[Android] Fix mini visualizer state in HeaderMediaListActivity

Nicolas Pomepuy git at videolan.org
Thu Feb 15 17:03:15 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Feb 15 08:41:16 2024 +0100| [95d137cf8f6719d38cb4e64d0ba6771176ab0fdc] | committer: Duncan McNamara

Fix mini visualizer state in HeaderMediaListActivity

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

 .../org/videolan/vlc/gui/HeaderMediaListActivity.kt   | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
index 61f50d26ae..3c45e85cba 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
@@ -152,17 +152,7 @@ open class HeaderMediaListActivity : AudioPlayerContainerActivity(), IEventsHand
         viewModel.tracksProvider.liveHeaders.observe(this) {
             binding.songs.invalidateItemDecorations()
         }
-        audioBrowserAdapter = AudioBrowserAdapter(MediaLibraryItem.TYPE_MEDIA, this, this, isPlaylist)
 
-        val playlistModel = PlaylistModel.get(this)
-        audioBrowserAdapter.setModel(playlistModel)
-        PlaylistManager.currentPlayedMedia.observe(this) {
-            audioBrowserAdapter.currentMedia = it
-        }
-        playlistModel.dataset.asFlow().conflate().onEach {
-            audioBrowserAdapter.setCurrentlyPlaying(playlistModel.playing)
-            delay(50L)
-        }.launchWhenStarted(lifecycleScope)
         if (isPlaylist) {
             audioBrowserAdapter = AudioBrowserAdapter(MediaLibraryItem.TYPE_MEDIA, this, this, isPlaylist)
             itemTouchHelperCallback = SwipeDragItemTouchHelperCallback(audioBrowserAdapter, lockedInSafeMode = Settings.safeMode)
@@ -177,6 +167,15 @@ open class HeaderMediaListActivity : AudioPlayerContainerActivity(), IEventsHand
             binding.songs.addItemDecoration(RecyclerSectionItemDecoration(resources.getDimensionPixelSize(R.dimen.recycler_section_header_height), true, viewModel.tracksProvider))
 
         }
+        val playlistModel = PlaylistModel.get(this)
+        PlaylistManager.currentPlayedMedia.observe(this) {
+            audioBrowserAdapter.currentMedia = it
+        }
+        playlistModel.dataset.asFlow().conflate().onEach {
+            audioBrowserAdapter.setCurrentlyPlaying(playlistModel.playing)
+            delay(50L)
+        }.launchWhenStarted(lifecycleScope)
+        audioBrowserAdapter.setModel(playlistModel)
         binding.btnShuffle.setOnClickListener {
             viewModel.playlist?.let { MediaUtils.playTracks(this, it, SecureRandom().nextInt(min(playlist.tracksCount, MEDIALIBRARY_PAGE_SIZE)), true) }
         }



More information about the Android mailing list