[Notifications] Fix showing an empty notification where the list is empty.

This commit is contained in:
Kuba Szczodrzyński 2020-01-19 19:19:30 +01:00
parent b7fc6fcc38
commit 904be34a87

View File

@ -57,9 +57,11 @@ class PostNotifications(val app: App, nList: MutableList<AppNotification>) {
return summaryTexts.concat(", ") return summaryTexts.concat(", ")
} }
init { init { run {
val notificationManager = app.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val count = nList.size val count = nList.size
if (count == 0)
return@run
val notificationManager = app.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val summaryCounts = SparseIntArray() val summaryCounts = SparseIntArray()
val newNotificationsText = app.resources.getQuantityString(R.plurals.notification_count_format, count, count) val newNotificationsText = app.resources.getQuantityString(R.plurals.notification_count_format, count, count)
@ -165,5 +167,5 @@ class PostNotifications(val app: App, nList: MutableList<AppNotification>) {
notificationManager.notify(app.notifications.dataId, summary) notificationManager.notify(app.notifications.dataId, summary)
} }
} }
} }}
} }