add method getRouteMenuAppMode()

This commit is contained in:
Nazar 2019-11-05 14:16:53 +02:00
parent e1c76c4a0f
commit cc543b61f7
2 changed files with 10 additions and 7 deletions

View file

@ -576,7 +576,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
}
bottomShadowVisible = routes.size() == 0;
} else {
RouteMenuAppModes mode = app.getRoutingOptionsHelper().modes.get(routingHelper.getAppMode());
RouteMenuAppModes mode = app.getRoutingOptionsHelper().getRouteMenuAppMode(routingHelper.getAppMode());
boolean avoidPTTypesCustomized = false;
for (LocalRoutingParameter parameter : mode.parameters) {
if (parameter instanceof AvoidPTTypesRoutingParameter) {
@ -916,7 +916,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
final OsmandApplication app = mapActivity.getMyApplication();
RoutingHelper routingHelper = app.getRoutingHelper();
final ApplicationMode applicationMode = routingHelper.getAppMode();
final RouteMenuAppModes mode = app.getRoutingOptionsHelper().modes.get(applicationMode);
final RouteMenuAppModes mode = app.getRoutingOptionsHelper().getRouteMenuAppMode(applicationMode);
updateControlButtons(mapActivity, mainView);
LinearLayout optionsButton = (LinearLayout) mainView.findViewById(R.id.map_options_route_button);

View file

@ -62,15 +62,11 @@ public class RoutingOptionsHelper {
private OsmandApplication app;
private OsmandSettings settings;
Map<ApplicationMode, RouteMenuAppModes> modes = new HashMap<>();
private Map<ApplicationMode, RouteMenuAppModes> modes = new HashMap<>();
public RoutingOptionsHelper(OsmandApplication application) {
app = application;
settings = app.getSettings();
for (ApplicationMode activeMode : ApplicationMode.values(app)) {
addRouteMenuAppModes(activeMode, getRoutingParametersForProfileType(activeMode));
}
}
private void addRouteMenuAppModes(ApplicationMode am, List<String> routingParameters) {
@ -90,6 +86,13 @@ public class RoutingOptionsHelper {
}
}
public RouteMenuAppModes getRouteMenuAppMode(ApplicationMode appMode) {
if (!modes.containsKey(appMode)) {
addRouteMenuAppModes(appMode, getRoutingParametersForProfileType(appMode));
}
return modes.get(appMode);
}
public void switchSound() {
RoutingHelper routingHelper = app.getRoutingHelper();
boolean mt = !routingHelper.getVoiceRouter().isMute();