Search in sources :

Example 1 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project plaid by nickbutcher.

the class FeedAdapter method bindDribbbleShotHolder.

private void bindDribbbleShotHolder(final Shot shot, final DribbbleShotHolder holder, int position) {
    final int[] imageSize = shot.images.bestSize();
    Glide.with(host).load(shot.images.best()).listener(new RequestListener<String, GlideDrawable>() {

        @Override
        public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
            if (!shot.hasFadedIn) {
                holder.image.setHasTransientState(true);
                final ObservableColorMatrix cm = new ObservableColorMatrix();
                final ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
                saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                    @Override
                    public void onAnimationUpdate(ValueAnimator valueAnimator) {
                        // just animating the color matrix does not invalidate the
                        // drawable so need this update listener.  Also have to create a
                        // new CMCF as the matrix is immutable :(
                        holder.image.setColorFilter(new ColorMatrixColorFilter(cm));
                    }
                });
                saturation.setDuration(2000L);
                saturation.setInterpolator(getFastOutSlowInInterpolator(host));
                saturation.addListener(new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        holder.image.clearColorFilter();
                        holder.image.setHasTransientState(false);
                    }
                });
                saturation.start();
                shot.hasFadedIn = true;
            }
            return false;
        }

        @Override
        public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
            return false;
        }
    }).placeholder(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]).diskCacheStrategy(DiskCacheStrategy.SOURCE).fitCenter().override(imageSize[0], imageSize[1]).into(new DribbbleTarget(holder.image, false));
    // need both placeholder & background to prevent seeing through shot as it fades in
    holder.image.setBackground(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]);
    holder.image.showBadge(shot.animated);
    // need a unique transition name per shot, let's use it's url
    holder.image.setTransitionName(shot.html_url);
}
Also used : DribbbleTarget(io.plaidapp.util.glide.DribbbleTarget) RequestListener(com.bumptech.glide.request.RequestListener) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) Target(com.bumptech.glide.request.target.Target) DribbbleTarget(io.plaidapp.util.glide.DribbbleTarget) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) ObservableColorMatrix(io.plaidapp.util.ObservableColorMatrix) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 2 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project CloudReader by youlookwhat.

the class MovieDetailActivity method setImgHeaderBg.

/**
     * 加载titlebar背景
     */
private void setImgHeaderBg() {
    if (subjectsBean != null) {
        // 高斯模糊背景 原来 参数:12,5  23,4
        Glide.with(this).load(subjectsBean.getImages().getLarge()).error(R.drawable.stackblur_default).bitmapTransform(new BlurTransformation(this, 23, 4)).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) {
                binding.titleToolBar.setBackgroundColor(Color.TRANSPARENT);
                binding.ivTitleHeadBg.setImageAlpha(0);
                binding.ivTitleHeadBg.setVisibility(View.VISIBLE);
                return false;
            }
        }).into(binding.ivTitleHeadBg);
    }
}
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 3 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project LookLook by xinghongfei.

the class MeiziAdapter method bindViewHolderNormal.

private void bindViewHolderNormal(final MeiziViewHolder holder, final int position) {
    final Meizi meizi = meiziItemes.get(holder.getAdapterPosition());
    holder.imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            startDescribeActivity(meizi, holder);
        }
    });
    //        holder.textView.setText("视频");
    //        holder.textView.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View view) {
    //                startDescribeActivity(meizi,holder);
    //            }
    //        });
    Glide.with(mContext).load(meizi.getUrl()).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) {
            if (!meizi.hasFadedIn) {
                holder.imageView.setHasTransientState(true);
                final ObservableColorMatrix cm = new ObservableColorMatrix();
                final ObjectAnimator animator = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
                animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                    @Override
                    public void onAnimationUpdate(ValueAnimator valueAnimator) {
                        holder.imageView.setColorFilter(new ColorMatrixColorFilter(cm));
                    }
                });
                animator.setDuration(2000L);
                animator.setInterpolator(new AccelerateInterpolator());
                animator.addListener(new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        holder.imageView.clearColorFilter();
                        holder.imageView.setHasTransientState(false);
                        animator.start();
                        meizi.hasFadedIn = true;
                    }
                });
            }
            return false;
        }
    }).diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().into(new DribbbleTarget(holder.imageView, false));
}
Also used : DribbbleTarget(com.looklook.xinghongfei.looklook.util.DribbbleTarget) RequestListener(com.bumptech.glide.request.RequestListener) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) Meizi(com.looklook.xinghongfei.looklook.bean.meizi.Meizi) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) BadgedFourThreeImageView(com.looklook.xinghongfei.looklook.widget.BadgedFourThreeImageView) RecyclerView(android.support.v7.widget.RecyclerView) ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) DribbbleTarget(com.looklook.xinghongfei.looklook.util.DribbbleTarget) Target(com.bumptech.glide.request.target.Target) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) ObservableColorMatrix(com.looklook.xinghongfei.looklook.util.ObservableColorMatrix) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 4 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project LookLook by xinghongfei.

the class TopNewsAdapter method bindViewHolderNormal.

private void bindViewHolderNormal(final TopNewsViewHolder holder, final int position) {
    final NewsBean newsBeanItem = topNewitems.get(holder.getAdapterPosition());
    if (DBUtils.getDB(mContext).isRead(Config.TOPNEWS, newsBeanItem.getTitle(), 1)) {
        holder.textView.setTextColor(Color.GRAY);
        holder.sourceTextview.setTextColor(Color.GRAY);
    } else {
        holder.textView.setTextColor(Color.BLACK);
        holder.sourceTextview.setTextColor(Color.BLACK);
    }
    holder.imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            DBUtils.getDB(mContext).insertHasRead(Config.ZHIHU, newsBeanItem.getTitle(), 1);
            holder.textView.setTextColor(Color.GRAY);
            holder.sourceTextview.setTextColor(Color.GRAY);
            startTopnewsActivity(newsBeanItem, holder);
        }
    });
    holder.textView.setText(newsBeanItem.getTitle());
    holder.sourceTextview.setText(newsBeanItem.getSource());
    holder.linearLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            startTopnewsActivity(newsBeanItem, holder);
        }
    });
    Glide.with(mContext).load(newsBeanItem.getImgsrc()).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) {
            if (!newsBeanItem.hasFadedIn) {
                holder.imageView.setHasTransientState(true);
                final ObservableColorMatrix cm = new ObservableColorMatrix();
                final ObjectAnimator animator = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
                animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                    @Override
                    public void onAnimationUpdate(ValueAnimator valueAnimator) {
                        holder.imageView.setColorFilter(new ColorMatrixColorFilter(cm));
                    }
                });
                animator.setDuration(2000L);
                animator.setInterpolator(new AccelerateInterpolator());
                animator.addListener(new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        holder.imageView.clearColorFilter();
                        holder.imageView.setHasTransientState(false);
                        animator.start();
                        newsBeanItem.hasFadedIn = true;
                    }
                });
            }
            return false;
        }
    }).diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().override(widthPx, heighPx).into(new DribbbleTarget(holder.imageView, false));
}
Also used : DribbbleTarget(com.looklook.xinghongfei.looklook.util.DribbbleTarget) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) BadgedFourThreeImageView(com.looklook.xinghongfei.looklook.widget.BadgedFourThreeImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) ObservableColorMatrix(com.looklook.xinghongfei.looklook.util.ObservableColorMatrix) NewsBean(com.looklook.xinghongfei.looklook.bean.news.NewsBean) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 5 with GlideDrawable

use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project easy by MehdiBenmesa.

the class MaterialViewPagerImageHelper method setImageUrl.

/**
 * change the image with a fade
 *
 * @param urlImage
 * @param fadeDuration TODO : remove Picasso
 */
public static void setImageUrl(final ImageView imageView, final String urlImage, final int fadeDuration) {
    final float alpha = ViewCompat.getAlpha(imageView);
    final ImageView viewToAnimate = imageView;
    // fade to alpha=0
    fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(View view) {
            super.onAnimationEnd(view);
            // change the image when alpha=0
            Glide.with(imageView.getContext()).load(urlImage).centerCrop().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) {
                    // then fade to alpha=1
                    fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter());
                    if (imageLoadListener != null) {
                        imageLoadListener.OnImageLoad(imageView, ((BitmapDrawable) imageView.getDrawable()).getBitmap());
                    }
                    return false;
                }
            }).into(viewToAnimate);
        }
    });
}
Also used : ImageView(android.widget.ImageView) ViewPropertyAnimatorListenerAdapter(android.support.v4.view.ViewPropertyAnimatorListenerAdapter) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) View(android.view.View) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Aggregations

GlideDrawable (com.bumptech.glide.load.resource.drawable.GlideDrawable)21 View (android.view.View)9 RequestListener (com.bumptech.glide.request.RequestListener)9 Target (com.bumptech.glide.request.target.Target)9 ObjectAnimator (android.animation.ObjectAnimator)6 ValueAnimator (android.animation.ValueAnimator)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)5 TextView (android.widget.TextView)5 RecyclerView (android.support.v7.widget.RecyclerView)4 ImageView (android.widget.ImageView)4 BlurTransformation (jp.wasabeef.glide.transformations.BlurTransformation)4 BitmapDrawable (android.graphics.drawable.BitmapDrawable)3 Drawable (android.graphics.drawable.Drawable)3 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)3 DribbbleTarget (com.looklook.xinghongfei.looklook.util.DribbbleTarget)3 ObservableColorMatrix (com.looklook.xinghongfei.looklook.util.ObservableColorMatrix)3 BadgedFourThreeImageView (com.looklook.xinghongfei.looklook.widget.BadgedFourThreeImageView)3 Context (android.content.Context)2