Search in sources :

Example 1 with MusicViewHolder

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

the class ArtistAdapter method getView.

/**
 * {@inheritDoc}
 */
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
    convertView = prepareMusicViewHolder(mLayoutId, getContext(), convertView, parent);
    MusicViewHolder holder = (MusicViewHolder) convertView.getTag();
    final DataHolder dataHolder = mData[position];
    updateFirstTwoArtistLines(holder, dataHolder);
    if (mImageFetcher != null && dataHolder != null && Ref.alive(holder.mImage)) {
        // Asynchronously load the artist image into the adapter
        mImageFetcher.loadArtistImage(dataHolder.mLineOne, holder.mImage.get());
    }
    if (mLoadExtraData && mImageFetcher != null && holder != null) {
        if (Ref.alive(holder.mOverlay)) {
            // Make sure the background layer gets set
            holder.mOverlay.get().setBackgroundColor(mOverlayColor);
        }
        if (Ref.alive(holder.mLineThree)) {
            // Set the number of songs (line three)
            holder.mLineThree.get().setText(dataHolder.mLineThree);
        }
        if (Ref.alive(holder.mBackground)) {
            if (mLayoutId == R.layout.list_item_detailed_no_background) {
                holder.mBackground.get().setBackground(null);
                holder.mBackground.get().setBackgroundColor(convertView.getResources().getColor(R.color.app_background_white));
            } else {
                // Set the background image
                mImageFetcher.loadArtistImage(dataHolder.mLineOne, holder.mBackground.get());
            }
        }
        if (Ref.alive(holder.mImage)) {
            // Play the artist when the artwork is touched
            initArtistPlayOnClick(holder.mImage.get(), position);
        }
    }
    return convertView;
}
Also used : DataHolder(com.andrew.apollo.ui.MusicViewHolder.DataHolder) MusicViewHolder(com.andrew.apollo.ui.MusicViewHolder)

Example 2 with MusicViewHolder

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

the class RecycleHolder method onMovedToScrapHeap.

/**
 * {@inheritDoc}
 */
@Override
public void onMovedToScrapHeap(final View view) {
    if (view == null) {
        return;
    }
    MusicViewHolder holder = (MusicViewHolder) view.getTag();
    if (holder == null) {
        holder = new MusicViewHolder(view);
        view.setTag(holder);
    }
    holder.reset();
}
Also used : MusicViewHolder(com.andrew.apollo.ui.MusicViewHolder)

Example 3 with MusicViewHolder

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

the class AlbumAdapter method getView.

/**
 * {@inheritDoc}
 */
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
    // Recycle ViewHolder's items
    convertView = prepareMusicViewHolder(mLayoutId, getContext(), convertView, parent);
    MusicViewHolder holder = (MusicViewHolder) convertView.getTag();
    // Retrieve the data holder
    final DataHolder dataHolder = mData[position];
    updateFirstTwoArtistLines(holder, dataHolder);
    if (mImageFetcher == null) {
        LOG.warn("ArtistAdapter has null image fetcher");
    }
    if (mImageFetcher != null && dataHolder != null && Ref.alive(holder.mImage)) {
        // Asynchronously load the album images into the adapter
        mImageFetcher.loadAlbumImage(dataHolder.mLineTwo, dataHolder.mLineOne, dataHolder.mItemId, holder.mImage.get());
    }
    // List view only items
    if (mLoadExtraData && holder != null && dataHolder != null) {
        if (Ref.alive(holder.mOverlay)) {
            // Make sure the background layer gets set
            holder.mOverlay.get().setBackgroundColor(mOverlay);
        }
        if (Ref.alive(holder.mLineThree)) {
            // Set the number of songs (line three)
            holder.mLineThree.get().setText(dataHolder.mLineThree);
        }
        if (mImageFetcher != null && Ref.alive(holder.mBackground)) {
            if (mLayoutId == R.layout.list_item_detailed_no_background) {
                holder.mBackground.get().setBackground(null);
                holder.mBackground.get().setBackgroundColor(convertView.getResources().getColor(R.color.app_background_white));
            } else {
                // Asynchronously load the artist image on the background view
                mImageFetcher.loadArtistImage(dataHolder.mLineTwo, holder.mBackground.get());
            }
        }
    }
    if (mTouchPlay && holder != null && Ref.alive(holder.mImage)) {
        // Play the album when the artwork is touched
        initAlbumPlayOnClick(holder.mImage.get(), position);
    }
    return convertView;
}
Also used : DataHolder(com.andrew.apollo.ui.MusicViewHolder.DataHolder) MusicViewHolder(com.andrew.apollo.ui.MusicViewHolder)

Example 4 with MusicViewHolder

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

the class ArtistAlbumAdapter method getView.

/**
 * {@inheritDoc}
 */
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
    // Return a faux header at position 0
    if (position == 0) {
        return mHeader;
    }
    // Recycle MusicHolder's items
    convertView = prepareMusicViewHolder(mLayoutId, getContext(), convertView, parent);
    MusicViewHolder holder = (MusicViewHolder) convertView.getTag();
    if (holder != null && Ref.alive(holder.mOverlay)) {
        holder.mOverlay.get().setBackgroundColor(0);
    }
    // Retrieve the album
    final Album album = getItem(position - getOffset());
    final String albumName = album.mAlbumName;
    if (holder != null) {
        if (Ref.alive(holder.mLineOne)) {
            // Set each album name (line one)
            holder.mLineOne.get().setText(albumName);
        }
        if (Ref.alive(holder.mLineTwo)) {
            // Set the number of songs (line two)
            holder.mLineTwo.get().setText(MusicUtils.makeLabel(getContext(), R.plurals.Nsongs, album.mSongNumber));
        }
        if (Ref.alive(holder.mLineThree)) {
            // Set the album year (line three)
            holder.mLineThree.get().setText(album.mYear);
        }
    }
    if (mImageFetcher != null && Ref.alive(holder.mImage)) {
        // Asynchronously load the album images into the adapter
        mImageFetcher.loadAlbumImage(album.mArtistName, albumName, album.mAlbumId, holder.mImage.get());
    }
    // Play the album when the artwork is touched
    if (holder != null && Ref.alive(holder.mImage)) {
        initAlbumPlayOnClick(holder.mImage.get(), position - getOffset());
    }
    return convertView;
}
Also used : Album(com.andrew.apollo.model.Album) MusicViewHolder(com.andrew.apollo.ui.MusicViewHolder)

Example 5 with MusicViewHolder

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

the class ProfileSongAdapter method getView.

/**
 * {@inheritDoc}
 */
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
    // Return a faux header at position 0
    if (position == 0) {
        return mHeader;
    }
    // Recycle MusicHolder's items
    MusicViewHolder holder;
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(mLayoutId, parent, false);
        holder = new MusicViewHolder(convertView);
        // Hide the third line of text
        holder.mLineThree.get().setVisibility(View.GONE);
        convertView.setTag(holder);
    } else {
        holder = (MusicViewHolder) convertView.getTag();
    }
    // Retrieve the album
    // getOffset());
    final Song song = getItem(position - 1);
    // Set each track name (line one)
    holder.mLineOne.get().setText(song.mSongName);
    // Set the line two
    switch(mDisplaySetting) {
        // show duration if on album fragment
        case DISPLAY_ALBUM_SETTING:
            holder.mLineOneRight.get().setVisibility(View.GONE);
            holder.mLineTwo.get().setText(MusicUtils.makeTimeString(getContext(), song.mDuration));
            break;
        case DISPLAY_PLAYLIST_SETTING:
            if (song.mDuration == -1) {
                holder.mLineOneRight.get().setVisibility(View.GONE);
            } else {
                holder.mLineOneRight.get().setVisibility(View.VISIBLE);
                holder.mLineOneRight.get().setText(MusicUtils.makeTimeString(getContext(), song.mDuration));
            }
            final StringBuilder sb = new StringBuilder(song.mArtistName);
            sb.append(SEPARATOR_STRING);
            sb.append(song.mAlbumName);
            holder.mLineTwo.get().setText(sb.toString());
            break;
        case DISPLAY_DEFAULT_SETTING:
        default:
            holder.mLineOneRight.get().setVisibility(View.VISIBLE);
            holder.mLineOneRight.get().setText(MusicUtils.makeTimeString(getContext(), song.mDuration));
            holder.mLineTwo.get().setText(song.mAlbumName);
            break;
    }
    return convertView;
}
Also used : Song(com.andrew.apollo.model.Song) 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