Search in sources :

Example 1 with Album

use of com.kabouzeid.gramophone.model.Album in project Phonograph by kabouzeid.

the class AlbumLoader method getAlbum.

@NonNull
public static Album getAlbum(@NonNull final Context context, long albumId) {
    List<Song> songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, AudioColumns.ALBUM_ID + "=?", new String[] { String.valueOf(albumId) }, getSongLoaderSortOrder(context)));
    Album album = new Album(songs);
    sortSongsByTrackNumber(album);
    return album;
}
Also used : Song(com.kabouzeid.gramophone.model.Song) Album(com.kabouzeid.gramophone.model.Album) NonNull(androidx.annotation.NonNull)

Example 2 with Album

use of com.kabouzeid.gramophone.model.Album in project Phonograph by kabouzeid.

the class AlbumAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
    final Album album = dataSet.get(position);
    final boolean isChecked = isChecked(album);
    holder.itemView.setActivated(isChecked);
    if (holder.getAdapterPosition() == getItemCount() - 1) {
        if (holder.shortSeparator != null) {
            holder.shortSeparator.setVisibility(View.GONE);
        }
    } else {
        if (holder.shortSeparator != null) {
            holder.shortSeparator.setVisibility(View.VISIBLE);
        }
    }
    if (holder.title != null) {
        holder.title.setText(getAlbumTitle(album));
    }
    if (holder.text != null) {
        holder.text.setText(getAlbumText(album));
    }
    loadAlbumCover(album, holder);
}
Also used : Album(com.kabouzeid.gramophone.model.Album)

Example 3 with Album

use of com.kabouzeid.gramophone.model.Album in project Phonograph by kabouzeid.

the class AlbumDetailActivity method onLoaderReset.

@Override
public void onLoaderReset(Loader<Album> loader) {
    this.album = new Album();
    adapter.swapDataSet(album.songs);
}
Also used : LastFmAlbum(com.kabouzeid.gramophone.lastfm.rest.model.LastFmAlbum) Album(com.kabouzeid.gramophone.model.Album)

Example 4 with Album

use of com.kabouzeid.gramophone.model.Album in project Phonograph by kabouzeid.

the class AlbumLoader method getOrCreateAlbum.

private static Album getOrCreateAlbum(ArrayList<Album> albums, int albumId) {
    for (Album album : albums) {
        if (!album.songs.isEmpty() && album.songs.get(0).albumId == albumId) {
            return album;
        }
    }
    Album album = new Album();
    albums.add(album);
    return album;
}
Also used : Album(com.kabouzeid.gramophone.model.Album)

Example 5 with Album

use of com.kabouzeid.gramophone.model.Album in project Phonograph by kabouzeid.

the class SearchAdapter method onBindViewHolder.

@SuppressWarnings("ConstantConditions")
@Override
public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
    switch(getItemViewType(position)) {
        case ALBUM:
            final Album album = (Album) dataSet.get(position);
            holder.title.setText(album.getTitle());
            holder.text.setText(MusicUtil.getAlbumInfoString(activity, album));
            SongGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong()).checkIgnoreMediaStore(activity).build().into(holder.image);
            break;
        case ARTIST:
            final Artist artist = (Artist) dataSet.get(position);
            holder.title.setText(artist.getName());
            holder.text.setText(MusicUtil.getArtistInfoString(activity, artist));
            ArtistGlideRequest.Builder.from(Glide.with(activity), artist).build().into(holder.image);
            break;
        case SONG:
            final Song song = (Song) dataSet.get(position);
            holder.title.setText(song.title);
            holder.text.setText(MusicUtil.getSongInfoString(song));
            break;
        default:
            holder.title.setText(dataSet.get(position).toString());
            break;
    }
}
Also used : Artist(com.kabouzeid.gramophone.model.Artist) Song(com.kabouzeid.gramophone.model.Song) Album(com.kabouzeid.gramophone.model.Album)

Aggregations

Album (com.kabouzeid.gramophone.model.Album)7 Song (com.kabouzeid.gramophone.model.Song)3 NonNull (androidx.annotation.NonNull)1 AlbumCover (com.kabouzeid.gramophone.glide.artistimage.AlbumCover)1 ArtistImage (com.kabouzeid.gramophone.glide.artistimage.ArtistImage)1 LastFmAlbum (com.kabouzeid.gramophone.lastfm.rest.model.LastFmAlbum)1 Artist (com.kabouzeid.gramophone.model.Artist)1 ArrayList (java.util.ArrayList)1