use of jp.wasabeef.glide.transformations.CropTransformation in project SpotiQ by ZinoKader.
the class TracklistRecyclerAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(SongHolder songHolder, int position) {
Song song = songs.get(position);
Context context = songHolder.itemView.getContext();
String artistsName = ArtistMapper.joinArtistNames(song.getArtists());
String runTimeText = String.format(Locale.getDefault(), "%d minutes, %d seconds", TimeUnit.MILLISECONDS.toMinutes(song.getDurationMs()), TimeUnit.MILLISECONDS.toSeconds(song.getDurationMs()) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(song.getDurationMs())));
songHolder.cropTransformation = new CropTransformation(context, ApplicationConstants.DEFAULT_TRACKLIST_CROP_WIDTH, ApplicationConstants.DEFAULT_TRACKLIST_CROP_HEIGHT, CropTransformation.CropType.CENTER);
songHolder.blurTransformation = new BlurTransformation(context, ApplicationConstants.DEFAULT_TRACKLIST_BLUR_RADIUS);
songHolder.colorFilterTransformation = new ColorFilterTransformation(context, R.color.colorPrimary);
Glide.with(songHolder.itemView.getContext()).load(song.getAlbumArtUrl()).fitCenter().placeholder(R.drawable.image_album_placeholder).bitmapTransform(songHolder.blurTransformation, songHolder.cropTransformation, songHolder.colorFilterTransformation).into(new SimpleTarget<GlideDrawable>() {
@Override
public void onResourceReady(GlideDrawable drawable, GlideAnimation<? super GlideDrawable> glideAnimation) {
songHolder.cardViewRoot.setBackground(drawable);
}
});
Glide.with(context).load(song.getAlbumArtUrl()).placeholder(R.drawable.image_album_placeholder).fitCenter().into(songHolder.albumArt);
songHolder.songName.setText(song.getName());
songHolder.artistsName.setText(artistsName);
songHolder.runTime.setText(runTimeText);
songHolder.albumName.setText(song.getAlbum().name);
}
Aggregations