[Android] Fix video group thumbnail not loading
Nicolas Pomepuy
git at videolan.org
Thu Dec 19 13:32:21 CET 2019
vlc-android | branch: 3.2.x | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Dec 19 10:23:46 2019 +0000| [e086c43f4ee786c42046e5ba03cfa927e3caf121] | committer: Geoffrey Métais
Fix video group thumbnail not loading
Fixes #1134
(cherry picked from commit ea2b127eeb8db3c9e7e4cd599ee3cfef6ed772ee)
> https://code.videolan.org/videolan/vlc-android/commit/e086c43f4ee786c42046e5ba03cfa927e3caf121
---
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