From c45e8b0162d8a0bbbd3a17778e9e2ebdf256da1f Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Fri, 12 Jan 2018 17:52:28 +0200 Subject: [PATCH] Fix NPE in osm point category --- OsmAnd/res/values/strings.xml | 1 + .../osmand/plus/osmedit/EditPOIMenuController.java | 8 +------- .../net/osmand/plus/osmedit/OsmEditingPlugin.java | 13 +++++++++++++ .../net/osmand/plus/osmedit/OsmEditsAdapter.java | 14 +------------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 2780b25267..d4552f4772 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Without name What\'s here: parked at Pick up until diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index 4808a06256..15327f3b8e 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -196,12 +196,6 @@ public class EditPOIMenuController extends MenuController { } private String getCategory() { - String category = ""; - if (osmPoint.getGroup() == OsmPoint.Group.POI) { - category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(EditPoiData.POI_TYPE_TAG); - } else if (osmPoint.getGroup() == OsmPoint.Group.BUG) { - category = getMapActivity().getString(R.string.osn_bug_name); - } - return category; + return OsmEditingPlugin.getCategory(osmPoint, getMapActivity()); } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 7c3aa390ab..4c63bcb5cf 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -445,6 +445,19 @@ public class OsmEditingPlugin extends OsmandPlugin { } } + public static String getCategory(OsmPoint osmPoint, Context context) { + String category = ""; + if (osmPoint.getGroup() == OsmPoint.Group.POI) { + category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(EditPoiData.POI_TYPE_TAG); + if (Algorithms.isEmpty(category)) { + category = context.getString(R.string.shared_string_without_name); + } + } else if (osmPoint.getGroup() == OsmPoint.Group.BUG) { + category = context.getString(R.string.osn_bug_name); + } + return category; + } + public static String getPrefix(OsmPoint osmPoint) { return (osmPoint.getGroup() == OsmPoint.Group.POI ? "POI" : "Bug") + " id: " + osmPoint.getId() + " "; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java index 1a88db662c..450a9ce993 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java @@ -301,11 +301,7 @@ public class OsmEditsAdapter extends ArrayAdapter { } private String getCategory(OsmPoint point) { - String category = ""; - if (point.getGroup() == OsmPoint.Group.POI) { - category = ((OpenstreetmapPoint) point).getEntity().getTag(EditPoiData.POI_TYPE_TAG); - } - return category; + return OsmEditingPlugin.getCategory(point, getContext()); } private String getDescription(OsmPoint point) { @@ -322,20 +318,12 @@ public class OsmEditsAdapter extends ArrayAdapter { String category = getCategory(point); - String comment = ""; - if (point.getGroup() == OsmPoint.Group.BUG) { - comment = getContext().getString(R.string.osn_bug_name); - } - String prefix = OsmEditingPlugin.getPrefix(point); String description = ""; if (!Algorithms.isEmpty(action)) { description += action + " • "; } - if (!Algorithms.isEmpty(comment)) { - description += comment + " • "; - } if (!Algorithms.isEmpty(category)) { description += category + " • "; }