Skip to content

Commit f2cfe93

Browse files
author
Guardiola31337
committed
add instruction loader null checks to prevent potential npes
1 parent cbdc3a7 commit f2cfe93

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/instruction/InstructionView.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,15 +750,22 @@ private void updateDataFromInstruction(InstructionModel model) {
750750
private void updateDataFromBannerInstruction(InstructionModel model) {
751751
updateManeuverView(model);
752752
if (model.getPrimaryBannerText() != null) {
753-
createInstructionLoader(upcomingPrimaryText, model.getPrimaryBannerText()).loadInstruction();
753+
InstructionLoader instructionLoader = createInstructionLoader(upcomingPrimaryText, model.getPrimaryBannerText());
754+
if (instructionLoader != null) {
755+
instructionLoader.loadInstruction();
756+
}
754757
}
755758
if (model.getSecondaryBannerText() != null) {
756759
if (upcomingSecondaryText.getVisibility() == GONE) {
757760
upcomingSecondaryText.setVisibility(VISIBLE);
758761
upcomingPrimaryText.setMaxLines(1);
759762
adjustBannerTextVerticalBias(0.65f);
760763
}
761-
createInstructionLoader(upcomingSecondaryText, model.getSecondaryBannerText()).loadInstruction();
764+
InstructionLoader instructionLoader = createInstructionLoader(upcomingSecondaryText,
765+
model.getSecondaryBannerText());
766+
if (instructionLoader != null) {
767+
instructionLoader.loadInstruction();
768+
}
762769
} else {
763770
upcomingPrimaryText.setMaxLines(2);
764771
upcomingSecondaryText.setVisibility(GONE);

libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/RouteProcessorRunnable.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ private void process() {
5959
NavigationEngineFactory engineFactory = navigation.retrieveEngineFactory();
6060
final boolean userOffRoute = isUserOffRoute(options, status, rawLocation, routeProgress, engineFactory);
6161
final Location snappedLocation = findSnappedLocation(status, rawLocation, routeProgress, engineFactory);
62-
final boolean checkFasterRoute = checkFasterRoute(options, snappedLocation, routeProgress, engineFactory, userOffRoute);
62+
final boolean checkFasterRoute = checkFasterRoute(options, snappedLocation, routeProgress, engineFactory,
63+
userOffRoute);
6364
final List<Milestone> milestones = findTriggeredMilestones(navigation, routeProgress);
6465

6566
sendUpdateToResponseHandler(userOffRoute, milestones, snappedLocation, checkFasterRoute, routeProgress);

0 commit comments

Comments
 (0)