mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-01-27 07:46:09 +01:00
Clear widget when service is being shutdown
This commit is contained in:
parent
70f8b75019
commit
87c160610f
@ -102,7 +102,6 @@ class NavigationActivity : AppCompatActivity() {
|
||||
Timber.d("onCreate called")
|
||||
|
||||
// First check if Koin has been started
|
||||
|
||||
if (UApp.instance != null && !UApp.instance!!.initiated) {
|
||||
Timber.d("Starting Koin")
|
||||
UApp.instance!!.startKoin()
|
||||
|
@ -87,6 +87,9 @@ class PlaybackService : MediaLibraryService(), KoinComponent {
|
||||
}
|
||||
|
||||
private fun releasePlayerAndSession() {
|
||||
// Broadcast that the service is being shutdown
|
||||
RxBus.stopCommandPublisher.onNext(Unit)
|
||||
|
||||
player.release()
|
||||
mediaLibrarySession.release()
|
||||
rxBusSubscription.dispose()
|
||||
|
@ -97,6 +97,7 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() {
|
||||
playing: Boolean,
|
||||
setAlbum: Boolean
|
||||
) {
|
||||
Timber.d("Updating Widget")
|
||||
val res = context.resources
|
||||
val views = RemoteViews(context.packageName, layoutId)
|
||||
val title = currentSong?.title
|
||||
|
@ -166,6 +166,11 @@ class MediaPlayerController(
|
||||
}
|
||||
}
|
||||
|
||||
rxBusSubscription += RxBus.stopCommandObservable.subscribe {
|
||||
// Clear the widget when we stop the service
|
||||
updateWidget(null)
|
||||
}
|
||||
|
||||
created = true
|
||||
Timber.i("MediaPlayerController started")
|
||||
}
|
||||
|
@ -63,6 +63,12 @@ class RxBus {
|
||||
PublishSubject.create()
|
||||
val shutdownCommandObservable: Observable<Unit> =
|
||||
shutdownCommandPublisher.observeOn(mainThread())
|
||||
|
||||
val stopCommandPublisher: PublishSubject<Unit> =
|
||||
PublishSubject.create()
|
||||
val stopCommandObservable: Observable<Unit> =
|
||||
stopCommandPublisher.observeOn(mainThread())
|
||||
|
||||
}
|
||||
|
||||
data class StateWithTrack(
|
||||
|
Loading…
x
Reference in New Issue
Block a user