use of io.hefuyi.listener.mvp.model.ArtistArt in project ListenerMusicPlayer by hefuyicoder.
the class ArtistDetailPresenter method loadArtistArt.
@Override
public void loadArtistArt(long artistID) {
String artistArtJson = PreferencesUtility.getInstance(mView.getContext()).getArtistArt(artistID);
if (!TextUtils.isEmpty(artistArtJson)) {
ArtistArt artistArt = new Gson().fromJson(artistArtJson, ArtistArt.class);
Glide.with(ListenerApp.getContext()).load(artistArt.getExtralarge()).asBitmap().diskCacheStrategy(DiskCacheStrategy.SOURCE).priority(Priority.IMMEDIATE).error(ATEUtil.getDefaultSingerDrawable(mView.getContext())).into(new SimpleTarget<Bitmap>() {
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
mView.showArtistArt(errorDrawable);
}
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
mView.showArtistArt(resource);
}
});
}
}
use of io.hefuyi.listener.mvp.model.ArtistArt in project ListenerMusicPlayer by hefuyicoder.
the class SearchAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ItemHolder itemHolder, int position) {
switch(getItemViewType(position)) {
case 0:
Song song = (Song) searchResults.get(position);
itemHolder.title.setText(song.title);
itemHolder.subtitle1.setText(song.artistName);
itemHolder.subtitle2.setText(song.albumName);
Glide.with(itemHolder.itemView.getContext()).load(ListenerUtil.getAlbumArtUri(song.albumId).toString()).error(ATEUtil.getDefaultAlbumDrawable(mContext)).placeholder(ATEUtil.getDefaultAlbumDrawable(mContext)).centerCrop().into(itemHolder.image);
setOnPopupMenuListener(itemHolder, 0, position);
break;
case 1:
Album album = (Album) searchResults.get(position);
itemHolder.title.setText(album.title);
itemHolder.subtitle1.setText(album.artistName);
itemHolder.subtitle2.setText(ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, album.songCount));
Glide.with(itemHolder.itemView.getContext()).load(ListenerUtil.getAlbumArtUri(album.id).toString()).asBitmap().placeholder(ATEUtil.getDefaultAlbumDrawable(mContext)).error(ATEUtil.getDefaultAlbumDrawable(mContext)).centerCrop().into(itemHolder.image);
if (ListenerUtil.isLollipop())
itemHolder.image.setTransitionName("transition_album_art" + position);
setOnPopupMenuListener(itemHolder, 1, position);
break;
case 2:
Artist artist = (Artist) searchResults.get(position);
itemHolder.title.setText(artist.name);
itemHolder.subtitle1.setText(ListenerUtil.makeLabel(mContext, R.plurals.Nalbums, artist.albumCount));
itemHolder.subtitle2.setText(ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, artist.songCount));
String artistArtJson = PreferencesUtility.getInstance(mContext).getArtistArt(artist.id);
if (!TextUtils.isEmpty(artistArtJson)) {
ArtistArt artistArt = new Gson().fromJson(artistArtJson, ArtistArt.class);
Glide.with(mContext).load(artistArt.getLarge()).asBitmap().placeholder(ATEUtil.getDefaultSingerDrawable(mContext)).diskCacheStrategy(DiskCacheStrategy.SOURCE).error(ATEUtil.getDefaultSingerDrawable(mContext)).into(itemHolder.image);
}
if (ListenerUtil.isLollipop())
itemHolder.image.setTransitionName("transition_artist_art" + position);
setOnPopupMenuListener(itemHolder, 2, position);
break;
case 10:
itemHolder.sectionHeader.setText((String) searchResults.get(position));
case 3:
break;
}
}
use of io.hefuyi.listener.mvp.model.ArtistArt in project ListenerMusicPlayer by hefuyicoder.
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);
itemHolder.albumCount.setText(ListenerUtil.makeLabel(mContext, R.plurals.Nalbums, localItem.albumCount));
itemHolder.songCount.setText(ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount));
String artistArtJson = PreferencesUtility.getInstance(mContext).getArtistArt(localItem.id);
if (TextUtils.isEmpty(artistArtJson)) {
getArtistInfo.execute(new GetArtistInfo.RequestValues(localItem.name)).getArtistInfo().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).onErrorReturn(new Func1<Throwable, ArtistInfo>() {
@Override
public ArtistInfo call(Throwable throwable) {
Toast.makeText(itemHolder.itemView.getContext(), R.string.load_artist_fail, Toast.LENGTH_SHORT).show();
return null;
}
}).subscribe(new Action1<ArtistInfo>() {
@Override
public void call(ArtistInfo artistInfo) {
if (artistInfo != null && artistInfo.mArtist != null && artistInfo.mArtist.mArtwork != null) {
List<Artwork> artworks = artistInfo.mArtist.mArtwork;
ArtistArt artistArt = new ArtistArt(artworks.get(0).mUrl, artworks.get(1).mUrl, artworks.get(2).mUrl, artworks.get(3).mUrl);
PreferencesUtility.getInstance(mContext).setArtistArt(localItem.id, new Gson().toJson(artistArt));
loadArtistArt(artistArt, itemHolder);
}
}
});
} else {
ArtistArt artistArt = new Gson().fromJson(artistArtJson, ArtistArt.class);
loadArtistArt(artistArt, itemHolder);
}
if (ListenerUtil.isLollipop())
itemHolder.artistImage.setTransitionName("transition_artist_art" + i);
setOnPopupMenuListener(itemHolder, i);
}
Aggregations