[Android] Allow changing the favorite state for a playlist

Nicolas Pomepuy git at videolan.org
Tue Mar 14 11:59:20 UTC 2023


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Feb 20 13:47:11 2023 +0100| [2271552517aede6a52923d0f082c799cd2bc8382] | committer: Nicolas Pomepuy

Allow changing the favorite state for a playlist

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

 .../src/org/videolan/vlc/gui/HeaderMediaListActivity.kt        | 10 ++++++----
 .../src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt         |  2 +-
 2 files changed, 7 insertions(+), 5 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 c35dff3f46..5dd1340847 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
@@ -128,10 +128,12 @@ open class HeaderMediaListActivity : AudioPlayerContainerActivity(), IEventsHand
         }
 
         viewModel.playlistLiveData.observe(this) { playlist ->
-            (playlist as? Album)?.let {
-                binding.btnFavorite.setVisible()
-                binding.btnFavorite.setImageDrawable(ContextCompat.getDrawable(this, if (it.isFavorite) R.drawable.ic_header_media_favorite else R.drawable.ic_header_media_favorite_outline))
-            } ?: binding.btnFavorite.setGone()
+            binding.btnFavorite.setImageDrawable(
+                ContextCompat.getDrawable(
+                    this,
+                    if (playlist.isFavorite) R.drawable.ic_header_media_favorite else R.drawable.ic_header_media_favorite_outline
+                )
+            )
 
             var totalDuration = 0L
             for (item in playlist.tracks)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt
index f3b0ae9f59..87f8a7b095 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt
@@ -392,7 +392,7 @@ abstract class BaseAudioBrowser<T : MedialibraryViewModel> : MediaBrowserFragmen
                 if ((item as? Genre)?.isFavorite == true) flags or CTX_FAV_REMOVE else flags or CTX_FAV_ADD
             }
             MediaLibraryItem.TYPE_PLAYLIST -> {
-                if (item.tracksCount > 2) CTX_PLAYLIST_ALBUM_FLAGS or CTX_PLAY_SHUFFLE else CTX_PLAYLIST_ALBUM_FLAGS
+                (if (item.tracksCount > 2) CTX_PLAYLIST_ALBUM_FLAGS or CTX_PLAY_SHUFFLE else CTX_PLAYLIST_ALBUM_FLAGS) or if(item.isFavorite) CTX_FAV_REMOVE else CTX_FAV_ADD
             }
             else -> CTX_AUDIO_FLAGS
         }



More information about the Android mailing list