Search in sources :

Example 6 with MusicViewHolder

use of com.andrew.apollo.ui.MusicViewHolder in project frostwire by frostwire.

the class SongAdapter method getView.

/**
 * {@inheritDoc}
 */
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
    convertView = prepareMusicViewHolder(mLayoutId, getContext(), convertView, parent);
    final MusicViewHolder musicViewHolder = (MusicViewHolder) convertView.getTag();
    final DataHolder dataHolder = mData[position];
    updateFirstTwoArtistLines(musicViewHolder, dataHolder);
    if (mImageFetcher == null) {
        Log.w("warning", "ArtistAdapter has null image fetcher");
    }
    if (mImageFetcher != null && dataHolder != null && Ref.alive(musicViewHolder.mImage)) {
        if (dataHolder.mParentId == -1) {
            mImageFetcher.loadAlbumImage(dataHolder.mLineTwo, dataHolder.mLineOne, R.drawable.list_item_audio_icon, musicViewHolder.mImage.get());
            async(getContext(), SongAdapter::updateDataHolderAlbumId, dataHolder, musicViewHolder, mImageFetcher, SongAdapter::updateAlbumImage);
        } else {
            mImageFetcher.loadAlbumImage(dataHolder.mLineTwo, dataHolder.mLineOne, dataHolder.mParentId, musicViewHolder.mImage.get());
        }
    }
    if (musicViewHolder != null) {
        if (Ref.alive(musicViewHolder.mLineThree)) {
            musicViewHolder.mLineThree.get().setVisibility(View.GONE);
        }
        if (dataHolder != null) {
            // Set each song name (line one)
            if (Ref.alive(musicViewHolder.mLineOne)) {
                musicViewHolder.mLineOne.get().setText(dataHolder.mLineOne);
            }
            // Set the song duration (line one, right)
            if (Ref.alive(musicViewHolder.mLineOneRight)) {
                musicViewHolder.mLineOneRight.get().setText(dataHolder.mLineOneRight);
            }
            // Set the artist name (line two)
            if (Ref.alive(musicViewHolder.mLineTwo)) {
                musicViewHolder.mLineTwo.get().setText(dataHolder.mLineTwo);
            }
            if (MusicUtils.getCurrentAudioId() == dataHolder.mItemId) {
                musicViewHolder.mLineOne.get().setTextColor(getContext().getResources().getColor(com.frostwire.android.R.color.app_text_highlight));
                musicViewHolder.mLineOneRight.get().setTextColor(getContext().getResources().getColor(com.frostwire.android.R.color.app_text_highlight));
                musicViewHolder.mLineTwo.get().setTextColor(getContext().getResources().getColor(com.frostwire.android.R.color.app_text_highlight));
            } else {
                musicViewHolder.mLineOne.get().setTextColor(getContext().getResources().getColor(com.frostwire.android.R.color.app_text_primary));
                musicViewHolder.mLineOneRight.get().setTextColor(getContext().getResources().getColor(com.frostwire.android.R.color.app_text_primary));
                musicViewHolder.mLineTwo.get().setTextColor(getContext().getResources().getColor(com.frostwire.android.R.color.app_text_primary));
            }
        }
    }
    return convertView;
}
Also used : DataHolder(com.andrew.apollo.ui.MusicViewHolder.DataHolder) MusicViewHolder(com.andrew.apollo.ui.MusicViewHolder)

Aggregations

MusicViewHolder (com.andrew.apollo.ui.MusicViewHolder)6 DataHolder (com.andrew.apollo.ui.MusicViewHolder.DataHolder)3 Album (com.andrew.apollo.model.Album)1 Song (com.andrew.apollo.model.Song)1