From b6807213962bfc703dc4a7a8e6cc38f3abf931b7 Mon Sep 17 00:00:00 2001 From: Nazar Date: Thu, 29 Aug 2019 13:24:26 +0300 Subject: [PATCH 1/2] Fix refresh notification bug --- .../net/osmand/plus/notifications/OsmandNotification.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java b/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java index a38c74c579..eaea74cff0 100644 --- a/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java +++ b/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java @@ -141,13 +141,13 @@ public abstract class OsmandNotification { if (isEnabled()) { Builder notificationBuilder = buildNotification(false); if (notificationBuilder != null) { - Notification notification = getNotification(notificationBuilder); - setupNotification(notification); + currentNotification = notificationBuilder.build(); + setupNotification(currentNotification); if (top) { //notificationManager.cancel(getOsmandNotificationId()); - notificationManager.notify(TOP_NOTIFICATION_SERVICE_ID, notification); + notificationManager.notify(TOP_NOTIFICATION_SERVICE_ID, currentNotification); } else { - notificationManager.notify(getOsmandNotificationId(), notification); + notificationManager.notify(getOsmandNotificationId(), currentNotification); } notifyWearable(notificationManager); return true; From 44754dbb18949d9386b03a6690ac5bc71f94da85 Mon Sep 17 00:00:00 2001 From: Nazar Date: Thu, 29 Aug 2019 13:44:29 +0300 Subject: [PATCH 2/2] add "forceBuild" parameter to getNotification() method --- .../plus/notifications/OsmandNotification.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java b/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java index eaea74cff0..30ed6236ed 100644 --- a/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java +++ b/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java @@ -126,7 +126,7 @@ public abstract class OsmandNotification { if (isEnabled()) { Builder notificationBuilder = buildNotification(false); if (notificationBuilder != null) { - Notification notification = getNotification(notificationBuilder); + Notification notification = getNotification(notificationBuilder, false); setupNotification(notification); notificationManager.notify(top ? TOP_NOTIFICATION_SERVICE_ID : getOsmandNotificationId(), notification); notifyWearable(notificationManager); @@ -141,13 +141,13 @@ public abstract class OsmandNotification { if (isEnabled()) { Builder notificationBuilder = buildNotification(false); if (notificationBuilder != null) { - currentNotification = notificationBuilder.build(); - setupNotification(currentNotification); + Notification notification = getNotification(notificationBuilder, true); + setupNotification(notification); if (top) { //notificationManager.cancel(getOsmandNotificationId()); - notificationManager.notify(TOP_NOTIFICATION_SERVICE_ID, currentNotification); + notificationManager.notify(TOP_NOTIFICATION_SERVICE_ID, notification); } else { - notificationManager.notify(getOsmandNotificationId(), currentNotification); + notificationManager.notify(getOsmandNotificationId(), notification); } notifyWearable(notificationManager); return true; @@ -160,9 +160,9 @@ public abstract class OsmandNotification { return false; } - private Notification getNotification(Builder notificationBuilder) { + private Notification getNotification(Builder notificationBuilder, boolean forceBuild) { Notification notification = currentNotification; - if (notification == null) { + if (forceBuild || notification == null) { notification = notificationBuilder.build(); currentNotification = notification; }