fix actions clicks
This commit is contained in:
parent
c86a3fea30
commit
b229c7405b
4 changed files with 27 additions and 46 deletions
|
@ -1,25 +1,14 @@
|
||||||
{
|
{
|
||||||
"categories": {
|
"categories" : {
|
||||||
"special": {
|
"special" : {
|
||||||
"icons": [
|
"icons" : [
|
||||||
"special_star",
|
"special_star", "special_star_stroked", "special_marker", "special_flag_stroke", "special_house", "special_building"
|
||||||
"special_star_stroked",
|
]
|
||||||
"special_marker",
|
},
|
||||||
"special_flag_stroke",
|
"amenity" : {
|
||||||
"special_house",
|
"icons": [
|
||||||
"special_building"
|
"amenity_bar", "amenity_cafe", "amenity_atm", "amenity_biergarten", "amenity_cinema", "amenity_fire_station", "amenity_parking"
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
"amenity": {
|
|
||||||
"icons": [
|
|
||||||
"amenity_bar",
|
|
||||||
"amenity_cafe",
|
|
||||||
"amenity_atm",
|
|
||||||
"amenity_biergarten",
|
|
||||||
"amenity_cinema",
|
|
||||||
"amenity_fire_station",
|
|
||||||
"amenity_parking"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -87,6 +87,7 @@ public class ContextMenuAdapter {
|
||||||
|
|
||||||
public void addItem(ContextMenuItem item) {
|
public void addItem(ContextMenuItem item) {
|
||||||
try {
|
try {
|
||||||
|
// TODO
|
||||||
items.add(item.getPos(), item);
|
items.add(item.getPos(), item);
|
||||||
} catch (IndexOutOfBoundsException ex) {
|
} catch (IndexOutOfBoundsException ex) {
|
||||||
items.add(item);
|
items.add(item);
|
||||||
|
|
|
@ -1062,19 +1062,6 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void buttonMorePressed() {
|
|
||||||
// MapActivity mapActivity = getMapActivity();
|
|
||||||
// if (mapActivity != null) {
|
|
||||||
// final ContextMenuAdapter menuAdapter = new ContextMenuAdapter();
|
|
||||||
// LatLon latLon = getLatLon();
|
|
||||||
// for (OsmandMapLayer layer : mapActivity.getMapView().getLayers()) {
|
|
||||||
// layer.populateObjectContextMenu(latLon, getObject(), menuAdapter, mapActivity);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// mapActivity.getMapActions().contextMenuPoint(latLon.getLatitude(), latLon.getLongitude(), menuAdapter, getObject());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public ContextMenuAdapter getActionsContextMenuAdapter(boolean all) {
|
public ContextMenuAdapter getActionsContextMenuAdapter(boolean all) {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
final ContextMenuAdapter menuAdapter = new ContextMenuAdapter();
|
final ContextMenuAdapter menuAdapter = new ContextMenuAdapter();
|
||||||
|
|
|
@ -564,6 +564,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Action buttons
|
// Action buttons
|
||||||
|
// TODO refactor section
|
||||||
ContextMenuAdapter adapter = menu.getActionsContextMenuAdapter(false);
|
ContextMenuAdapter adapter = menu.getActionsContextMenuAdapter(false);
|
||||||
adapter.initItemsCustomOrder(requireMyApplication());
|
adapter.initItemsCustomOrder(requireMyApplication());
|
||||||
List<ContextMenuItem> items = adapter.getItems();
|
List<ContextMenuItem> items = adapter.getItems();
|
||||||
|
@ -581,8 +582,15 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
1f
|
1f
|
||||||
);
|
);
|
||||||
buttons.removeAllViews();
|
buttons.removeAllViews();
|
||||||
|
ContextMenuAdapter mainAdapter = new ContextMenuAdapter();
|
||||||
|
mainAdapter.updateItems(main);
|
||||||
|
ContextMenuItemClickListener mainListener = menu.getContextMenuItemClickListener(mainAdapter);
|
||||||
|
ContextMenuAdapter additionalAdapter = new ContextMenuAdapter();
|
||||||
|
additionalAdapter.updateItems(additional);
|
||||||
|
ContextMenuItemClickListener additionalListener = menu.getContextMenuItemClickListener(additionalAdapter);
|
||||||
|
|
||||||
for (int i = 0; i < main.size(); i++) {
|
for (int i = 0; i < main.size(); i++) {
|
||||||
buttons.addView(getActionView(main.get(i), i, adapter, additional,main), params);
|
buttons.addView(getActionView(main.get(i), i, mainAdapter, additionalAdapter, mainListener, additionalListener), params);
|
||||||
}
|
}
|
||||||
buttons.setGravity(Gravity.CENTER);
|
buttons.setGravity(Gravity.CENTER);
|
||||||
|
|
||||||
|
@ -645,9 +653,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
|
|
||||||
private View getActionView(ContextMenuItem contextMenuItem,
|
private View getActionView(ContextMenuItem contextMenuItem,
|
||||||
final int position,
|
final int position,
|
||||||
final ContextMenuAdapter adapter,
|
final ContextMenuAdapter mainAdapter,
|
||||||
List<ContextMenuItem> additional,
|
final ContextMenuAdapter additionalAdapter,
|
||||||
List<ContextMenuItem> main) {
|
final ContextMenuItemClickListener mainListener,
|
||||||
|
final ContextMenuItemClickListener additionalListener) {
|
||||||
UiUtilities uiUtilities = requireMyApplication().getUIUtilities();
|
UiUtilities uiUtilities = requireMyApplication().getUIUtilities();
|
||||||
LayoutInflater inflater = UiUtilities.getInflater(getMyApplication(), nightMode);
|
LayoutInflater inflater = UiUtilities.getInflater(getMyApplication(), nightMode);
|
||||||
View view = inflater.inflate(R.layout.context_menu_action_item, null);
|
View view = inflater.inflate(R.layout.context_menu_action_item, null);
|
||||||
|
@ -656,23 +665,18 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
TextView title = view.findViewById(R.id.text);
|
TextView title = view.findViewById(R.id.text);
|
||||||
icon.setImageDrawable(uiUtilities.getIcon(contextMenuItem.getIcon(), nightMode));
|
icon.setImageDrawable(uiUtilities.getIcon(contextMenuItem.getIcon(), nightMode));
|
||||||
title.setText(contextMenuItem.getTitle());
|
title.setText(contextMenuItem.getTitle());
|
||||||
adapter.updateItems(main);
|
|
||||||
final ContextMenuItemClickListener l = menu.getContextMenuItemClickListener(adapter);
|
|
||||||
if (contextMenuItem.getId().equals(MAP_CONTEXT_MENU_MORE_ID)) {
|
if (contextMenuItem.getId().equals(MAP_CONTEXT_MENU_MORE_ID)) {
|
||||||
final ContextMenuAdapter aditionalAdapter = adapter;
|
|
||||||
aditionalAdapter.updateItems(additional);
|
|
||||||
final ContextMenuItemClickListener listener = menu.getContextMenuItemClickListener(aditionalAdapter);
|
|
||||||
item.setOnClickListener(new View.OnClickListener() {
|
item.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
menu.showAdditionalActionsFragment(aditionalAdapter, listener);
|
menu.showAdditionalActionsFragment(additionalAdapter, additionalListener);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
item.setOnClickListener(new View.OnClickListener() {
|
item.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
l.onItemClick(position);
|
mainListener.onItemClick(position);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue