From 41c6a0c0f40020b8db8019c3797a860f79c83ae5 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 12 Nov 2015 11:02:50 +0100 Subject: [PATCH] Fix update edit poi data --- .../net/osmand/plus/osmedit/EditPoiData.java | 19 ++++++++++++++----- .../plus/osmedit/EditPoiDialogFragment.java | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java index 9c317cb166..291011d5bf 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java @@ -26,14 +26,13 @@ public class EditPoiData { private boolean hasChangesBeenMade = false; private Map allTranslatedSubTypes; private PoiCategory category; - private String subtype; public EditPoiData(Node node, OsmandApplication app) { allTranslatedSubTypes = app.getPoiTypes().getAllTranslatedNames(true); category = app.getPoiTypes().getOtherPoiCategory(); - subtype = ""; entity = node; initTags(node); + updateTypeTag(getPoiTypeString()); } public Map getAllTranslatedSubTypes() { @@ -43,7 +42,7 @@ public class EditPoiData { public void updateType(PoiCategory type) { if(type != null && type != category) { category = type; - subtype = ""; + tagValues.put(POI_TYPE_TAG, ""); } } @@ -57,7 +56,8 @@ public class EditPoiData { } public String getPoiTypeString() { - return subtype; + String s = tagValues.get(POI_TYPE_TAG) ; + return s == null ? "" : s; } public Node getEntity() { @@ -94,7 +94,6 @@ public class EditPoiData { if(tp != null) { PoiType pt = allTranslatedSubTypes.get(tp); if (pt != null) { - subtype = tp; category = pt.getCategory(); } } @@ -181,6 +180,16 @@ public class EditPoiData { return hasChangesBeenMade; } + public void updateTypeTag(String string) { + tagValues.put(POI_TYPE_TAG, string); + retrieveType(); + PoiType pt = getPoiTypeDefined(); + if(pt != null) { + tagValues.remove(pt.getOsmTag()); + tagValues.remove(pt.getOsmTag2()); + } + } + } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index b8b02fa595..c14e0b28b5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -250,7 +250,7 @@ public class EditPoiDialogFragment extends DialogFragment { @Override public void afterTextChanged(Editable s) { if (!getEditPoiData().isInEdit()) { - getEditPoiData().putTag(EditPoiData.POI_TYPE_TAG, s.toString()); + getEditPoiData().updateTypeTag(s.toString()); } } }); @@ -314,7 +314,7 @@ public class EditPoiDialogFragment extends DialogFragment { if (poiType.getOsmTag2() != null) { node.putTag(poiType.getOsmTag2(), poiType.getOsmValue2()); } - } else { + } else if (!Algorithms.isEmpty(tag.getValue())) { node.putTag(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue()); }