From b904e2d2055abcec73da9bf6932022d06e35c082 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 9 Oct 2017 12:09:24 +0300 Subject: [PATCH 1/3] Fix #3753 --- .../src/net/osmand/plus/mapcontextmenu/MapContextMenu.java | 7 +++++++ OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 3afdfbdf74..303f119c3f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -398,6 +398,13 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL if (fragmentRef != null) { fragmentRef.get().rebuildMenu(centerMarker); } + ContextMenuLayer contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer(); + for (OsmandMapLayer layer : mapActivity.getMapView().getLayers()) { + if (layer instanceof ContextMenuLayer.IMoveObjectProvider && ((ContextMenuLayer.IMoveObjectProvider) layer).isObjectMovable(object)) { + contextMenuLayer.setSelectedObjectContextMenuProvider((ContextMenuLayer.IContextMenuProvider) layer); + break; + } + } centerMarker = false; } diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 14902589be..a34489ee2f 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -97,6 +97,10 @@ public class ContextMenuLayer extends OsmandMapLayer { mAddGpxPointBottomSheetHelper = new AddGpxPointBottomSheetHelper(activity, this); } + public void setSelectedObjectContextMenuProvider(IContextMenuProvider provider) { + this.selectedObjectContextMenuProvider = provider; + } + public AddGpxPointBottomSheetHelper getAddGpxPointBottomSheetHelper() { return mAddGpxPointBottomSheetHelper; } From 6169630188e4b461b22e065b1dffe7825b8d90ca Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 9 Oct 2017 12:50:22 +0300 Subject: [PATCH 2/3] Update provider in layer after adding point --- .../net/osmand/plus/mapcontextmenu/MapContextMenu.java | 7 +------ OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java | 9 +++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 303f119c3f..10595db2e3 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -399,12 +399,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL fragmentRef.get().rebuildMenu(centerMarker); } ContextMenuLayer contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer(); - for (OsmandMapLayer layer : mapActivity.getMapView().getLayers()) { - if (layer instanceof ContextMenuLayer.IMoveObjectProvider && ((ContextMenuLayer.IMoveObjectProvider) layer).isObjectMovable(object)) { - contextMenuLayer.setSelectedObjectContextMenuProvider((ContextMenuLayer.IContextMenuProvider) layer); - break; - } - } + contextMenuLayer.updateContextMenu(); centerMarker = false; } diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index a34489ee2f..9a3fd5fe21 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -232,6 +232,15 @@ public class ContextMenuLayer extends OsmandMapLayer { this.selectOnMap = selectOnMap; } + public void updateContextMenu() { + for (OsmandMapLayer layer : view.getLayers()) { + if (layer instanceof ContextMenuLayer.IMoveObjectProvider && ((ContextMenuLayer.IMoveObjectProvider) layer).isObjectMovable(selectedObject)) { + selectedObjectContextMenuProvider = (IContextMenuProvider) layer; + break; + } + } + } + @Override public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter, MapActivity mapActivity) { if (menu.hasHiddenBottomInfo()) { From 4efc82caf183b6f068504e78943986475fcdaaa7 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 9 Oct 2017 12:51:50 +0300 Subject: [PATCH 3/3] Remove setter for provider --- OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 9a3fd5fe21..7740d4e12b 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -97,10 +97,6 @@ public class ContextMenuLayer extends OsmandMapLayer { mAddGpxPointBottomSheetHelper = new AddGpxPointBottomSheetHelper(activity, this); } - public void setSelectedObjectContextMenuProvider(IContextMenuProvider provider) { - this.selectedObjectContextMenuProvider = provider; - } - public AddGpxPointBottomSheetHelper getAddGpxPointBottomSheetHelper() { return mAddGpxPointBottomSheetHelper; }