[Android] Open a playlist from home screen

Nicolas Pomepuy git at videolan.org
Wed Jun 5 10:31:20 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu May  9 13:14:46 2019 +0200| [fbea3a05afaca3b3301fb30e7a17ac37092031ef] | committer: Geoffrey Métais

Open a playlist from home screen

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

 vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt             |  4 ++++
 vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt | 10 +++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt b/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt
index 510fcf035..a07847133 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt
@@ -28,10 +28,12 @@ import android.graphics.Bitmap
 import android.graphics.drawable.BitmapDrawable
 import android.net.Uri
 import android.os.Build
+import android.provider.MediaStore.Video.VideoColumns.CATEGORY
 import android.text.TextUtils
 import android.view.View
 import androidx.annotation.RequiresApi
 import androidx.core.content.ContextCompat
+import androidx.core.content.ContextCompat.startActivity
 import androidx.fragment.app.FragmentActivity
 import androidx.leanback.app.BackgroundManager
 import androidx.leanback.widget.DiffCallback
@@ -56,6 +58,7 @@ import org.videolan.vlc.util.*
 import org.videolan.vlc.viewmodels.BaseModel
 import org.videolan.vlc.viewmodels.browser.BrowserModel
 
+import kotlin.collections.ArrayList
 @ExperimentalCoroutinesApi
 @ObsoleteCoroutinesApi
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@@ -292,6 +295,7 @@ object TvUtil {
     fun openAudioCategory(context: Activity, mediaLibraryItem: MediaLibraryItem) {
         when {
             mediaLibraryItem.itemType == MediaLibraryItem.TYPE_ALBUM -> playAudioList(context, mediaLibraryItem.tracks, 0)
+            mediaLibraryItem.itemType == MediaLibraryItem.TYPE_PLAYLIST -> playAudioList(context, mediaLibraryItem.tracks, 0)
             mediaLibraryItem.itemType == MediaLibraryItem.TYPE_MEDIA -> {
                 val list = ArrayList<MediaWrapper>().apply { add(mediaLibraryItem as MediaWrapper) }
                 playAudioList(context, list, 0)
diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt b/vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt
index c322bf56e..2de4d425a 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt
@@ -69,10 +69,10 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
     private set
     // LiveData
     private val favorites: LiveData<List<BrowserFav>> = browserFavRepository.browserFavorites
-    val videos : LiveData<List<MediaLibraryItem>> = MutableLiveData()
-    val audioCategories : LiveData<List<MediaLibraryItem>> = MutableLiveData()
-    val browsers : LiveData<List<MediaLibraryItem>> = MutableLiveData()
-    val history : LiveData<List<MediaWrapper>> = MutableLiveData()
+    val videos: LiveData<List<MediaLibraryItem>> = MutableLiveData()
+    val audioCategories: LiveData<List<MediaLibraryItem>> = MutableLiveData()
+    val browsers: LiveData<List<MediaLibraryItem>> = MutableLiveData()
+    val history: LiveData<List<MediaWrapper>> = MutableLiveData()
     val playlist: LiveData<List<MediaLibraryItem>> = MutableLiveData()
 
     private val nowPlayingDelegate = NowPlayingDelegate(this)
@@ -238,7 +238,7 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
         fun Fragment.getMainTvModel() = ViewModelProviders.of(requireActivity(), Factory(requireActivity().application)).get(MainTvModel::class.java)
     }
 
-    class Factory(private val app: Application): ViewModelProvider.NewInstanceFactory() {
+    class Factory(private val app: Application) : ViewModelProvider.NewInstanceFactory() {
         override fun <T : ViewModel> create(modelClass: Class<T>): T {
             @Suppress("UNCHECKED_CAST")
             return MainTvModel(app) as T



More information about the Android mailing list