[Android] AudioUtil: extra check for existence

Jean-Baptiste Kempf git at videolan.org
Fri Oct 19 11:26:19 CEST 2012


vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Oct 19 11:10:47 2012 +0200| [9fbbb38807283cbeb6a482faa6bc9521dd6df3ad] | committer: Jean-Baptiste Kempf

AudioUtil: extra check for existence

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=9fbbb38807283cbeb6a482faa6bc9521dd6df3ad
---

 vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
index a3e65c0..de01be1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
@@ -174,8 +174,8 @@ public class AudioUtil {
             int hash = MurmurHash.hash32(media.getArtist()+media.getAlbum());
             cachePath = COVER_DIR + (hash >= 0 ? "" + hash : "m" + (-hash)) + "_" + width;
 
-            BitmapCache cache = BitmapCache.getInstance();
             // try to get the cover from the LRUCache first
+            BitmapCache cache = BitmapCache.getInstance();
             cover = cache.getBitmapFromMemCache(cachePath);
             if (cover != null)
                 return cover;
@@ -189,15 +189,18 @@ public class AudioUtil {
                     return null;
             }
 
-            if (coverPath == null)
+            // try to get it from VLC
+            if (coverPath == null || !cacheFile.exists())
                 coverPath = getCoverFromVlc(context, media);
 
             // no found yet, looking in folder
-            if (coverPath == null)
+            cacheFile = new File(coverPath);
+            if (coverPath == null || !cacheFile.exists())
                 coverPath = getCoverFromFolder(context, media);
 
             // try to get the cover from android MediaStore
-            if (coverPath == null)
+            cacheFile = new File(coverPath);
+            if (coverPath == null || !cacheFile.exists())
                 coverPath = getCoverFromMediaStore(context, media);
 
             // read (and scale?) the bitmap



More information about the Android mailing list