diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index 6bf5b4eeec..92a570b05f 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -55,7 +55,11 @@ public class ContextMenuAdapter { } public void addItem(ContextMenuItem item) { - items.add(item); + try { + items.add(item.getPos(), item); + } catch (IndexOutOfBoundsException ex) { + items.add(item); + } } public ContextMenuItem getItem(int position) { diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java index 0805ee2ee4..2a197de6eb 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java @@ -198,7 +198,7 @@ public class ContextMenuItem { private int mLayout = INVALID_ID; private boolean mLoading = false; private boolean mIsCategory = false; - private int mPosition = INVALID_ID; + private int mPosition = -1; private String mDescription = null; private ContextMenuAdapter.ItemClickListener mItemClickListener = null; private ContextMenuAdapter.OnIntegerValueChangedListener mIntegerListener = null;