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