[Android] Fix same name directories having the same thumb

Geoffrey Métais git at videolan.org
Mon Apr 20 07:59:23 CEST 2020


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Apr 17 12:30:01 2020 +0200| [3d7c425d940661fdb4a23897b0ba12eee896451f] | committer: Nicolas Pomepuy

Fix same name directories having the same thumb

Fix #925

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

 .../vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt       | 4 +++-
 .../vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt       | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
index 64fb04268..f388808d0 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
@@ -25,6 +25,7 @@ import androidx.leanback.widget.ImageCardView
 import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
 import kotlinx.coroutines.*
 import org.videolan.medialibrary.interfaces.Medialibrary
+import org.videolan.medialibrary.interfaces.media.Folder
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.resources.AppContextProvider
@@ -33,6 +34,7 @@ import org.videolan.resources.HEADER_TV_SHOW
 import org.videolan.tools.BitmapCache
 import org.videolan.tools.HttpImageLoader
 import org.videolan.tools.Settings
+import org.videolan.tools.sanitizePath
 import org.videolan.vlc.BR
 import org.videolan.vlc.R
 import org.videolan.vlc.util.ThumbnailsProvider
@@ -72,7 +74,7 @@ fun loadImage(v: View, item: MediaLibraryItem?, imageWidth: Int = 0, tv: Boolean
     val isFolder = !isMedia && item.itemType == MediaLibraryItem.TYPE_FOLDER
     val cacheKey = when {
         isGroup -> "videogroup:${item.title}"
-        isFolder -> "folder:${item.title}"
+        isFolder -> "folder:${(item as Folder).mMrl.sanitizePath()}"
         else -> ThumbnailsProvider.getMediaCacheKey(isMedia, item, imageWidth.toString())
     }
     val bitmap = if (cacheKey !== null) BitmapCache.getBitmapFromMemCache(cacheKey) else null
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 cb6faa9da..40e5449c3 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
@@ -22,6 +22,7 @@ import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.resources.AppContextProvider
 import org.videolan.tools.BitmapCache
 import org.videolan.tools.CloseableUtils
+import org.videolan.tools.sanitizePath
 import org.videolan.vlc.gui.helpers.AudioUtil.readCoverBitmap
 import org.videolan.vlc.gui.helpers.BitmapUtil
 import org.videolan.vlc.gui.helpers.UiTools
@@ -45,7 +46,7 @@ object ThumbnailsProvider {
     @WorkerThread
     fun getFolderThumbnail(folder: Folder, width: Int): Bitmap? {
         val media = folder.media(Folder.TYPE_FOLDER_VIDEO, Medialibrary.SORT_DEFAULT, true, 4, 0).filterNotNull()
-        return getComposedImage("folder:${folder.title}", media, width)
+        return getComposedImage("folder:${folder.mMrl.sanitizePath()}", media, width)
     }
 
     @WorkerThread



More information about the Android mailing list