add "forceBuild" parameter to getNotification() method

This commit is contained in:
Nazar 2019-08-29 13:44:29 +03:00
parent b680721396
commit 44754dbb18

View file

@ -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;
}