-
Notifications
You must be signed in to change notification settings - Fork 319
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
Conversation
@@ -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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
14cef8f
to
954867c
Compare
NavigationLauncherOptions
now requires aDirectionsRoute
every time you build an instance.This PR updates
NavigationActivity
to always provide the original route stored inSharedPreferences
. This is okay because, when initializing, theNavigationViewModel
ignores the route provided if it's already running (after rotation it will be already running because the view model survives rotation).