Update PersistentNotificationPlugin.kt
This commit is contained in:
parent
e4c3e4c560
commit
f668cc4af3
|
@ -65,10 +65,10 @@ class PersistentNotificationPlugin @Inject constructor(
|
|||
// End Android auto
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
private var channel: NotificationChannel? = null
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
notificationHolder.createNotificationChannel()
|
||||
disposable += rxBus
|
||||
.toObservable(EventRefreshOverview::class.java)
|
||||
.observeOn(aapsSchedulers.io)
|
||||
|
@ -103,12 +103,6 @@ class PersistentNotificationPlugin @Inject constructor(
|
|||
.subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException)
|
||||
}
|
||||
|
||||
private fun createNotificationChannel() {
|
||||
val mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
channel = NotificationChannel(notificationHolder.channelID, notificationHolder.channelID as CharSequence, NotificationManager.IMPORTANCE_HIGH)
|
||||
channel?.let { mNotificationManager.createNotificationChannel(it) }
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
disposable.clear()
|
||||
dummyServiceHelper.stopService(context)
|
||||
|
@ -116,8 +110,6 @@ class PersistentNotificationPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
private fun triggerNotificationUpdate() {
|
||||
if (channel == null)
|
||||
createNotificationChannel() // make sure channels exist before triggering updates through the bus
|
||||
updateNotification()
|
||||
dummyServiceHelper.startService(context)
|
||||
}
|
||||
|
@ -231,4 +223,4 @@ class PersistentNotificationPlugin @Inject constructor(
|
|||
mNotificationManager.notify(notificationHolder.notificationID, notification)
|
||||
notificationHolder.notification = notification
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue