diff --git a/navigation/app/src/main/java/com/mapbox/services/android/navigation/testapp/MainActivity.java b/navigation/app/src/main/java/com/mapbox/services/android/navigation/testapp/MainActivity.java index 299d8cfe0c2..bf974022840 100644 --- a/navigation/app/src/main/java/com/mapbox/services/android/navigation/testapp/MainActivity.java +++ b/navigation/app/src/main/java/com/mapbox/services/android/navigation/testapp/MainActivity.java @@ -37,6 +37,11 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); final List samples = new ArrayList<>(Arrays.asList( + new SampleItem( + getString(R.string.title_navigation_view_ui), + getString(R.string.description_navigation_view_ui), + NavigationViewActivity.class + ), new SampleItem( getString(R.string.title_mock_navigation), getString(R.string.description_mock_navigation), @@ -62,11 +67,6 @@ protected void onCreate(Bundle savedInstanceState) { getString(R.string.description_navigation_route_ui), NavigationMapRouteActivity.class ), - new SampleItem( - getString(R.string.title_navigation_view_ui), - getString(R.string.description_navigation_view_ui), - NavigationViewActivity.class - ), new SampleItem( getString(R.string.title_long_step), getString(R.string.description_long_step), diff --git a/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationEngine.java b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationEngine.java index e0f6d1eaf66..d77aeba31c6 100644 --- a/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationEngine.java +++ b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationEngine.java @@ -91,6 +91,13 @@ private RouteProgress generateNewRouteProgress(MapboxNavigation mapboxNavigation MapboxNavigationOptions options = mapboxNavigation.options(); if (newRoute(directionsRoute)) { + // Need to keep track of total distance traveled even when reroute occurs. + if (previousRouteProgress != null) { + mapboxNavigation.getSessionState().toBuilder().previousRouteDistancesCompleted( + mapboxNavigation.getSessionState().previousRouteDistancesCompleted() + + previousRouteProgress.distanceTraveled() + ); + } // Decode the first steps geometry and hold onto the resulting Position objects till the users // on the next step. Indices are both 0 since the user just started on the new route. stepPositions = PolylineUtils.decode( @@ -105,12 +112,6 @@ private RouteProgress generateNewRouteProgress(MapboxNavigation mapboxNavigation .legIndex(0) .build(); - // Need to keep track of total distance traveled even when reroute occurs. - mapboxNavigation.getSessionState().toBuilder().previousRouteDistancesCompleted( - mapboxNavigation.getSessionState().previousRouteDistancesCompleted() - + previousRouteProgress.distanceTraveled() - ); - indices = NavigationIndices.create(0, 0); }