add checks for getPoiCategory

This commit is contained in:
Chumva 2018-05-29 17:40:30 +03:00
parent ff4b3f4046
commit 144e0012c1
3 changed files with 18 additions and 8 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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());