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 // registering icon at top level
// Leave icon visible even for navigation for proper display // Leave icon visible even for navigation for proper display
Notification notification = app.getNotificationHelper().buildTopNotification(); Notification notification = app.getNotificationHelper().buildTopNotification();
startForeground(OsmandNotification.TOP_NOTIFICATION_SERVICE_ID, notification); if (notification != null) {
app.getNotificationHelper().refreshNotifications(); startForeground(OsmandNotification.TOP_NOTIFICATION_SERVICE_ID, notification);
return START_REDELIVER_INTENT; 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); all.add(downloadNotification);
} }
@NonNull
public Notification buildTopNotification() { public Notification buildTopNotification() {
OsmandNotification notification = acquireTopNotification(); OsmandNotification notification = acquireTopNotification();
if (notification != null) { if (notification != null) {
@ -56,10 +55,10 @@ public class NotificationHelper {
if (notificationBuilder != null) { if (notificationBuilder != null) {
return notificationBuilder.build(); return notificationBuilder.build();
} else { } else {
return buildErrorNotification(); return null;
} }
} else { } else {
return buildErrorNotification(); return null;
} }
} }
@ -68,7 +67,7 @@ public class NotificationHelper {
return downloadNotification.buildNotification(false).build(); return downloadNotification.buildNotification(false).build();
} }
private Notification buildErrorNotification() { public Notification buildErrorNotification() {
removeNotification(errorNotification.getType()); removeNotification(errorNotification.getType());
setTopNotification(errorNotification); setTopNotification(errorNotification);
return errorNotification.buildNotification(false).build(); return errorNotification.buildNotification(false).build();