[Android] Fix the mini visualizer leaking in the file browser

Nicolas Pomepuy git at videolan.org
Wed Apr 10 16:13:11 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Mar 22 14:35:14 2024 +0100| [e695745cd809386cb6639206b4f3c280f3b5cb2b] | committer: Duncan McNamara

Fix the mini visualizer leaking in the file browser

> https://code.videolan.org/videolan/vlc-android/commit/e695745cd809386cb6639206b4f3c280f3b5cb2b
---

 .../videolan/vlc/gui/browser/BaseBrowserFragment.kt | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index 914956058b..b26736bac5 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -291,12 +291,6 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
             adapter.currentMedia = it
         }
 
-        val playlistModel = PlaylistModel.get(this)
-        adapter.setModel(playlistModel)
-        playlistModel.dataset.asFlow().conflate().onEach {
-            adapter.setCurrentlyPlaying(playlistModel.playing)
-            delay(50L)
-        }.launchWhenStarted(lifecycleScope)
         inCards = Settings.getInstance(requireActivity()).getBoolean(BROWSER_DISPLAY_IN_CARDS, false)
     }
 
@@ -400,6 +394,21 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
         needRefresh.postValue(false)
     }
 
+    override fun onPause() {
+        super.onPause()
+        adapter.setCurrentlyPlaying(false)
+    }
+
+    override fun onResume() {
+        super.onResume()
+        val playlistModel = PlaylistModel.get(this)
+        adapter.setModel(playlistModel)
+        playlistModel.dataset.asFlow().conflate().onEach {
+            adapter.setCurrentlyPlaying(playlistModel.playing)
+            delay(50L)
+        }.launchWhenStarted(lifecycleScope)
+    }
+
     override fun onDestroy() {
         if (::adapter.isInitialized) adapter.cancel()
         super.onDestroy()



More information about the Android mailing list