[Android] Fix the browser thumbnails when file is not indexed by the ML

Nicolas Pomepuy git at videolan.org
Thu Feb 3 07:46:15 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Feb  2 09:20:47 2022 +0100| [5dce5a9605b32fa46f878d4ae007f4a410d5a5fa] | committer: Nicolas Pomepuy

Fix the browser thumbnails when file is not indexed by the ML

Fixes #2358

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

 .../vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt        | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt b/application/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
index c585436fb..f8c89e042 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
@@ -66,6 +66,7 @@ object ThumbnailsProvider {
 
     private fun getMediaThumbnailPath(isMedia: Boolean, item: MediaLibraryItem): String? {
         if (isMedia && isMediaVideo(item as MediaWrapper)) {
+            if (item.id == 0L) return item.uri.toString()
             if (appDir == null) appDir = AppContextProvider.appContext.getExternalFilesDir(null)
             val hasCache = appDir != null && appDir!!.exists()
             if (hasCache && cacheDir == null) cacheDir = appDir!!.absolutePath + MEDIALIB_FOLDER_NAME
@@ -82,7 +83,7 @@ object ThumbnailsProvider {
         if (appDir == null) appDir = AppContextProvider.appContext.getExternalFilesDir(null)
         val hasCache = appDir?.exists() == true
         val thumbPath = getMediaThumbnailPath(true, media) ?: return null
-        val cacheBM = if (hasCache) BitmapCache.getBitmapFromMemCache(getMediaCacheKey(true, media)) else null
+        val cacheBM = if (hasCache) BitmapCache.getBitmapFromMemCache(getMediaCacheKey(true, media, width.toString())) 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