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

Always provide DirectionsRoute in NavigationActivity #980

Merged
merged 2 commits into from
May 31, 2018

Conversation

danesfeder
Copy link
Contributor

NavigationLauncherOptions now requires a DirectionsRoute every time you build an instance.

This PR updates NavigationActivity to always provide the original route stored in SharedPreferences. This is okay because, when initializing, the NavigationViewModel ignores the route provided if it's already running (after rotation it will be already running because the view model survives rotation).

@danesfeder danesfeder added bug Defect to be fixed. navigation-ui labels May 31, 2018
@danesfeder danesfeder added this to the 0.14.0 milestone May 31, 2018
@danesfeder danesfeder self-assigned this May 31, 2018
@@ -67,13 +62,9 @@ static DirectionsRoute extractRoute(Context context) {
return DirectionsRoute.fromJson(directionsRouteJson);
}

private static void storeRouteOptions(NavigationLauncherOptions options, SharedPreferences.Editor editor) {
if (options.directionsRoute() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove null check?

@@ -77,10 +77,8 @@ public void updateRawLocation(@NonNull Location rawLocation) {

private void extractRouteFromOptions(NavigationViewOptions options) {
DirectionsRoute route = options.directionsRoute();
if (route != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove null check?

@@ -56,7 +56,7 @@ public void onDestroy() {
@Override
public void onStart() {
requestAudioFocus();
instructionQueue.remove();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just do instructionQueue.poll which is the empty-safe version of remove

@@ -69,7 +69,7 @@ public void onError(boolean isMapboxPlayer) {
if (isMapboxPlayer) {
androidSpeechPlayer.play(instructionQueue.peek().getAnnouncement());
} else {
instructionQueue.remove();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@danesfeder danesfeder merged commit 1c808c6 into master May 31, 2018
@danesfeder danesfeder deleted the dan-options-rotation branch May 31, 2018 17:22
@danesfeder danesfeder mentioned this pull request May 31, 2018
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defect to be fixed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants