use of com.naman14.timber.models.Album in project Timber by naman14.
the class AlbumAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
Album localItem = arraylist.get(i);
itemHolder.title.setText(localItem.title);
itemHolder.artist.setText(localItem.artistName);
ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.id).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build(), new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if (isGrid) {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
Palette.Swatch swatch = palette.getVibrantSwatch();
if (swatch != null) {
int color = swatch.getRgb();
itemHolder.footer.setBackgroundColor(color);
int textColor = TimberUtils.getBlackWhiteColor(swatch.getTitleTextColor());
itemHolder.title.setTextColor(textColor);
itemHolder.artist.setTextColor(textColor);
} else {
Palette.Swatch mutedSwatch = palette.getMutedSwatch();
if (mutedSwatch != null) {
int color = mutedSwatch.getRgb();
itemHolder.footer.setBackgroundColor(color);
int textColor = TimberUtils.getBlackWhiteColor(mutedSwatch.getTitleTextColor());
itemHolder.title.setTextColor(textColor);
itemHolder.artist.setTextColor(textColor);
}
}
}
});
}
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
if (isGrid) {
itemHolder.footer.setBackgroundColor(0);
if (mContext != null) {
int textColorPrimary = Config.textColorPrimary(mContext, Helpers.getATEKey(mContext));
itemHolder.title.setTextColor(textColorPrimary);
itemHolder.artist.setTextColor(textColorPrimary);
}
}
}
});
if (TimberUtils.isLollipop())
itemHolder.albumArt.setTransitionName("transition_album_art" + i);
}
use of com.naman14.timber.models.Album in project Timber by naman14.
the class SearchAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
switch(getItemViewType(i)) {
case 0:
Song song = (Song) searchResults.get(i);
itemHolder.title.setText(song.title);
itemHolder.songartist.setText(song.albumName);
ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(song.albumId).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
setOnPopupMenuListener(itemHolder, i);
break;
case 1:
Album album = (Album) searchResults.get(i);
itemHolder.albumtitle.setText(album.title);
itemHolder.albumartist.setText(album.artistName);
ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(album.id).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
break;
case 2:
Artist artist = (Artist) searchResults.get(i);
itemHolder.artisttitle.setText(artist.name);
String albumNmber = TimberUtils.makeLabel(mContext, R.plurals.Nalbums, artist.albumCount);
String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, artist.songCount);
itemHolder.albumsongcount.setText(TimberUtils.makeCombinedString(mContext, albumNmber, songCount));
LastFmClient.getInstance(mContext).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {
@Override
public void artistInfoSucess(LastfmArtist artist) {
if (artist != null && itemHolder.artistImage != null) {
ImageLoader.getInstance().displayImage(artist.mArtwork.get(1).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
}
}
@Override
public void artistInfoFailed() {
}
});
break;
case 10:
itemHolder.sectionHeader.setText((String) searchResults.get(i));
case 3:
break;
}
}
use of com.naman14.timber.models.Album in project Timber by naman14.
the class ArtistAlbumAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ItemHolder itemHolder, int i) {
Album localItem = arraylist.get(i);
itemHolder.title.setText(localItem.title);
String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount);
itemHolder.details.setText(songCount);
ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.id).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build());
if (TimberUtils.isLollipop())
itemHolder.albumArt.setTransitionName("transition_album_art" + i);
}
use of com.naman14.timber.models.Album in project Timber by naman14.
the class QueueLoader method getQueueSongs.
public static List<Song> getQueueSongs(Context context) {
final ArrayList<Song> mSongList = new ArrayList<>();
mCursor = new NowPlayingCursor(context);
if (mCursor != null && mCursor.moveToFirst()) {
do {
final long id = mCursor.getLong(0);
final String songName = mCursor.getString(1);
final String artist = mCursor.getString(2);
final long albumId = mCursor.getLong(3);
final String album = mCursor.getString(4);
final int duration = mCursor.getInt(5);
final long artistid = mCursor.getInt(7);
final int tracknumber = mCursor.getInt(6);
final Song song = new Song(id, albumId, artistid, songName, artist, album, duration, tracknumber);
mSongList.add(song);
} while (mCursor.moveToNext());
}
if (mCursor != null) {
mCursor.close();
mCursor = null;
}
return mSongList;
}
use of com.naman14.timber.models.Album in project Timber by naman14.
the class AlbumDetailFragment method onCreateView.
@TargetApi(21)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_album_detail, container, false);
albumArt = (ImageView) rootView.findViewById(R.id.album_art);
artistArt = (ImageView) rootView.findViewById(R.id.artist_art);
albumTitle = (TextView) rootView.findViewById(R.id.album_title);
albumDetails = (TextView) rootView.findViewById(R.id.album_details);
toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
if (getArguments().getBoolean("transition")) {
albumArt.setTransitionName(getArguments().getString("transition_name"));
}
recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
collapsingToolbarLayout = (CollapsingToolbarLayout) rootView.findViewById(R.id.collapsing_toolbar);
appBarLayout = (AppBarLayout) rootView.findViewById(R.id.app_bar);
recyclerView.setEnabled(false);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
album = AlbumLoader.getAlbum(getActivity(), albumID);
setAlbumart();
setUpEverything();
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
AlbumSongsAdapter adapter = (AlbumSongsAdapter) recyclerView.getAdapter();
MusicPlayer.playAll(getActivity(), adapter.getSongIds(), 0, albumID, TimberUtils.IdType.Album, true);
NavigationUtils.navigateToNowplaying(getActivity(), false);
}
}, 150);
}
});
return rootView;
}
Aggregations