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;
}
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);
}
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);
}
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;
}
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;
}
}
Aggregations