[Android] Fix video group thumbnail not loading

Nicolas Pomepuy git at videolan.org
Thu Dec 19 13:08:18 CET 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Dec 19 11:23:46 2019 +0100| [ea2b127eeb8db3c9e7e4cd599ee3cfef6ed772ee] | committer: Geoffrey Métais

Fix video group thumbnail not loading

Fixes #1134

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

 vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt b/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
index 4b5e74a97..fa6340d30 100644
--- a/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
@@ -61,23 +61,25 @@ object ThumbnailsProvider {
             readCoverBitmap(Uri.decode(item.artworkMrl), width)
     }
 
-    fun getMediaCacheKey(isMedia: Boolean, item: MediaLibraryItem, width: String = ""): String? {
+    private fun getMediaThumbnailPath(isMedia: Boolean, item: MediaLibraryItem): String? {
         if (isMedia && (item as AbstractMediaWrapper).type == AbstractMediaWrapper.TYPE_VIDEO && TextUtils.isEmpty(item.getArtworkMrl())) {
             if (appDir == null) appDir = VLCApplication.appContext.getExternalFilesDir(null)
             val hasCache = appDir != null && appDir!!.exists()
             if (hasCache && cacheDir == null) cacheDir = appDir!!.absolutePath + MEDIALIB_FOLDER_NAME
             return if (hasCache) StringBuilder(cacheDir!!).append('/').append(item.fileName).append(".jpg").toString() else null
         }
-        return "${item.artworkMrl}_$width"
+        return item.artworkMrl
     }
 
+    fun getMediaCacheKey(isMedia: Boolean, item: MediaLibraryItem, width: String = "") = if (width.isEmpty()) getMediaThumbnailPath(isMedia, item) else "${getMediaThumbnailPath(isMedia, item)}_$width"
+
     @WorkerThread
     fun getVideoThumbnail(media: AbstractMediaWrapper, width: Int): Bitmap? {
         val filePath = media.uri.path ?: return null
         if (appDir == null) appDir = VLCApplication.appContext.getExternalFilesDir(null)
         val hasCache = appDir?.exists() == true
-        val thumbPath = getMediaCacheKey(true, media) ?: return null
-        val cacheBM = if (hasCache) BitmapCache.getBitmapFromMemCache(thumbPath) else null
+        val thumbPath = getMediaThumbnailPath(true, media) ?: return null
+        val cacheBM = if (hasCache) BitmapCache.getBitmapFromMemCache(getMediaCacheKey(true, media)) else null
         if (cacheBM != null) return cacheBM
         if (hasCache && File(thumbPath).exists()) return readCoverBitmap(thumbPath, width)
         if (media.isThumbnailGenerated) return null



More information about the Android mailing list