diff --git a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java index ef39e9b91c..180524edc6 100644 --- a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java +++ b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java @@ -146,11 +146,11 @@ public class TargetPointsHelper { Location lastKnownLocation = ctx.getLocationProvider().getLastKnownLocation(); if((routingHelper.isFollowingMode() && lastKnownLocation != null) || start == null) { routingHelper.setFinalAndCurrentLocation(settings.getPointToNavigate(), - settings.getIntermediatePoints(), lastKnownLocation, routingHelper.getCurrentGPXRoute()); + settings.getIntermediatePoints(), lastKnownLocation); } else { Location loc = wrap(start); routingHelper.setFinalAndCurrentLocation(settings.getPointToNavigate(), - settings.getIntermediatePoints(), loc, routingHelper.getCurrentGPXRoute()); + settings.getIntermediatePoints(), loc); } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index bc306b44e7..9640a43505 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -834,8 +834,7 @@ public class MapActivityActions implements DialogProvider { if(getMyApplication().getLocationProvider().getLocationSimulation().isRouteAnimating()) { getMyApplication().getLocationProvider().getLocationSimulation().startStopRouteAnimation(mapActivity); } - routingHelper.setFinalAndCurrentLocation(null, new ArrayList(), getLastKnownLocation(), - routingHelper.getCurrentGPXRoute()); + routingHelper.clearCurrentRoute(null, new ArrayList()); routingHelper.setRoutePlanningMode(false); settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get()); mapActivity.updateApplicationModeSettings(); diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 2b11f72470..7e3abb22a2 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -116,14 +116,11 @@ public class RoutingHelper { - public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, List intermediatePoints, Location currentLocation, - GPXRouteParamsBuilder gpxRoute){ + public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, List intermediatePoints, Location currentLocation){ + RouteCalculationResult previousRoute = route; clearCurrentRoute(finalLocation, intermediatePoints); - - setGpxParams(gpxRoute); // to update route - setCurrentLocation(currentLocation, false); - + setCurrentLocation(currentLocation, false, previousRoute); } public synchronized void clearCurrentRoute(LatLon newFinalLocation, List newIntermediatePoints) { @@ -210,8 +207,11 @@ public class RoutingHelper { } } + public Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation) { + return setCurrentLocation(currentLocation, returnUpdatedLocation, route); + } - public Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation ) { + private Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation, RouteCalculationResult previousRoute) { Location locationProjection = currentLocation; if (finalLocation == null || currentLocation == null) { makeUturnWhenPossible = false; @@ -286,8 +286,8 @@ public class RoutingHelper { } if (calculateRoute) { - recalculateRouteInBackground(false, currentLocation, finalLocation, intermediatePoints, currentGPXRoute, route.isCalculated() ? route - : null); + recalculateRouteInBackground(false, currentLocation, finalLocation, intermediatePoints, currentGPXRoute, + previousRoute.isCalculated() ? previousRoute : null); } double projectDist = mode.hasFastSpeed() ? posTolerance : posTolerance / 2; if(returnUpdatedLocation && locationProjection != null && currentLocation.distanceTo(locationProjection) < projectDist) {