Add "gpx waypoint action" to the right position

This commit is contained in:
Alexander Sytnyk 2018-01-23 12:57:57 +02:00
parent f7e688023e
commit daddcdbece

View file

@ -304,12 +304,14 @@ public class MapActivityActions implements DialogProvider {
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.context_menu_item_edit_waypoint, mapActivity)
.setIcon(R.drawable.ic_action_edit_dark)
.setPosition(getPositionForGpxAction(adapter))
.setListener(listener).createItem());
} else if (!getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles().isEmpty()
|| (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null)) {
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.context_menu_item_add_waypoint, mapActivity)
.setIcon(R.drawable.ic_action_gnew_label_dark)
.setPosition(getPositionForGpxAction(adapter))
.setListener(listener).createItem());
}
@ -346,6 +348,17 @@ public class MapActivityActions implements DialogProvider {
actionsBottomSheetDialogFragment.show(mapActivity.getSupportFragmentManager(), AdditionalActionsBottomSheetDialogFragment.TAG);
}
private int getPositionForGpxAction(ContextMenuAdapter adapter) {
for (int i = 0; i < adapter.length(); i++) {
int titleId = adapter.getItem(i).getTitleId();
if (titleId == R.string.context_menu_item_add_parking_point
|| titleId == R.string.context_menu_item_update_map) {
return i;
}
}
return adapter.length();
}
public void setGPXRouteParams(GPXFile result) {
if (result == null) {
mapActivity.getRoutingHelper().setGpxParams(null);