Skip to content
Snippets Groups Projects
Commit c8b1f083 authored by Marc K's avatar Marc K Committed by Geoffrey Métais
Browse files

Use the icon cache as additional source for cover art


This fixes showing the cover art of network media if it was previously
shown as icon in the browser.

Signed-off-by: default avatarMarc K <morckx@gmail.com>
parent 6942c099
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.media.RingtoneManager;
import android.net.Uri;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
......@@ -42,6 +43,7 @@ import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.HttpImageLoader;
import org.videolan.vlc.util.MurmurHash;
import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.Util;
......@@ -283,11 +285,16 @@ public class AudioUtil {
}
public static Bitmap getCoverFromMemCache(Context context, MediaWrapper media, int width) {
Bitmap cover = null;
if (media != null && media.getArtist() != null && media.getAlbum() != null) {
final BitmapCache cache = BitmapCache.getInstance();
return cache.getBitmapFromMemCache(getCoverCachePath(context, media, width));
} else
return null;
cover = cache.getBitmapFromMemCache(getCoverCachePath(context, media, width));
}
if (cover == null && media != null && !TextUtils.isEmpty(media.getArtworkURL()) && media.getArtworkURL().startsWith("http")) {
cover = HttpImageLoader.getBitmapFromIconCache(media.getArtworkURL());
}
return cover;
}
@SuppressLint("NewApi")
......@@ -322,10 +329,8 @@ public class AudioUtil {
if (cacheFile.exists()) {
if (cacheFile.length() > 0)
coverPath = cachePath;
else
return null;
}
}
} else
// try to get it from VLC
if (coverPath == null || !cacheFile.exists())
......
......@@ -95,7 +95,7 @@ public class HttpImageLoader implements Callbacks {
}
@Nullable
public static Bitmap downloadBitmap(String imageUrl) {
public static Bitmap getBitmapFromIconCache(String imageUrl) {
if (iconsMap.containsKey(imageUrl)) {
Bitmap bd = iconsMap.get(imageUrl).get();
if (bd != null) {
......@@ -103,8 +103,15 @@ public class HttpImageLoader implements Callbacks {
} else
iconsMap.remove(imageUrl);
}
return null;
}
@Nullable
public static Bitmap downloadBitmap(String imageUrl) {
HttpURLConnection urlConnection = null;
Bitmap icon = null;
Bitmap icon = getBitmapFromIconCache(imageUrl);
if (icon != null)
return icon;
try {
URL url = new URL(imageUrl);
if (url.getPort() <= 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment