[Android] AudioBrowserList: try to get cover from memcache before doing it asynchronously

Thomas Guillem git at videolan.org
Tue Oct 6 18:32:35 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Oct  6 17:53:52 2015 +0200| [98d4bd595b4d1de8bca2e2aafe722eae19d8ec61] | committer: Thomas Guillem

AudioBrowserList: try to get cover from memcache before doing it asynchronously

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

 .../vlc/gui/audio/AudioBrowserListAdapter.java       |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
index a9aee41..1c538a2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -26,6 +26,8 @@ import android.content.SharedPreferences;
 import android.database.DataSetObserver;
 import android.databinding.DataBindingUtil;
 import android.databinding.ViewDataBinding;
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
 import android.preference.PreferenceManager;
 import android.support.v4.util.ArrayMap;
 import android.util.SparseArray;
@@ -40,6 +42,7 @@ import android.widget.TextView;
 import org.videolan.vlc.BR;
 import org.videolan.vlc.MediaWrapper;
 import org.videolan.vlc.R;
+import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.AsyncImageLoader;
 import org.videolan.vlc.interfaces.IAudioClickHandler;
 import org.videolan.vlc.util.Util;
@@ -328,11 +331,18 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
         holder.binding.setVariable(BR.item, item);
 
         if (mItemType == ITEM_WITH_COVER) {
-            AudioUtil.AudioCoverFetcher fetcher = new AudioUtil.AudioCoverFetcher(mContext, mItems.get(position).mMediaList);
-            AsyncImageLoader.LoadAudioCover(fetcher, holder.binding, mContext);
-        }
+            final ArrayList<MediaWrapper> mediaList = mItems.get(position).mMediaList;
+            Bitmap bitmap = AudioUtil.getCoverFromMemCache(mContext, mediaList, 64);
+            if (bitmap != null)
+                holder.binding.setVariable(BR.cover, new BitmapDrawable(VLCApplication.getAppResources(), bitmap));
+            else {
+                holder.binding.setVariable(BR.cover, AudioUtil.DEFAULT_COVER);
+                AudioUtil.AudioCoverFetcher fetcher = new AudioUtil.AudioCoverFetcher(mContext, mediaList);
+                AsyncImageLoader.LoadAudioCover(fetcher, holder.binding, mContext);
+            }
+        } else
+            holder.binding.setVariable(BR.cover, AudioUtil.DEFAULT_COVER);
 
-        holder.binding.setVariable(BR.cover, AudioUtil.DEFAULT_COVER);
         holder.binding.setVariable(BR.footer, !isMediaItemAboveASeparator(position));
         holder.binding.setVariable(BR.clickable, mContextPopupMenuListener != null);
         holder.binding.setVariable(BR.handler, this);



More information about the Android mailing list