[Android] Fix TV provider content ID
Geoffrey Métais
git at videolan.org
Tue Mar 3 11:03:18 CET 2020
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar 3 09:42:04 2020 +0100| [b44559b0c8b52dbe6825e1949dc5e6cda6be5e0f] | committer: Geoffrey Métais
Fix TV provider content ID
> https://code.videolan.org/videolan/vlc-android/commit/b44559b0c8b52dbe6825e1949dc5e6cda6be5e0f
---
.../org/videolan/moviepedia/provider/MediaScrapingTvshowProvider.kt | 6 ++++--
.../resources/src/main/java/org/videolan/resources/Constants.kt | 2 ++
.../src/main/java/org/videolan/television/util/TVSearchProvider.kt | 6 ++++--
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/application/moviepedia/src/main/java/org/videolan/moviepedia/provider/MediaScrapingTvshowProvider.kt b/application/moviepedia/src/main/java/org/videolan/moviepedia/provider/MediaScrapingTvshowProvider.kt
index a3b2bbf65..8038d14e6 100644
--- a/application/moviepedia/src/main/java/org/videolan/moviepedia/provider/MediaScrapingTvshowProvider.kt
+++ b/application/moviepedia/src/main/java/org/videolan/moviepedia/provider/MediaScrapingTvshowProvider.kt
@@ -32,7 +32,9 @@ import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.moviepedia.database.models.MediaMetadataWithImages
import org.videolan.moviepedia.repository.MediaMetadataRepository
import org.videolan.moviepedia.viewmodel.Season
+import org.videolan.resources.CONTENT_EPISODE
import org.videolan.resources.CONTENT_PREFIX
+import org.videolan.resources.CONTENT_RESUME
import org.videolan.resources.interfaces.IMediaContentResolver
import org.videolan.resources.util.getFromMl
@@ -168,14 +170,14 @@ class MediaScrapingTvshowProvider(private val context: Context) {
companion object {
fun getProviders() : List<IMediaContentResolver> = mutableListOf<IMediaContentResolver>().apply {
add(object : IMediaContentResolver {
- override val prefix = "${CONTENT_PREFIX}resume_"
+ override val prefix = CONTENT_RESUME
override suspend fun getList(context: Context, id: String): Pair<List<MediaWrapper>, Int>? {
val provider = MediaScrapingTvshowProvider(context)
return withContext(Dispatchers.IO) { Pair(provider.getResumeMediasById(id.substringAfter(prefix)), 0) }
}
})
add(object : IMediaContentResolver {
- override val prefix = "${CONTENT_PREFIX}episode_"
+ override val prefix = CONTENT_EPISODE
override suspend fun getList(context: Context, id: String): Pair<List<MediaWrapper>, Int>? {
val provider = MediaScrapingTvshowProvider(context)
val moviepediaId = id.substringAfter(prefix)
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 851e44b20..978729147 100644
--- a/application/resources/src/main/java/org/videolan/resources/Constants.kt
+++ b/application/resources/src/main/java/org/videolan/resources/Constants.kt
@@ -199,6 +199,8 @@ const val ACTION_VIEW_ARC = "org.chromium.arc.intent.action.VIEW"
const val ACTION_SEARCH_GMS = "com.google.android.gms.actions.SEARCH_ACTION"
const val CONTENT_PREFIX = "content_"
+const val CONTENT_RESUME = "${CONTENT_PREFIX}resume_"
+const val CONTENT_EPISODE = "${CONTENT_PREFIX}episode_"
const val ACTION_OPEN_CONTENT = "action_open_content"
const val EXTRA_CONTENT_ID = "extra_content_id"
diff --git a/application/television/src/main/java/org/videolan/television/util/TVSearchProvider.kt b/application/television/src/main/java/org/videolan/television/util/TVSearchProvider.kt
index 9da09fd33..62e0d9ffc 100644
--- a/application/television/src/main/java/org/videolan/television/util/TVSearchProvider.kt
+++ b/application/television/src/main/java/org/videolan/television/util/TVSearchProvider.kt
@@ -39,6 +39,8 @@ import org.videolan.moviepedia.database.models.getYear
import org.videolan.moviepedia.database.models.subtitle
import org.videolan.moviepedia.database.models.tvEpisodeSubtitle
import org.videolan.moviepedia.repository.MediaMetadataRepository
+import org.videolan.resources.CONTENT_EPISODE
+import org.videolan.resources.CONTENT_RESUME
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
import org.videolan.vlc.getFileUri
@@ -81,7 +83,7 @@ class TVSearchProvider : ContentProvider() {
provider.getFirstResumableEpisode(medialibrary, mediaMetadataEpisodes)?.let { firstResumableEpisode ->
val media = medialibrary.getMedia(firstResumableEpisode.metadata.mlId!!)
val thumbnail = mediaMetadataWithImages.metadata.currentBackdrop
- matrixCursor.addRow(arrayOf(media.id, "resume_${mediaMetadataWithImages.metadata.moviepediaId}", mediaMetadataWithImages.metadata.title, context.getString(R.string.resume_episode, firstResumableEpisode.tvEpisodeSubtitle()), thumbnail, firstResumableEpisode.metadata.getYear(), media.length))
+ matrixCursor.addRow(arrayOf(media.id, "${CONTENT_RESUME}${mediaMetadataWithImages.metadata.moviepediaId}", mediaMetadataWithImages.metadata.title, context.getString(R.string.resume_episode, firstResumableEpisode.tvEpisodeSubtitle()), thumbnail, firstResumableEpisode.metadata.getYear(), media.length))
}
@@ -92,7 +94,7 @@ class TVSearchProvider : ContentProvider() {
mlIds.add(mlId)
val media = medialibrary.getMedia(mlId)
val thumbnail = mediaMetadataWithImages.metadata.currentBackdrop
- matrixCursor.addRow(arrayOf(media.id, "episode_${mediaMetadataWithImages.metadata.moviepediaId}", mediaMetadataWithImages.metadata.title, mediaMetadataWithImages.subtitle(), thumbnail, mediaMetadataWithImages.metadata.getYear(), media.length))
+ matrixCursor.addRow(arrayOf(media.id, "${CONTENT_EPISODE}${mediaMetadataWithImages.metadata.moviepediaId}", mediaMetadataWithImages.metadata.title, mediaMetadataWithImages.subtitle(), thumbnail, mediaMetadataWithImages.metadata.getYear(), media.length))
}
}
}
More information about the Android
mailing list