From e019ec788d874f80145bce06b19819488737ba44 Mon Sep 17 00:00:00 2001 From: Nite Date: Mon, 15 Nov 2021 18:20:26 +0100 Subject: [PATCH] Fixed subscription --- .../kotlin/org/moire/ultrasonic/fragment/PlayerFragment.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/PlayerFragment.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/PlayerFragment.kt index 3c15c61d..14cbbdf5 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/PlayerFragment.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/PlayerFragment.kt @@ -39,6 +39,7 @@ import androidx.lifecycle.lifecycleScope import androidx.navigation.Navigation import com.mobeta.android.dslv.DragSortListView import com.mobeta.android.dslv.DragSortListView.DragSortListener +import io.reactivex.rxjava3.disposables.Disposable import java.text.DateFormat import java.text.SimpleDateFormat import java.util.ArrayList @@ -112,6 +113,7 @@ class PlayerFragment : Fragment(), GestureDetector.OnGestureListener, KoinCompon private var currentPlaying: DownloadFile? = null private var currentSong: MusicDirectory.Entry? = null private var onProgressChangedTask: SilentBackgroundTask? = null + private var rxBusSubscription: Disposable? = null // Views and UI Elements private lateinit var visualizerViewLayout: LinearLayout @@ -422,7 +424,7 @@ class PlayerFragment : Fragment(), GestureDetector.OnGestureListener, KoinCompon ) // Observe playlist changes and update the UI - RxBus.playlistObservable.subscribe { + rxBusSubscription = RxBus.playlistObservable.subscribe { onPlaylistChanged() } @@ -488,6 +490,7 @@ class PlayerFragment : Fragment(), GestureDetector.OnGestureListener, KoinCompon } override fun onDestroyView() { + rxBusSubscription?.dispose() cancellationToken.cancel() super.onDestroyView() }