Search in sources :

Example 6 with BlurTransformation

use of jp.wasabeef.glide.transformations.BlurTransformation in project CloudReader by youlookwhat.

the class TestActivity method setData.

private void setData() {
    if (subjectsBean != null) {
        // 高斯模糊背景
        Glide.with(this).load(subjectsBean.getImages().getLarge()).error(R.drawable.stackblur_default).bitmapTransform(new BlurTransformation(this, 12, 5)).listener(new RequestListener<String, GlideDrawable>() {

            @Override
            public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                return false;
            }

            @Override
            public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                mToolbar.setBackgroundColor(Color.TRANSPARENT);
                binding.ivTitleBg.setImageAlpha(0);
                binding.ivTitleBg.setVisibility(View.VISIBLE);
                return false;
            }
        }).into(binding.ivTitleBg);
    }
}
Also used : BlurTransformation(jp.wasabeef.glide.transformations.BlurTransformation) Target(com.bumptech.glide.request.target.Target) RequestListener(com.bumptech.glide.request.RequestListener) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 7 with BlurTransformation

use of jp.wasabeef.glide.transformations.BlurTransformation 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

BlurTransformation (jp.wasabeef.glide.transformations.BlurTransformation)7 GlideDrawable (com.bumptech.glide.load.resource.drawable.GlideDrawable)4 RequestListener (com.bumptech.glide.request.RequestListener)4 Target (com.bumptech.glide.request.target.Target)4 Context (android.content.Context)1 AnimationDrawable (android.graphics.drawable.AnimationDrawable)1 Drawable (android.graphics.drawable.Drawable)1 Nullable (androidx.annotation.Nullable)1 DataSource (com.bumptech.glide.load.DataSource)1 MultiTransformation (com.bumptech.glide.load.MultiTransformation)1 GlideException (com.bumptech.glide.load.engine.GlideException)1 RequestOptions (com.bumptech.glide.request.RequestOptions)1 CircleBorderTransformation (com.ljy.devring.image.support.CircleBorderTransformation)1 ColorFilterTransformation (jp.wasabeef.glide.transformations.ColorFilterTransformation)1 CropTransformation (jp.wasabeef.glide.transformations.CropTransformation)1 GrayscaleTransformation (jp.wasabeef.glide.transformations.GrayscaleTransformation)1 RoundedCornersTransformation (jp.wasabeef.glide.transformations.RoundedCornersTransformation)1 Song (se.zinokader.spotiq.model.Song)1