From 3ee1ef6e4a626f90894017b7fb20bce9f29f185c Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 25 Oct 2019 15:18:11 +0300 Subject: [PATCH] Fix #7693 --- OsmAnd/src/net/osmand/plus/AppInitializer.java | 3 ++- .../net/osmand/plus/activities/MapActivity.java | 17 +++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index c95fd8e3ef..3e6718eea3 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -130,7 +130,7 @@ public class AppInitializer implements IProgress { FAVORITES_INITIALIZED, NATIVE_INITIALIZED, NATIVE_OPEN_GLINITIALIZED, TASK_CHANGED, MAPS_INITIALIZED, POI_TYPES_INITIALIZED, ASSETS_COPIED, INIT_RENDERERS, - RESTORE_BACKUPS, INDEX_REGION_BOUNDARIES, SAVE_GPX_TRACKS, LOAD_GPX_TRACKS + RESTORE_BACKUPS, INDEX_REGION_BOUNDARIES, SAVE_GPX_TRACKS, LOAD_GPX_TRACKS, ROUTING_CONFIG_INITIALIZED } public interface AppInitializeListener { @@ -588,6 +588,7 @@ public class AppInitializer implements IProgress { protected void onPostExecute(Builder builder) { super.onPostExecute(builder); app.updateRoutingConfig(builder); + notifyEvent(InitEvents.ROUTING_CONFIG_INITIALIZED); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index d5f1e70f81..7d0e613cc3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -318,12 +318,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven mapLayers.createLayers(mapView); createProgressBarForRouting(); updateStatusBarColor(); - // This situtation could be when navigation suddenly crashed and after restarting - // it tries to continue the last route - if (settings.FOLLOW_THE_ROUTE.get() && !app.getRoutingHelper().isRouteCalculated() - && !app.getRoutingHelper().isRouteBeingCalculated()) { - FailSafeFuntions.restoreRoutingMode(this); - } else if (!app.getRoutingHelper().isRoutePlanningMode() + + if (!app.getRoutingHelper().isRoutePlanningMode() && !settings.FOLLOW_THE_ROUTE.get() && app.getTargetPointsHelper().getAllPoints().size() > 0) { app.getRoutingHelper().clearCurrentRoute(null, new ArrayList()); @@ -423,6 +419,15 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven if (event == InitEvents.FAVORITES_INITIALIZED) { refreshMap(); } + if (event == InitEvents.ROUTING_CONFIG_INITIALIZED) { + // This situation could be when navigation suddenly crashed and after restarting + // it tries to continue the last route + if (settings.FOLLOW_THE_ROUTE.get() + && !app.getRoutingHelper().isRouteCalculated() + && !app.getRoutingHelper().isRouteBeingCalculated()) { + FailSafeFuntions.restoreRoutingMode(MapActivity.this); + } + } } @Override