From 7e16d30a718239de9eb9894c2b35fa9865f462ec Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 25 May 2018 17:20:07 +0300 Subject: [PATCH 1/3] add npe check for poi category --- .../src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index 64fd505d75..21003595a5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -143,7 +143,10 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment amenityTagTextView.setText(pt.getEditOsmTag()); amenityTextView.setText(pt.getEditOsmValue()); } else { - amenityTagTextView.setText(getData().getPoiCategory().getDefaultTag()); + PoiCategory category = getData().getPoiCategory(); + if (category != null) { + amenityTagTextView.setText(category.getDefaultTag()); + } amenityTextView.setText(getData().getPoiTypeString()); } } From ff4b3f40465ceb35fa6c0598149b50f54f044939 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 29 May 2018 16:06:05 +0300 Subject: [PATCH 2/3] add default type for null category --- OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index 21003595a5..dab14a0284 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -146,6 +146,8 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment PoiCategory category = getData().getPoiCategory(); if (category != null) { amenityTagTextView.setText(category.getDefaultTag()); + } else { + amenityTagTextView.setText(R.string.tag_poi_amenity); } amenityTextView.setText(getData().getPoiTypeString()); } From 144e0012c131a787e2246cf404d5559759d2e29d Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 29 May 2018 17:40:30 +0300 Subject: [PATCH 3/3] add checks for getPoiCategory --- .../src/net/osmand/plus/osmedit/EditPoiData.java | 4 +++- .../plus/osmedit/EditPoiDialogFragment.java | 16 +++++++++++----- .../plus/quickaction/actions/AddPOIAction.java | 6 ++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java index d64264c9eb..f818a30175 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java @@ -1,5 +1,7 @@ package net.osmand.plus.osmedit; +import android.support.annotation.Nullable; + import net.osmand.PlatformUtil; import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiType; @@ -52,7 +54,7 @@ public class EditPoiData { } } - + @Nullable public PoiCategory getPoiCategory() { return category; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 4532a1349f..21d76332e9 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -273,7 +273,10 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { if (!getEditPoiData().isInEdit()) { getEditPoiData().updateTypeTag(s.toString(), true); if (!getMyApplication().isApplicationInitializing()) { - poiTypeTextInputLayout.setHint(editPoiData.getPoiCategory().getTranslation()); + PoiCategory category = editPoiData.getPoiCategory(); + if (category != null) { + poiTypeTextInputLayout.setHint(category.getTranslation()); + } } } } @@ -289,9 +292,10 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { if (event.getX() >= (editText.getRight() - editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width() - editText.getPaddingRight())) { - if (editPoiData.getPoiCategory() != null) { + PoiCategory category = editPoiData.getPoiCategory(); + if (category != null) { PoiSubTypeDialogFragment dialogFragment = - PoiSubTypeDialogFragment.createInstance(editPoiData.getPoiCategory()); + PoiSubTypeDialogFragment.createInstance(category); dialogFragment.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() { @Override public void select(String category) { @@ -466,8 +470,10 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { node.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag2()); } } else if (!Algorithms.isEmpty(poiTypeTag)) { - node.putTagNoLC(editPoiData.getPoiCategory().getDefaultTag(), poiTypeTag); - + PoiCategory category = editPoiData.getPoiCategory(); + if (category != null) { + node.putTagNoLC(category.getDefaultTag(), poiTypeTag); + } } if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) { node.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java index d264656730..7eac6c5123 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/AddPOIAction.java @@ -117,8 +117,10 @@ public class AddPOIAction extends QuickAction { newNode.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); } } else if (!Algorithms.isEmpty(tag.getValue())) { - newNode.putTagNoLC(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue()); - + PoiCategory category = editPoiData.getPoiCategory(); + if (category != null) { + newNode.putTagNoLC(category.getDefaultTag(), tag.getValue()); + } } if (offlineEdit && !Algorithms.isEmpty(tag.getValue())) { newNode.putTagNoLC(tag.getKey(), tag.getValue());