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

Notification check for valid BannerInstructions before updating #637

Merged
merged 1 commit into from
Jan 8, 2018
Merged
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 @@ -47,6 +47,13 @@ class MapboxNavigationNotification implements NavigationNotification {
private int currentManeuverId;
private int distanceUnitType;

private BroadcastReceiver endNavigationBtnReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
MapboxNavigationNotification.this.onEndNavigationBtnClick();
}
};

MapboxNavigationNotification(Context context, MapboxNavigation mapboxNavigation) {
this.mapboxNavigation = mapboxNavigation;
this.distanceUnitType = mapboxNavigation.options().unitType();
Expand Down Expand Up @@ -145,16 +152,18 @@ private void updateNotificationViews(RouteProgress routeProgress) {
}

private void updateInstructionText(LegStep step) {
if (instructionText == null || newInstructionText(step)) {
if (hasInstructions(step) && (instructionText == null || newInstructionText(step))) {
instructionText = step.bannerInstructions().get(0).primary().text();
notificationRemoteViews.setTextViewText(R.id.notificationInstructionText, instructionText);
}
}

private boolean hasInstructions(LegStep step) {
return step.bannerInstructions() != null && !step.bannerInstructions().isEmpty();
}

private boolean newInstructionText(LegStep step) {
return step.bannerInstructions() != null
&& !step.bannerInstructions().isEmpty()
&& !instructionText.equals(step.bannerInstructions().get(0).primary().text());
return !instructionText.equals(step.bannerInstructions().get(0).primary().text());
}

private void updateDistanceText(RouteProgress routeProgress) {
Expand Down Expand Up @@ -208,11 +217,4 @@ private void onEndNavigationBtnClick() {
mapboxNavigation.endNavigation();
}
}

private BroadcastReceiver endNavigationBtnReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
MapboxNavigationNotification.this.onEndNavigationBtnClick();
}
};
}