diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index ed2bf456f6..66ff2c1ae9 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -104,10 +104,6 @@ public class ContextMenuAdapter { return items; } - public void updateItems(List items) { - this.items = items; - } - public void removeItem(int position) { items.remove(position); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 8674c15663..57717e57eb 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -567,13 +567,14 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo // TODO refactor section ContextMenuAdapter adapter = menu.getActionsContextMenuAdapter(false); List items = adapter.getItems(); - List main = new ArrayList<>(); - List additional = new ArrayList<>(); - for (int i = 0; i < 4; i++) { - main.add(items.get(i)); - } - for (int i = 4; i < items.size(); i++) { - additional.add(items.get(i)); + ContextMenuAdapter mainAdapter = new ContextMenuAdapter(requireMyApplication()); + ContextMenuAdapter additionalAdapter = new ContextMenuAdapter(requireMyApplication()); + for (int i = 0; i < items.size(); i++) { + if (i < 4) { + mainAdapter.addItem(items.get(i)); + } else { + additionalAdapter.addItem(items.get(i)); + } } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, @@ -581,15 +582,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo 1f ); buttons.removeAllViews(); - ContextMenuAdapter mainAdapter = new ContextMenuAdapter(requireMyApplication()); - mainAdapter.updateItems(main); ContextMenuItemClickListener mainListener = menu.getContextMenuItemClickListener(mainAdapter); - ContextMenuAdapter additionalAdapter = new ContextMenuAdapter(requireMyApplication()); - additionalAdapter.updateItems(additional); ContextMenuItemClickListener additionalListener = menu.getContextMenuItemClickListener(additionalAdapter); - for (int i = 0; i < main.size(); i++) { - buttons.addView(getActionView(main.get(i), i, mainAdapter, additionalAdapter, mainListener, additionalListener), params); + for (int i = 0; i < 4; i++) { + buttons.addView(getActionView(items.get(i), i, mainAdapter, additionalAdapter, mainListener, additionalListener), params); } buttons.setGravity(Gravity.CENTER);