From 8044f306e2d2aa5a62f199817301747d1ef5805d Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 11 Feb 2021 12:45:14 +0200 Subject: [PATCH 1/4] Try to fix possible npe --- .../osmand/plus/mapcontextmenu/MapContextMenu.java | 2 +- .../plus/mapcontextmenu/MenuTitleController.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index cd035da4bb..3fe1e4452b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -651,7 +651,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } private void updateTitle(String address) { - nameStr = address; + setNameStr(address); getPointDescription().setName(address); WeakReference fragmentRef = findMenuFragment(); if (fragmentRef != null) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java index f676c5812e..722e09c27d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java @@ -138,6 +138,10 @@ public abstract class MenuTitleController { } } + public void setNameStr(@Nullable String nameStr) { + this.nameStr = nameStr != null ? nameStr : ""; + } + protected boolean needStreetName() { MenuController menuController = getMenuController(); boolean res = getObject() != null || Algorithms.isEmpty(getPointDescription().getName()); @@ -165,28 +169,28 @@ public abstract class MenuTitleController { protected void acquireNameAndType() { String firstNameStr = ""; - nameStr = ""; typeStr = ""; commonTypeStr = ""; streetStr = ""; + setNameStr(""); MenuController menuController = getMenuController(); if (menuController != null) { firstNameStr = menuController.getFirstNameStr(); - nameStr = menuController.getNameStr(); + setNameStr(menuController.getNameStr()); typeStr = menuController.getTypeStr(); commonTypeStr = menuController.getCommonTypeStr(); } if (Algorithms.isEmpty(nameStr)) { - nameStr = typeStr; + setNameStr(typeStr); typeStr = commonTypeStr; } else if (Algorithms.isEmpty(typeStr)) { typeStr = commonTypeStr; } if (!Algorithms.isEmpty(firstNameStr)) { - nameStr = firstNameStr + " (" + nameStr + ")"; + setNameStr(firstNameStr + " (" + nameStr + ")"); } } @@ -204,7 +208,7 @@ public abstract class MenuTitleController { } if (displayStreetNameInTitle()) { - nameStr = streetStr; + setNameStr(streetStr); getPointDescription().setName(nameStr); } onSearchAddressDone(); From 33a2cf6ba3cac4e60673aa0e51aeae5030d8a55c Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 11 Feb 2021 13:12:40 +0200 Subject: [PATCH 2/4] Fix possible npe --- OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 51e7370da6..2c6666e925 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -1369,7 +1369,9 @@ public class MenuBuilder { if (amenity != null) { PoiCategory category = amenity.getType(); PoiType poiType = category.getPoiTypeByKeyName(amenity.getSubType()); - return app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + poiType.getKeyName()); + if (poiType != null) { + return app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + poiType.getKeyName()); + } } return null; } From b5ccc8bed84dcc12a0aa65f4e2d3b274422f10eb Mon Sep 17 00:00:00 2001 From: Skalii Date: Fri, 12 Feb 2021 18:31:26 +0200 Subject: [PATCH 3/4] fix display correct general information in track context menu after import gpx file --- OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index c7b1ebd63b..9ba7186f0d 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -2480,6 +2480,7 @@ public class GPXUtilities { firstSegment.routeSegments = routeSegments; firstSegment.routeTypes = routeTypes; } + gpxFile.addGeneralTrack(); } catch (Exception e) { gpxFile.error = e; log.error("Error reading gpx", e); //$NON-NLS-1$ From 2bf1c899fd8eb0d368c093797bb87a41fc4cc6d1 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Sun, 14 Feb 2021 11:05:48 +0100 Subject: [PATCH 4/4] Update GPXUtilities.java don't write too much noisy data so it's better handled in graphs & other programs - https://github.com/osmandapp/OsmAnd/issues/10864 --- OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index c7b1ebd63b..9f5b954015 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -60,7 +60,8 @@ public class GPXUtilities { private final static NumberFormat latLonFormat = new DecimalFormat("0.00#####", new DecimalFormatSymbols( new Locale("EN", "US"))); - private final static NumberFormat decimalFormat = new DecimalFormat("#.###", new DecimalFormatSymbols( + // speed, ele, hdop + private final static NumberFormat decimalFormat = new DecimalFormat("#.#", new DecimalFormatSymbols( new Locale("EN", "US"))); public enum GPXColor { @@ -2594,4 +2595,4 @@ public class GPXUtilities { to.error = from.error; } } -} \ No newline at end of file +}