diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index b16126e3df..f5421a7919 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu; import android.app.Dialog; import android.app.ProgressDialog; import android.content.DialogInterface; +import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog.Builder; @@ -214,7 +215,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL public MapContextMenu() { } - public boolean init(LatLon latLon, PointDescription pointDescription, Object object) { + public boolean init(LatLon latLon, PointDescription pointDescription, @Nullable Object object) { return init(latLon, pointDescription, object, false); } @@ -295,7 +296,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } } - public void show(LatLon latLon, PointDescription pointDescription, Object object) { + public void show(LatLon latLon, PointDescription pointDescription, @Nullable Object object) { if (init(latLon, pointDescription, object)) { if (!MapContextMenuFragment.showInstance(this, mapActivity, centerMarker)) { active = false; @@ -406,7 +407,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } } - private void setSelectedObject(Object object) { + private void setSelectedObject(@Nullable Object object) { if (object != null) { for (OsmandMapLayer l : mapActivity.getMapView().getLayers()) { if (l instanceof ContextMenuLayer.IContextMenuProvider) { diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 499a7d335b..2d97e5a319 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -211,12 +211,15 @@ public class ContextMenuLayer extends OsmandMapLayer { } public void applyMovedObject(Object o, LatLon position, ApplyMovedObjectCallback callback) { - if (selectedObjectContextMenuProvider != null - && selectedObjectContextMenuProvider instanceof ContextMenuLayer.IMoveObjectProvider) { - final IMoveObjectProvider l = (ContextMenuLayer.IMoveObjectProvider) selectedObjectContextMenuProvider; - if (l.isObjectMovable(o)) { - l.applyNewObjectPosition(o, position, callback); + if (selectedObjectContextMenuProvider != null) { + if (selectedObjectContextMenuProvider instanceof IMoveObjectProvider) { + final IMoveObjectProvider l = (IMoveObjectProvider) selectedObjectContextMenuProvider; + if (l.isObjectMovable(o)) { + l.applyNewObjectPosition(o, position, callback); + } } + } else if (mInChangeMarkerPositionMode) { + callback.onApplyMovedObject(true, null); } } @@ -235,7 +238,7 @@ public class ContextMenuLayer extends OsmandMapLayer { mMoveMarkerBottomSheetHelper.enterApplyPositionMode(); applyMovedObject(obj, ll, new ApplyMovedObjectCallback() { @Override - public void onApplyMovedObject(boolean success, Object newObject) { + public void onApplyMovedObject(boolean success, @Nullable Object newObject) { mMoveMarkerBottomSheetHelper.exitApplyPositionMode(); if (success && !cancelApplyingNewMarkerPosition) { mMoveMarkerBottomSheetHelper.hide(); @@ -540,7 +543,7 @@ public class ContextMenuLayer extends OsmandMapLayer { public interface ApplyMovedObjectCallback { - void onApplyMovedObject(boolean success, Object newObject); + void onApplyMovedObject(boolean success, @Nullable Object newObject); boolean isCancelled(); }