refactor Action buttons
This commit is contained in:
parent
b85b562cb6
commit
6fe8311d92
2 changed files with 10 additions and 17 deletions
|
@ -104,10 +104,6 @@ public class ContextMenuAdapter {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateItems(List<ContextMenuItem> items) {
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeItem(int position) {
|
public void removeItem(int position) {
|
||||||
items.remove(position);
|
items.remove(position);
|
||||||
}
|
}
|
||||||
|
|
|
@ -567,13 +567,14 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
// TODO refactor section
|
// TODO refactor section
|
||||||
ContextMenuAdapter adapter = menu.getActionsContextMenuAdapter(false);
|
ContextMenuAdapter adapter = menu.getActionsContextMenuAdapter(false);
|
||||||
List<ContextMenuItem> items = adapter.getItems();
|
List<ContextMenuItem> items = adapter.getItems();
|
||||||
List<ContextMenuItem> main = new ArrayList<>();
|
ContextMenuAdapter mainAdapter = new ContextMenuAdapter(requireMyApplication());
|
||||||
List<ContextMenuItem> additional = new ArrayList<>();
|
ContextMenuAdapter additionalAdapter = new ContextMenuAdapter(requireMyApplication());
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < items.size(); i++) {
|
||||||
main.add(items.get(i));
|
if (i < 4) {
|
||||||
}
|
mainAdapter.addItem(items.get(i));
|
||||||
for (int i = 4; i < items.size(); i++) {
|
} else {
|
||||||
additional.add(items.get(i));
|
additionalAdapter.addItem(items.get(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
@ -581,15 +582,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
1f
|
1f
|
||||||
);
|
);
|
||||||
buttons.removeAllViews();
|
buttons.removeAllViews();
|
||||||
ContextMenuAdapter mainAdapter = new ContextMenuAdapter(requireMyApplication());
|
|
||||||
mainAdapter.updateItems(main);
|
|
||||||
ContextMenuItemClickListener mainListener = menu.getContextMenuItemClickListener(mainAdapter);
|
ContextMenuItemClickListener mainListener = menu.getContextMenuItemClickListener(mainAdapter);
|
||||||
ContextMenuAdapter additionalAdapter = new ContextMenuAdapter(requireMyApplication());
|
|
||||||
additionalAdapter.updateItems(additional);
|
|
||||||
ContextMenuItemClickListener additionalListener = menu.getContextMenuItemClickListener(additionalAdapter);
|
ContextMenuItemClickListener additionalListener = menu.getContextMenuItemClickListener(additionalAdapter);
|
||||||
|
|
||||||
for (int i = 0; i < main.size(); i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
buttons.addView(getActionView(main.get(i), i, mainAdapter, additionalAdapter, mainListener, additionalListener), params);
|
buttons.addView(getActionView(items.get(i), i, mainAdapter, additionalAdapter, mainListener, additionalListener), params);
|
||||||
}
|
}
|
||||||
buttons.setGravity(Gravity.CENTER);
|
buttons.setGravity(Gravity.CENTER);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue