From 904be34a87b361afe08097e5c8c1fa7e5d94862e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Sun, 19 Jan 2020 19:19:30 +0100 Subject: [PATCH] [Notifications] Fix showing an empty notification where the list is empty. --- .../edziennik/data/api/task/PostNotifications.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/PostNotifications.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/PostNotifications.kt index ebf77f6a..91aa0df0 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/PostNotifications.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/PostNotifications.kt @@ -57,9 +57,11 @@ class PostNotifications(val app: App, nList: MutableList) { return summaryTexts.concat(", ") } - init { - val notificationManager = app.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + init { run { val count = nList.size + if (count == 0) + return@run + val notificationManager = app.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val summaryCounts = SparseIntArray() val newNotificationsText = app.resources.getQuantityString(R.plurals.notification_count_format, count, count) @@ -165,5 +167,5 @@ class PostNotifications(val app: App, nList: MutableList) { notificationManager.notify(app.notifications.dataId, summary) } } - } + }} }