Extract common code

This commit is contained in:
Alexander Sytnyk 2017-10-05 14:48:10 +03:00
parent 94ee59462f
commit 987b476b32
3 changed files with 8 additions and 11 deletions

View file

@ -889,8 +889,6 @@ public class PlanRouteFragment extends Fragment {
}
private RouteCalculationParams getParams(final OsmandApplication app) {
OsmandSettings settings = app.getSettings();
final Pair<WptPt, WptPt> 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();

View file

@ -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<WptPt, WptPt> 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();

View file

@ -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;
}