Fix ErrorNotification appearance

This commit is contained in:
Nazar 2019-08-23 16:19:43 +03:00
parent c2adf00dad
commit a93be94c1d
2 changed files with 13 additions and 7 deletions

View file

@ -191,9 +191,16 @@ public class NavigationService extends Service implements LocationListener {
// registering icon at top level
// Leave icon visible even for navigation for proper display
Notification notification = app.getNotificationHelper().buildTopNotification();
startForeground(OsmandNotification.TOP_NOTIFICATION_SERVICE_ID, notification);
app.getNotificationHelper().refreshNotifications();
return START_REDELIVER_INTENT;
if (notification != null) {
startForeground(OsmandNotification.TOP_NOTIFICATION_SERVICE_ID, notification);
app.getNotificationHelper().refreshNotifications();
return START_REDELIVER_INTENT;
} else {
notification = app.getNotificationHelper().buildErrorNotification();
startForeground(OsmandNotification.TOP_NOTIFICATION_SERVICE_ID, notification);
stopSelf();
return START_NOT_STICKY;
}
}

View file

@ -46,7 +46,6 @@ public class NotificationHelper {
all.add(downloadNotification);
}
@NonNull
public Notification buildTopNotification() {
OsmandNotification notification = acquireTopNotification();
if (notification != null) {
@ -56,10 +55,10 @@ public class NotificationHelper {
if (notificationBuilder != null) {
return notificationBuilder.build();
} else {
return buildErrorNotification();
return null;
}
} else {
return buildErrorNotification();
return null;
}
}
@ -68,7 +67,7 @@ public class NotificationHelper {
return downloadNotification.buildNotification(false).build();
}
private Notification buildErrorNotification() {
public Notification buildErrorNotification() {
removeNotification(errorNotification.getType());
setTopNotification(errorNotification);
return errorNotification.buildNotification(false).build();