[Android] Fix the mini visualizer leaking the 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:59:54 2024 +0100| [7da67c5d34af52b4ba20b3d083927046aa74cda0] | committer: Duncan McNamara
Fix the mini visualizer leaking the HeaderMediaListActivity
> https://code.videolan.org/videolan/vlc-android/commit/7da67c5d34af52b4ba20b3d083927046aa74cda0
---
.../videolan/vlc/gui/HeaderMediaListActivity.kt | 27 ++++++++++++++--------
1 file changed, 18 insertions(+), 9 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 3c45e85cba..ba4c0fabb9 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
@@ -167,15 +167,6 @@ 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) }
}
@@ -239,6 +230,24 @@ open class HeaderMediaListActivity : AudioPlayerContainerActivity(), IEventsHand
binding.browserFastScroller.setRecyclerView(binding.songs, viewModel.tracksProvider)
}
+ override fun onResume() {
+ super.onResume()
+ 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)
+ }
+
+ override fun onPause() {
+ super.onPause()
+ audioBrowserAdapter.setCurrentlyPlaying(false)
+ }
+
override fun onStop() {
super.onStop()
stopActionMode()
More information about the Android
mailing list