Update PersistentNotificationPlugin.kt
This commit is contained in:
parent
e4c3e4c560
commit
f668cc4af3
1 changed files with 2 additions and 10 deletions
|
@ -65,10 +65,10 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
// End Android auto
|
// End Android auto
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
private var channel: NotificationChannel? = null
|
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
|
notificationHolder.createNotificationChannel()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventRefreshOverview::class.java)
|
.toObservable(EventRefreshOverview::class.java)
|
||||||
.observeOn(aapsSchedulers.io)
|
.observeOn(aapsSchedulers.io)
|
||||||
|
@ -103,12 +103,6 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
.subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException)
|
.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() {
|
override fun onStop() {
|
||||||
disposable.clear()
|
disposable.clear()
|
||||||
dummyServiceHelper.stopService(context)
|
dummyServiceHelper.stopService(context)
|
||||||
|
@ -116,8 +110,6 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun triggerNotificationUpdate() {
|
private fun triggerNotificationUpdate() {
|
||||||
if (channel == null)
|
|
||||||
createNotificationChannel() // make sure channels exist before triggering updates through the bus
|
|
||||||
updateNotification()
|
updateNotification()
|
||||||
dummyServiceHelper.startService(context)
|
dummyServiceHelper.startService(context)
|
||||||
}
|
}
|
||||||
|
@ -231,4 +223,4 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
mNotificationManager.notify(notificationHolder.notificationID, notification)
|
mNotificationManager.notify(notificationHolder.notificationID, notification)
|
||||||
notificationHolder.notification = notification
|
notificationHolder.notification = notification
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue