<div dir="ltr">LGTM<br><br><div class="gmail_quote"><div dir="ltr">On Sun, Nov 27, 2016 at 9:06 PM Marc K <<a href="mailto:morckx@gmail.com">morckx@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This fixes showing the cover art of network media if it was previously<br class="gmail_msg">
shown as icon in the browser.<br class="gmail_msg">
<br class="gmail_msg">
Signed-off-by: Marc K <<a href="mailto:morckx@gmail.com" class="gmail_msg" target="_blank">morckx@gmail.com</a>><br class="gmail_msg">
---<br class="gmail_msg">
.../src/org/videolan/vlc/gui/helpers/AudioUtil.java | 17 +++++++++++------<br class="gmail_msg">
.../src/org/videolan/vlc/util/HttpImageLoader.java | 11 +++++++++--<br class="gmail_msg">
2 files changed, 20 insertions(+), 8 deletions(-)<br class="gmail_msg">
<br class="gmail_msg">
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java b/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java<br class="gmail_msg">
index 846f996..82ad0dd 100644<br class="gmail_msg">
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java<br class="gmail_msg">
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java<br class="gmail_msg">
@@ -32,6 +32,7 @@ import android.graphics.drawable.BitmapDrawable;<br class="gmail_msg">
import android.media.RingtoneManager;<br class="gmail_msg">
import android.net.Uri;<br class="gmail_msg">
import android.provider.MediaStore;<br class="gmail_msg">
+import android.text.TextUtils;<br class="gmail_msg">
import android.util.Log;<br class="gmail_msg">
import android.widget.Toast;<br class="gmail_msg">
<br class="gmail_msg">
@@ -42,6 +43,7 @@ import org.videolan.vlc.R;<br class="gmail_msg">
import org.videolan.vlc.VLCApplication;<br class="gmail_msg">
import org.videolan.vlc.media.MediaUtils;<br class="gmail_msg">
import org.videolan.vlc.util.AndroidDevices;<br class="gmail_msg">
+import org.videolan.vlc.util.HttpImageLoader;<br class="gmail_msg">
import org.videolan.vlc.util.MurmurHash;<br class="gmail_msg">
import org.videolan.vlc.util.Permissions;<br class="gmail_msg">
import org.videolan.vlc.util.Util;<br class="gmail_msg">
@@ -283,11 +285,16 @@ public class AudioUtil {<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
public static Bitmap getCoverFromMemCache(Context context, MediaWrapper media, int width) {<br class="gmail_msg">
+ Bitmap cover = null;<br class="gmail_msg">
+<br class="gmail_msg">
if (media != null && media.getArtist() != null && media.getAlbum() != null) {<br class="gmail_msg">
final BitmapCache cache = BitmapCache.getInstance();<br class="gmail_msg">
- return cache.getBitmapFromMemCache(getCoverCachePath(context, media, width));<br class="gmail_msg">
- } else<br class="gmail_msg">
- return null;<br class="gmail_msg">
+ cover = cache.getBitmapFromMemCache(getCoverCachePath(context, media, width));<br class="gmail_msg">
+ }<br class="gmail_msg">
+ if (cover == null && media != null && !TextUtils.isEmpty(media.getArtworkURL()) && media.getArtworkURL().startsWith("http")) {<br class="gmail_msg">
+ cover = HttpImageLoader.getBitmapFromIconCache(media.getArtworkURL());<br class="gmail_msg">
+ }<br class="gmail_msg">
+ return cover;<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
@SuppressLint("NewApi")<br class="gmail_msg">
@@ -322,10 +329,8 @@ public class AudioUtil {<br class="gmail_msg">
if (cacheFile.exists()) {<br class="gmail_msg">
if (cacheFile.length() > 0)<br class="gmail_msg">
coverPath = cachePath;<br class="gmail_msg">
- else<br class="gmail_msg">
- return null;<br class="gmail_msg">
}<br class="gmail_msg">
- }<br class="gmail_msg">
+ } else<br class="gmail_msg">
<br class="gmail_msg">
// try to get it from VLC<br class="gmail_msg">
if (coverPath == null || !cacheFile.exists())<br class="gmail_msg">
diff --git a/vlc-android/src/org/videolan/vlc/util/HttpImageLoader.java b/vlc-android/src/org/videolan/vlc/util/HttpImageLoader.java<br class="gmail_msg">
index a0cf59e..8810408 100644<br class="gmail_msg">
--- a/vlc-android/src/org/videolan/vlc/util/HttpImageLoader.java<br class="gmail_msg">
+++ b/vlc-android/src/org/videolan/vlc/util/HttpImageLoader.java<br class="gmail_msg">
@@ -95,7 +95,7 @@ public class HttpImageLoader implements Callbacks {<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
@Nullable<br class="gmail_msg">
- public static Bitmap downloadBitmap(String imageUrl) {<br class="gmail_msg">
+ public static Bitmap getBitmapFromIconCache(String imageUrl) {<br class="gmail_msg">
if (iconsMap.containsKey(imageUrl)) {<br class="gmail_msg">
Bitmap bd = iconsMap.get(imageUrl).get();<br class="gmail_msg">
if (bd != null) {<br class="gmail_msg">
@@ -103,8 +103,15 @@ public class HttpImageLoader implements Callbacks {<br class="gmail_msg">
} else<br class="gmail_msg">
iconsMap.remove(imageUrl);<br class="gmail_msg">
}<br class="gmail_msg">
+ return null;<br class="gmail_msg">
+ }<br class="gmail_msg">
+<br class="gmail_msg">
+ @Nullable<br class="gmail_msg">
+ public static Bitmap downloadBitmap(String imageUrl) {<br class="gmail_msg">
HttpURLConnection urlConnection = null;<br class="gmail_msg">
- Bitmap icon = null;<br class="gmail_msg">
+ Bitmap icon = getBitmapFromIconCache(imageUrl);<br class="gmail_msg">
+ if (icon != null)<br class="gmail_msg">
+ return icon;<br class="gmail_msg">
try {<br class="gmail_msg">
URL url = new URL(imageUrl);<br class="gmail_msg">
if (url.getPort() <= 0)<br class="gmail_msg">
--<br class="gmail_msg">
2.9.3<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
Android mailing list<br class="gmail_msg">
<a href="mailto:Android@videolan.org" class="gmail_msg" target="_blank">Android@videolan.org</a><br class="gmail_msg">
<a href="https://mailman.videolan.org/listinfo/android" rel="noreferrer" class="gmail_msg" target="_blank">https://mailman.videolan.org/listinfo/android</a><br class="gmail_msg">
</blockquote></div></div>