Search in sources :

Example 1 with CropTransformation

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);
}
Also used : Context(android.content.Context) BlurTransformation(jp.wasabeef.glide.transformations.BlurTransformation) Song(se.zinokader.spotiq.model.Song) CropTransformation(jp.wasabeef.glide.transformations.CropTransformation) ColorFilterTransformation(jp.wasabeef.glide.transformations.ColorFilterTransformation) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Aggregations

Context (android.content.Context)1 GlideDrawable (com.bumptech.glide.load.resource.drawable.GlideDrawable)1 BlurTransformation (jp.wasabeef.glide.transformations.BlurTransformation)1 ColorFilterTransformation (jp.wasabeef.glide.transformations.ColorFilterTransformation)1 CropTransformation (jp.wasabeef.glide.transformations.CropTransformation)1 Song (se.zinokader.spotiq.model.Song)1