[Android] Playlists: add composed blured background

Duncan McNamara git at videolan.org
Mon Sep 19 12:29:35 UTC 2022


vlc-android | branch: 3.5.x | Duncan McNamara <dcn.mcnamara at gmail.com> | Wed Sep 14 15:56:17 2022 +0200| [1804c226116465f7648df5ad046e15f2f8016292] | committer: Nicolas Pomepuy

Playlists: add composed blured background

(cherry picked from commit 7855bae8a5cf18cace719b3a1c36e3d9c07b1c3e)

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

 .../org/videolan/vlc/gui/HeaderMediaListActivity.kt   | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 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 91e90e301..b2722f1a6 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
@@ -156,9 +156,10 @@ open class HeaderMediaListActivity : AudioPlayerContainerActivity(), IEventsHand
         binding.songs.layoutManager = LinearLayoutManager(this)
         binding.songs.adapter = audioBrowserAdapter
 
+        val context = this
         lifecycleScope.launch {
             val cover = withContext(Dispatchers.IO) {
-                val width = getScreenWidth()
+                val width = if (binding.backgroundView.width > 0) binding.backgroundView.width else context.getScreenWidth()
                 if (!playlist.artworkMrl.isNullOrEmpty()) {
                     AudioUtil.fetchCoverBitmap(Uri.decode(playlist.artworkMrl), width)
                 } else {
@@ -168,16 +169,12 @@ open class HeaderMediaListActivity : AudioPlayerContainerActivity(), IEventsHand
             if (cover != null) {
                 binding.cover = BitmapDrawable(this at HeaderMediaListActivity.resources, cover)
                 binding.appbar.setExpanded(true, true)
-            }
-        }
-
-        val context = this
-        lifecycleScope.launch(Dispatchers.IO) {
-            val width = if (binding.backgroundView.width > 0) binding.backgroundView.width else context.getScreenWidth()
-            val blurredCover = UiTools.blurBitmap(AudioUtil.readCoverBitmap(Uri.decode(viewModel.playlist.artworkMrl), width))
-            withContext(Dispatchers.Main) {
-                binding.backgroundView.setColorFilter(UiTools.getColorFromAttribute(context, R.attr.audio_player_background_tint))
-                binding.backgroundView.setImageBitmap(blurredCover)
+                val radius = if (isPlaylist) 25f else 15f
+                val blurredCover = UiTools.blurBitmap(cover, radius)
+                withContext(Dispatchers.Main) {
+                    binding.backgroundView.setColorFilter(UiTools.getColorFromAttribute(context, R.attr.audio_player_background_tint))
+                    binding.backgroundView.setImageBitmap(blurredCover)
+                }
             }
         }
 



More information about the Android mailing list