Merge pull request #5492 from osmandapp/FixPoiEdits

Add npe check for poi category
This commit is contained in:
Alexey 2018-05-29 18:05:04 +03:00 committed by GitHub
commit 6ad69050a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 9 deletions

View file

@ -143,7 +143,12 @@ 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());
} else {
amenityTagTextView.setText(R.string.tag_poi_amenity);
}
amenityTextView.setText(getData().getPoiTypeString());
}
}

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