removed unnecessary changes

This commit is contained in:
Chumva 2018-06-08 18:16:08 +03:00
parent 92235adeb1
commit 9de34ecf0c
3 changed files with 9 additions and 21 deletions

View file

@ -10,20 +10,15 @@ import net.osmand.plus.mapcontextmenu.MenuBuilder;
public class TransportStopMenuBuilder extends MenuBuilder { public class TransportStopMenuBuilder extends MenuBuilder {
private final TransportStop transportStop; private final TransportStop transportStop;
private Amenity amenity;
public TransportStopMenuBuilder(MapActivity mapActivity, final TransportStop transportStop) { public TransportStopMenuBuilder(MapActivity mapActivity, final TransportStop transportStop) {
super(mapActivity); super(mapActivity);
this.transportStop = transportStop; this.transportStop = transportStop;
acquireOriginObject();
}
private void acquireOriginObject() {
amenity = transportStop.getAmenity();
} }
@Override @Override
public void buildInternal(View view) { public void buildInternal(View view) {
Amenity amenity = transportStop.getAmenity();
if (amenity != null) { if (amenity != null) {
AmenityMenuBuilder builder = new AmenityMenuBuilder(mapActivity, amenity); AmenityMenuBuilder builder = new AmenityMenuBuilder(mapActivity, amenity);
builder.setLatLon(getLatLon()); builder.setLatLon(getLatLon());

View file

@ -165,7 +165,7 @@ public class TransportStopController extends MenuController {
if (amenity != null) { if (amenity != null) {
AmenityMenuController.addTypeMenuItem(amenity, builder); AmenityMenuController.addTypeMenuItem(amenity, builder);
} else { } else {
addMyLocationToPlainItems(latLon); super.addPlainMenuItems(typeStr, pointDescription, latLon);
} }
} }
} }

View file

@ -207,8 +207,13 @@ public class OsmEditingPlugin extends OsmandPlugin {
} }
}; };
boolean isEditable = false; boolean isEditable = false;
if (selectedObj instanceof Amenity) { if (selectedObj instanceof Amenity || (selectedObj instanceof TransportStop && ((TransportStop) selectedObj).getAmenity() != null)) {
Amenity amenity = (Amenity) selectedObj; Amenity amenity;
if (selectedObj instanceof Amenity) {
amenity = (Amenity) selectedObj;
} else {
amenity = ((TransportStop) selectedObj).getAmenity();
}
final PoiType poiType = amenity.getType().getPoiTypeByKeyName(amenity.getSubType()); final PoiType poiType = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
isEditable = !amenity.getType().isWiki() && poiType !=null && !poiType.isNotEditableOsm(); isEditable = !amenity.getType().isWiki() && poiType !=null && !poiType.isNotEditableOsm();
} }
@ -224,18 +229,6 @@ public class OsmEditingPlugin extends OsmandPlugin {
.setOrder(MODIFY_OSM_CHANGE_ITEM_ORDER) .setOrder(MODIFY_OSM_CHANGE_ITEM_ORDER)
.setListener(listener) .setListener(listener)
.createItem()); .createItem());
} else if (selectedObj instanceof TransportStop && ((TransportStop) selectedObj).getAmenity() != null) {
TransportStop transportStop = (TransportStop) selectedObj;
Amenity amenity = transportStop.getAmenity();
final PoiType poiType = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
isEditable = !amenity.getType().isWiki() && poiType != null && !poiType.isNotEditableOsm();
if (isEditable) {
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.poi_context_menu_modify, mapActivity)
.setIcon(R.drawable.ic_action_edit_dark)
.setOrder(MODIFY_POI_ITEM_ORDER)
.setListener(listener)
.createItem());
}
} else { } else {
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_create_poi, mapActivity) adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_create_poi, mapActivity)
.setIcon(R.drawable.ic_action_plus_dark) .setIcon(R.drawable.ic_action_plus_dark)