Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump up Navigation UI example #260

Merged
merged 1 commit into from
Sep 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

final List<SampleItem> 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),
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
}

Expand Down