[Android] Restore cache policy in cover fetching

Geoffrey Métais git at videolan.org
Fri Feb 24 16:32:07 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 24 16:30:02 2017 +0100| [177bec2a11bfbfb80869bfd51d2b79d00615a4c6] | committer: Geoffrey Métais

Restore cache policy in cover fetching

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

 vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java b/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java
index 8c54318..f03a320 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java
@@ -378,7 +378,13 @@ public class AudioUtil {
     }
 
     public static Bitmap readCoverBitmap(String path, int width) {
-        Bitmap cover = null;
+        if (path == null)
+            return null;
+        if (path.startsWith("file"))
+            path = path.substring(7);
+        Bitmap cover = BitmapCache.getInstance().getBitmapFromMemCache(path);
+        if (cover != null)
+            return cover;
         BitmapFactory.Options options = new BitmapFactory.Options();
 
         /* Get the resolution of the bitmap without allocating the memory */
@@ -397,6 +403,7 @@ public class AudioUtil {
 
             // Decode the file (with memory allocation this time)
             cover = BitmapFactory.decodeFile(path, options);
+            BitmapCache.getInstance().addBitmapToMemCache(path, cover);
         }
         return cover;
     }



More information about the Android mailing list