From cc543b61f7276ab52b0bea8d90284dbc062b1f67 Mon Sep 17 00:00:00 2001 From: Nazar Date: Tue, 5 Nov 2019 14:16:53 +0200 Subject: [PATCH] add method getRouteMenuAppMode() --- .../plus/routepreparationmenu/MapRouteInfoMenu.java | 4 ++-- .../routepreparationmenu/RoutingOptionsHelper.java | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index 1d92f245c3..95f428ad51 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java index dee2367b77..9d3cab36fe 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java @@ -62,15 +62,11 @@ public class RoutingOptionsHelper { private OsmandApplication app; private OsmandSettings settings; - Map modes = new HashMap<>(); + private Map 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 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();