From 987b476b327f3b0958360dd862cb256ec73a1685 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 5 Oct 2017 14:48:10 +0300 Subject: [PATCH] Extract common code --- .../src/net/osmand/plus/mapmarkers/PlanRouteFragment.java | 6 +----- .../plus/measurementtool/MeasurementEditingContext.java | 7 +------ OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java | 6 ++++++ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java index 7eb075dfa8..0eb07e5415 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java @@ -889,8 +889,6 @@ public class PlanRouteFragment extends Fragment { } private RouteCalculationParams getParams(final OsmandApplication app) { - OsmandSettings settings = app.getSettings(); - final Pair currentPair = snapToRoadPairsToCalculate.poll(); Location start = new Location(""); @@ -903,9 +901,7 @@ public class PlanRouteFragment extends Fragment { params.inSnapToRoadMode = true; params.start = start; params.end = end; - params.leftSide = settings.DRIVING_REGION.get().leftHandDriving; - params.fast = settings.FAST_ROUTE_MODE.getModeValue(appMode); - params.type = settings.ROUTER_SERVICE.getModeValue(appMode); + RoutingHelper.applyApplicationSettings(params, app.getSettings(), appMode); params.mode = appMode; params.ctx = app; params.calculationProgress = calculationProgress = new RouteCalculationProgress(); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java index 5ffca2ee76..cb4ca4c637 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java @@ -8,7 +8,6 @@ import net.osmand.plus.ApplicationMode; import net.osmand.plus.GPXUtilities.TrkSegment; import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; import net.osmand.plus.measurementtool.command.MeasurementCommandManager; import net.osmand.plus.routing.RouteCalculationParams; import net.osmand.plus.routing.RoutingHelper; @@ -259,8 +258,6 @@ public class MeasurementEditingContext { } private RouteCalculationParams getParams() { - OsmandSettings settings = application.getSettings(); - final Pair currentPair = snapToRoadPairsToCalculate.poll(); Location start = new Location(""); @@ -273,9 +270,7 @@ public class MeasurementEditingContext { params.inSnapToRoadMode = true; params.start = start; params.end = end; - params.leftSide = settings.DRIVING_REGION.get().leftHandDriving; - params.fast = settings.FAST_ROUTE_MODE.getModeValue(snapToRoadAppMode); - params.type = settings.ROUTER_SERVICE.getModeValue(snapToRoadAppMode); + RoutingHelper.applyApplicationSettings(params, application.getSettings(), snapToRoadAppMode); params.mode = snapToRoadAppMode; params.ctx = application; params.calculationProgress = calculationProgress = new RouteCalculationProgress(); diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 15d920ec8f..cad742e399 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -1008,6 +1008,12 @@ public class RoutingHelper { } } + public static void applyApplicationSettings(RouteCalculationParams params, OsmandSettings settings, ApplicationMode mode) { + params.leftSide = settings.DRIVING_REGION.get().leftHandDriving; + params.fast = settings.FAST_ROUTE_MODE.getModeValue(mode); + params.type = settings.ROUTER_SERVICE.getModeValue(mode); + } + public void setProgressBar(RouteCalculationProgressCallback progressRoute) { this.progressRoute = progressRoute; }