OSDN Git Service

Eleven: Add playlist cover art to search results
authorLinus Lee <llee@cyngn.com>
Sat, 18 Apr 2015 00:30:21 +0000 (17:30 -0700)
committerLinus Lee <llee@cyngn.com>
Fri, 29 May 2015 22:04:11 +0000 (22:04 +0000)
Change-Id: I63f3b15cc9757b0daa945e4d8a3920c28673713d
(cherry picked from commit b84e90377248a0155019915529d45461c3403d44)

src/com/cyanogenmod/eleven/adapters/SummarySearchAdapter.java

index fa12c8f..6e61b96 100644 (file)
@@ -42,11 +42,6 @@ public final class SummarySearchAdapter extends ArrayAdapter<SearchResult>
         implements SectionAdapter.BasicAdapter, IPopupMenuCallback {
 
     /**
-     * no-image list item type and with image type
-     */
-    private static final int VIEW_TYPE_COUNT = 2;
-
-    /**
      * Image cache and image fetcher
      */
     private final ImageFetcher mImageFetcher;
@@ -89,7 +84,7 @@ public final class SummarySearchAdapter extends ArrayAdapter<SearchResult>
 
         if (convertView == null) {
             convertView = LayoutInflater.from(getContext()).inflate(
-                    getViewResourceId(position), parent, false);
+                    R.layout.list_item_normal, parent, false);
             holder = new MusicHolder(convertView);
             convertView.setTag(holder);
             // set the pop up menu listener
@@ -133,6 +128,10 @@ public final class SummarySearchAdapter extends ArrayAdapter<SearchResult>
                         MusicUtils.makeCombinedString(getContext(), item.mArtist, item.mAlbum));
                 break;
             case Playlist:
+                // Asynchronously load the playlist images into the adapter
+                ImageFetcher.getInstance(getContext()).loadPlaylistCoverArtImage(
+                        item.mId, holder.mImage.get());
+
                 setText(holder.mLineOne.get(), item.mTitle);
                 String songs = MusicUtils.makeLabel(getContext(), R.plurals.Nsongs, item.mSongCount);
                 holder.mLineTwo.get().setText(songs);
@@ -164,46 +163,6 @@ public final class SummarySearchAdapter extends ArrayAdapter<SearchResult>
     }
 
     /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int getViewTypeCount() {
-        return VIEW_TYPE_COUNT;
-    }
-
-    /**
-     * This categorizes the view types we want for each item type
-     * @param position of the item
-     * @return categorization
-     */
-    @Override
-    public int getItemViewType(int position) {
-        switch (getItem(position).mType) {
-            case Artist:
-            case Album:
-            case Song:
-                return 0;
-            default:
-            case Playlist:
-                return 1;
-        }
-    }
-
-    /**
-     * this returns the layout needed for the item
-     * @param position of the item
-     * @return layout id
-     */
-    public int getViewResourceId(int position) {
-        switch (getItemViewType(position)) {
-            case 0:
-                return R.layout.list_item_normal;
-            default:
-                return R.layout.list_item_simple;
-        }
-    }
-
-    /**
      * @param pause True to temporarily pause the disk cache, false
      *            otherwise.
      */