From 48f615846c3ed657157d331f72eae78292039a38 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Mon, 24 Oct 2016 22:49:36 +0300 Subject: [PATCH] Fix notification crash while navigating --- .../notifications/NavigationNotification.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java index afeeef5cab..9ce48abf34 100644 --- a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java +++ b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java @@ -8,9 +8,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.graphics.Bitmap; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.v4.app.NotificationCompat; @@ -18,7 +16,6 @@ import android.support.v4.app.NotificationCompat.BigTextStyle; import android.support.v4.app.NotificationCompat.Builder; import android.view.View; -import net.osmand.AndroidUtils; import net.osmand.plus.NavigationService; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; @@ -147,15 +144,18 @@ public class NavigationNotification extends OsmandNotification { } } - TurnDrawable drawable = new TurnDrawable(app, false); - int height = (int) app.getResources().getDimension(android.R.dimen.notification_large_icon_height); - int width = (int) app.getResources().getDimension(android.R.dimen.notification_large_icon_width); - drawable.setBounds(0, 0, width, height); - drawable.setTurnType(turnType); - drawable.setTurnImminent(turnImminent, deviatedFromRoute); - turnBitmap = drawableToBitmap(drawable); + if (turnType != null) { + TurnDrawable drawable = new TurnDrawable(app, false); + int height = (int) app.getResources().getDimension(android.R.dimen.notification_large_icon_height); + int width = (int) app.getResources().getDimension(android.R.dimen.notification_large_icon_width); + drawable.setBounds(0, 0, width, height); + drawable.setTurnType(turnType); + drawable.setTurnImminent(turnImminent, deviatedFromRoute); + turnBitmap = drawableToBitmap(drawable); + } - notificationTitle = OsmAndFormatter.getFormattedDistance(nextTurnDistance, app) + " • " + RouteCalculationResult.toString(turnType, app); + notificationTitle = OsmAndFormatter.getFormattedDistance(nextTurnDistance, app) + + (turnType != null ? " • " + RouteCalculationResult.toString(turnType, app) : ""); if (ri != null && !Algorithms.isEmpty(ri.getDescriptionRoutePart())) { notificationText.append(ri.getDescriptionRoutePart()); notificationText.append("\n");