[Android] Add a TV playlist item to browse playlists
Nicolas Pomepuy
git at videolan.org
Mon Apr 11 13:14:00 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Apr 11 07:35:17 2022 +0200| [c2ded4409f613a6606555eaab446ce2a21a632fa] | committer: Duncan McNamara
Add a TV playlist item to browse playlists
Fixes #2472
> https://code.videolan.org/videolan/vlc-android/commit/c2ded4409f613a6606555eaab446ce2a21a632fa
---
.../resources/src/main/java/org/videolan/resources/Constants.kt | 1 +
.../org/videolan/television/ui/browser/MediaBrowserTvFragment.kt | 2 ++
.../org/videolan/television/ui/browser/VerticalGridActivity.kt | 2 ++
.../src/main/java/org/videolan/television/viewmodel/MainTvModel.kt | 2 +-
.../org/videolan/television/viewmodel/MediaBrowserViewModel.kt | 7 +++----
5 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/application/resources/src/main/java/org/videolan/resources/Constants.kt b/application/resources/src/main/java/org/videolan/resources/Constants.kt
index ba89a8aa0..ab92be76b 100644
--- a/application/resources/src/main/java/org/videolan/resources/Constants.kt
+++ b/application/resources/src/main/java/org/videolan/resources/Constants.kt
@@ -153,6 +153,7 @@ const val CATEGORY_ALBUMS = 22L
const val CATEGORY_GENRES = 23L
const val CATEGORY_SONGS = 24L
const val CATEGORY_VIDEOS = 25L
+const val CATEGORY_PLAYLISTS = 27L
const val CATEGORY_NOW_PLAYING_PIP = 26L
const val CATEGORY = "category"
diff --git a/application/television/src/main/java/org/videolan/television/ui/browser/MediaBrowserTvFragment.kt b/application/television/src/main/java/org/videolan/television/ui/browser/MediaBrowserTvFragment.kt
index 56eb4db8e..06404e2ce 100644
--- a/application/television/src/main/java/org/videolan/television/ui/browser/MediaBrowserTvFragment.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/browser/MediaBrowserTvFragment.kt
@@ -33,6 +33,7 @@ class MediaBrowserTvFragment : BaseBrowserTvFragment<MediaLibraryItem>() {
CATEGORY_ALBUMS -> MediaWrapper.TYPE_ALBUM
CATEGORY_ARTISTS -> MediaWrapper.TYPE_ARTIST
CATEGORY_GENRES -> MediaWrapper.TYPE_GENRE
+ CATEGORY_PLAYLISTS -> MediaWrapper.TYPE_PLAYLIST
else -> MediaWrapper.TYPE_VIDEO
}, this, itemSize)
}
@@ -46,6 +47,7 @@ class MediaBrowserTvFragment : BaseBrowserTvFragment<MediaLibraryItem>() {
CATEGORY_ALBUMS -> getString(R.string.albums)
CATEGORY_ARTISTS -> getString(R.string.artists)
CATEGORY_GENRES -> getString(R.string.genres)
+ CATEGORY_PLAYLISTS -> getString(R.string.playlists)
else -> getString(R.string.video)
}
diff --git a/application/television/src/main/java/org/videolan/television/ui/browser/VerticalGridActivity.kt b/application/television/src/main/java/org/videolan/television/ui/browser/VerticalGridActivity.kt
index 48f02088b..c7e9cc9ff 100644
--- a/application/television/src/main/java/org/videolan/television/ui/browser/VerticalGridActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/browser/VerticalGridActivity.kt
@@ -81,6 +81,8 @@ class VerticalGridActivity : BaseTvActivity(), BrowserActivityInterface {
fragment = MediaScrapingBrowserTvFragment.newInstance(type)
} else if (type == HEADER_DIRECTORIES) {
fragment = FileBrowserTvFragment.newInstance(TYPE_FILE, intent.data?.let { MLServiceLocator.getAbstractMediaWrapper(it) }, true)
+ } else if (type == HEADER_PLAYLISTS) {
+ fragment = MediaBrowserTvFragment.newInstance(CATEGORY_PLAYLISTS, null)
} else {
finish()
return
diff --git a/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt b/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt
index 038b69f18..9b765000b 100644
--- a/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt
+++ b/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt
@@ -204,7 +204,7 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
getPagedPlaylists(Medialibrary.SORT_INSERTIONDATE, true, true, NUM_ITEMS_PREVIEW, 0)
}.let {
(playlist as MutableLiveData).value = mutableListOf<MediaLibraryItem>().apply {
- // add(DummyItem(HEADER_PLAYLISTS, context.getString(R.string.playlists), ""))
+ add(DummyItem(HEADER_PLAYLISTS, context.getString(R.string.playlists), ""))
addAll(it)
}
}
diff --git a/application/television/src/main/java/org/videolan/television/viewmodel/MediaBrowserViewModel.kt b/application/television/src/main/java/org/videolan/television/viewmodel/MediaBrowserViewModel.kt
index 2ad44c66f..33249a2e5 100644
--- a/application/television/src/main/java/org/videolan/television/viewmodel/MediaBrowserViewModel.kt
+++ b/application/television/src/main/java/org/videolan/television/viewmodel/MediaBrowserViewModel.kt
@@ -6,11 +6,8 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.videolan.medialibrary.media.MediaLibraryItem
+import org.videolan.resources.*
import org.videolan.vlc.providers.medialibrary.*
-import org.videolan.resources.CATEGORY_ALBUMS
-import org.videolan.resources.CATEGORY_ARTISTS
-import org.videolan.resources.CATEGORY_GENRES
-import org.videolan.resources.CATEGORY_VIDEOS
import org.videolan.vlc.viewmodels.MedialibraryViewModel
import org.videolan.vlc.viewmodels.tv.TvBrowserModel
@@ -27,6 +24,7 @@ class MediaBrowserViewModel(context: Context, val category: Long, val parent : M
CATEGORY_ARTISTS -> ArtistsProvider(context, this, false)
CATEGORY_GENRES -> GenresProvider(context, this)
CATEGORY_VIDEOS -> VideosProvider(null, null, context, this)
+ CATEGORY_PLAYLISTS -> PlaylistsProvider(context, this)
else -> TracksProvider(null, context, this)
}
override val providers = arrayOf(provider)
@@ -36,6 +34,7 @@ class MediaBrowserViewModel(context: Context, val category: Long, val parent : M
CATEGORY_ALBUMS -> watchAlbums()
CATEGORY_ARTISTS -> watchArtists()
CATEGORY_GENRES -> watchGenres()
+ CATEGORY_PLAYLISTS -> watchPlaylists()
else -> watchMedia()
}
}
More information about the Android
mailing list