From 657eeeaaf38aa930c28a760fda67e451c145d2cf Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Thu, 12 Nov 2015 16:45:11 +0300 Subject: [PATCH] Fix maps order in multi menu --- .../other/MapMultiSelectionMenu.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenu.java index 19e98b9443..9862887476 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenu.java @@ -30,6 +30,7 @@ public class MapMultiSelectionMenu extends BaseMenuController { private LatLon latLon; private PointDescription pointDescription; private Object object; + private int order; private MapActivity mapActivity; private MenuController controller; @@ -107,8 +108,6 @@ public class MapMultiSelectionMenu extends BaseMenuController { this.selectedObjects.clear(); this.selectedObjects.putAll(selectedObjects); objects.clear(); - int order = Integer.MAX_VALUE; - MenuObject topObject = null; for (Map.Entry e : selectedObjects.entrySet()) { Object selectedObj = e.getKey(); IContextMenuProvider contextObject = selectedObjects.get(selectedObj); @@ -130,25 +129,20 @@ public class MapMultiSelectionMenu extends BaseMenuController { objects.add(menuObject); if (contextObject instanceof ContextMenuLayer.IContextMenuProviderSelection) { - int i = ((ContextMenuLayer.IContextMenuProviderSelection) contextObject).getOrder(selectedObj); - if (i < order) { - topObject = menuObject; - order = i; - } + menuObject.order = ((ContextMenuLayer.IContextMenuProviderSelection) contextObject).getOrder(selectedObj); } } Collections.sort(objects, new Comparator() { @Override public int compare(MenuObject obj1, MenuObject obj2) { - return obj1.getTitleStr().compareToIgnoreCase(obj2.getTitleStr()); + if (obj1.order == obj2.order) { + return obj1.getTitleStr().compareToIgnoreCase(obj2.getTitleStr()); + } else { + return obj1.order - obj2.order; + } } }); - - if (topObject != null) { - objects.remove(topObject); - objects.add(0, topObject); - } } private void clearMenu() {