use of com.naman14.timber.lastfmapi.models.LastfmArtist in project Timber by naman14.
the class ArtistDetailFragment method setUpArtistDetails.
private void setUpArtistDetails() {
final Artist artist = ArtistLoader.getArtist(getActivity(), artistID);
List<Song> songList = ArtistSongLoader.getSongsForArtist(getActivity(), artistID);
mAdapter = new ArtistSongAdapter(getActivity(), songList, artistID);
collapsingToolbarLayout.setTitle(artist.name);
LastFmClient.getInstance(getActivity()).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {
@Override
public void artistInfoSucess(final LastfmArtist artist) {
if (artist != null) {
ImageLoader.getInstance().displayImage(artist.mArtwork.get(4).mUrl, artistArt, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).build(), new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
largeImageLoaded = true;
try {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
Palette.Swatch swatch = palette.getVibrantSwatch();
if (swatch != null) {
primaryColor = swatch.getRgb();
collapsingToolbarLayout.setContentScrimColor(primaryColor);
if (getActivity() != null)
ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
} else {
Palette.Swatch swatchMuted = palette.getMutedSwatch();
if (swatchMuted != null) {
primaryColor = swatchMuted.getRgb();
collapsingToolbarLayout.setContentScrimColor(primaryColor);
if (getActivity() != null)
ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
}
}
}
});
} catch (Exception ignored) {
}
}
});
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
setBlurredPlaceholder(artist);
}
}, 100);
}
}
@Override
public void artistInfoFailed() {
}
});
}
use of com.naman14.timber.lastfmapi.models.LastfmArtist 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.lastfmapi.models.LastfmArtist in project Timber by naman14.
the class ArtistBioFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_artist_bio, container, false);
Artist artist = ArtistLoader.getArtist(getActivity(), artistID);
LastFmClient.getInstance(getActivity()).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {
@Override
public void artistInfoSucess(LastfmArtist artist) {
}
@Override
public void artistInfoFailed() {
}
});
final MultiViewPager pager = (MultiViewPager) rootView.findViewById(R.id.tagspager);
final FragmentStatePagerAdapter adapter = new FragmentStatePagerAdapter(getActivity().getSupportFragmentManager()) {
@Override
public int getCount() {
return 20;
}
@Override
public Fragment getItem(int position) {
return ArtistTagFragment.newInstance(position);
}
};
pager.setAdapter(adapter);
return rootView;
}
use of com.naman14.timber.lastfmapi.models.LastfmArtist in project Timber by naman14.
the class SimilarArtistFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_similar_artists, container, false);
Artist artist = ArtistLoader.getArtist(getActivity(), artistID);
LastFmClient.getInstance(getActivity()).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {
@Override
public void artistInfoSucess(LastfmArtist artist) {
}
@Override
public void artistInfoFailed() {
}
});
return rootView;
}
use of com.naman14.timber.lastfmapi.models.LastfmArtist in project Timber by naman14.
the class ArtistAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
final Artist localItem = arraylist.get(i);
itemHolder.name.setText(localItem.name);
String albumNmber = TimberUtils.makeLabel(mContext, R.plurals.Nalbums, localItem.albumCount);
String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount);
itemHolder.albums.setText(TimberUtils.makeCombinedString(mContext, albumNmber, songCount));
LastFmClient.getInstance(mContext).getArtistInfo(new ArtistQuery(localItem.name), new ArtistInfoListener() {
@Override
public void artistInfoSucess(LastfmArtist artist) {
if (artist != null && artist.mArtwork != null) {
if (isGrid) {
ImageLoader.getInstance().displayImage(artist.mArtwork.get(2).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnLoading(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 && loadedImage != null) {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
int color = palette.getVibrantColor(Color.parseColor("#66000000"));
itemHolder.footer.setBackgroundColor(color);
Palette.Swatch swatch = palette.getVibrantSwatch();
int textColor;
if (swatch != null) {
textColor = getOpaqueColor(swatch.getTitleTextColor());
} else
textColor = Color.parseColor("#ffffff");
itemHolder.name.setTextColor(textColor);
itemHolder.albums.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.name.setTextColor(textColorPrimary);
itemHolder.albums.setTextColor(textColorPrimary);
}
}
}
});
} else {
ImageLoader.getInstance().displayImage(artist.mArtwork.get(1).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnLoading(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
}
}
}
@Override
public void artistInfoFailed() {
}
});
if (TimberUtils.isLollipop())
itemHolder.artistImage.setTransitionName("transition_artist_art" + i);
}
Aggregations