Add check for mapObjectId

This commit is contained in:
Chumva 2018-09-06 14:43:47 +03:00
parent 8e9044652d
commit 948875cc9a
2 changed files with 6 additions and 1 deletions

View file

@ -416,6 +416,10 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
long objectId = object.getId();
boolean isWay = objectId % 2 == 1;// check if mapObject is a way
long entityId;
if (!(objectId > 0 && (objectId % 2 == 1 || (objectId >> 7) < Integer.MAX_VALUE))) {
return null;
}
if (object instanceof Amenity) {
entityId = objectId >> 1;
} else {

View file

@ -222,7 +222,8 @@ public class OsmEditingPlugin extends OsmandPlugin {
final PoiType poiType = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
isEditable = !amenity.getType().isWiki() && poiType !=null && !poiType.isNotEditableOsm();
} else if (selectedObj instanceof MapObject) {
isEditable = true;
Long objectId = ((MapObject) selectedObj).getId();
isEditable = objectId != null && objectId > 0 && (objectId % 2 == 1 || (objectId >> 7) < Integer.MAX_VALUE);
}
if (isEditable) {
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.poi_context_menu_modify, mapActivity)