[Android] Find first available cover for artists

Geoffrey Métais git at videolan.org
Mon Mar 9 17:29:27 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Mar  9 17:29:03 2015 +0100| [882bd2d70ec5e89e939c4fddee3097b9d73bc13a] | committer: Geoffrey Métais

Find first available cover for artists

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

 .../videolan/vlc/gui/audio/AudioBrowserListAdapter.java   |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 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 f4f1f25..be1703b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -305,8 +305,17 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
 
         RelativeLayout.LayoutParams paramsCover;
         if (mItemType == ITEM_WITH_COVER) {
-            MediaWrapper media = mItems.get(position).mMediaList.get(0);
-            Bitmap cover = AudioUtil.getCover(v.getContext(), media, 64);
+            Bitmap cover = null;
+            LinkedList<String> testedAlbums = new LinkedList<String>();
+            for (MediaWrapper media : mItems.get(position).mMediaList) {
+                if (media.getAlbum() != null && testedAlbums.contains(media.getAlbum()))
+                    continue;
+                cover = AudioUtil.getCover(v.getContext(), media, 64);
+                if (cover != null)
+                    break;
+                else if (media.getAlbum() != null)
+                    testedAlbums.add(media.getAlbum());
+            }
             if (cover == null)
                 cover = BitmapCache.GetFromResource(v, R.drawable.icon);
             holder.cover.setImageBitmap(cover);



More information about the Android mailing list