diff --git a/app/src/main/java/org/tasks/notifications/NotificationManager.java b/app/src/main/java/org/tasks/notifications/NotificationManager.java index da849d98b..1752bcc55 100644 --- a/app/src/main/java/org/tasks/notifications/NotificationManager.java +++ b/app/src/main/java/org/tasks/notifications/NotificationManager.java @@ -128,7 +128,7 @@ public class NotificationManager { createNotifications(notifications, false, false, false, true); } else { createNotifications(notifications, false, false, false, false); - notificationManagerCompat.cancel(SUMMARY_NOTIFICATION_ID); + cancelSummaryNotification(); } } @@ -138,12 +138,12 @@ public class NotificationManager { notificationDao.insertAll(newNotifications); int totalCount = existingNotifications.size() + newNotifications.size(); if (totalCount == 0) { - notificationManagerCompat.cancel(SUMMARY_NOTIFICATION_ID); + cancelSummaryNotification(); } else if (totalCount == 1) { List notifications = newArrayList(concat(existingNotifications, newNotifications)); createNotifications(notifications, alert, nonstop, fiveTimes, false); - notificationManagerCompat.cancel(SUMMARY_NOTIFICATION_ID); + cancelSummaryNotification(); } else if (preferences.bundleNotifications()) { updateSummary(false, false, false, Collections.emptyList()); @@ -235,6 +235,10 @@ public class NotificationManager { boolean notify, boolean nonStop, boolean fiveTimes, List newNotifications) { List tasks = taskDao.activeNotifications(); int taskCount = tasks.size(); + if (taskCount == 0) { + cancelSummaryNotification(); + return; + } ArrayList taskIds = newArrayList(transform(tasks, Task::getId)); Filter filter = new Filter( @@ -429,4 +433,8 @@ public class NotificationManager { snoozePendingIntent) .extend(wearableExtender); } + + private void cancelSummaryNotification() { + notificationManagerCompat.cancel(SUMMARY_NOTIFICATION_ID); + } }