[Android] Set correct cache key for MediaGroup

Geoffrey Métais git at videolan.org
Wed Jun 28 11:38:00 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jun 28 11:34:38 2017 +0200| [3d6c33d5b3488b69eb1a25df8de44c5642710e07] | committer: Geoffrey Métais

Set correct cache key for MediaGroup

Fix group composed thumbnail replaced by simple thumb on rotation

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

 .../org/videolan/vlc/gui/helpers/AsyncImageLoader.java   | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java b/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
index 875f0010b..ecdb5dd6c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
@@ -86,20 +86,22 @@ public class AsyncImageLoader {
                 || item.getItemType() == MediaLibraryItem.TYPE_GENRE
                 || item.getItemType() == MediaLibraryItem.TYPE_PLAYLIST)
             return;
-        final Bitmap bitmap = BitmapCache.getInstance().getBitmapFromMemCache(item.getArtworkMrl());
+        final boolean isMedia = item.getItemType() == MediaLibraryItem.TYPE_MEDIA;
+        final boolean isGroup = isMedia && ((MediaWrapper)item).getType() == MediaWrapper.TYPE_GROUP;
+        final String cacheKey = isGroup ? "group:"+item.getTitle() : item.getArtworkMrl();
+        final Bitmap bitmap = BitmapCache.getInstance().getBitmapFromMemCache(cacheKey);
         if (bitmap != null) {
             updateTargetImage(bitmap, v, DataBindingUtil.findBinding(v));
             return;
         }
-        if (item.getItemType() == MediaLibraryItem.TYPE_MEDIA && ((MediaWrapper)item).getType() != MediaWrapper.TYPE_GROUP) {
+        if (isMedia && !isGroup && item.getId() == 0L) {
             MediaWrapper mw = (MediaWrapper) item;
-            int type = mw.getType();
-            boolean isMedia = type == MediaWrapper.TYPE_AUDIO || type == MediaWrapper.TYPE_VIDEO;
+            final int type = mw.getType();
+            final boolean isMediaFile = type == MediaWrapper.TYPE_AUDIO || type == MediaWrapper.TYPE_VIDEO;
             Uri uri = mw.getUri();
-            if (!isMedia && !(type == MediaWrapper.TYPE_DIR && "upnp".equals(uri.getScheme())))
+            if (!isMediaFile && !(type == MediaWrapper.TYPE_DIR && "upnp".equals(uri.getScheme())))
                 return;
-            item = mw;
-            if (item.getId() == 0L && (isMedia) && "file".equals(uri.getScheme())) {
+            if (isMediaFile && "file".equals(uri.getScheme())) {
                 mw = VLCApplication.getMLInstance().getMedia(uri);
                 if (mw != null)
                     item = mw;



More information about the Android mailing list