Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b84e9037 authored by Linus Lee's avatar Linus Lee
Browse files

Eleven: Add playlist cover art to search results

Change-Id: I63f3b15cc9757b0daa945e4d8a3920c28673713d
parent 92ad21c7
Loading
Loading
Loading
Loading
+5 −46
Original line number Diff line number Diff line
@@ -41,11 +41,6 @@ import java.util.Locale;
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
     */
@@ -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);
@@ -163,46 +162,6 @@ public final class SummarySearchAdapter extends ArrayAdapter<SearchResult>
        return true;
    }

    /**
     * {@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.