Search in sources :

Example 1 with ObservableColorMatrix

use of com.looklook.xinghongfei.looklook.util.ObservableColorMatrix 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 2 with ObservableColorMatrix

use of com.looklook.xinghongfei.looklook.util.ObservableColorMatrix 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 3 with ObservableColorMatrix

use of com.looklook.xinghongfei.looklook.util.ObservableColorMatrix in project LookLook by xinghongfei.

the class ZhihuAdapter method bindViewHolderNormal.

private void bindViewHolderNormal(final ZhihuViewHolder holder, final int position) {
    final ZhihuDailyItem zhihuDailyItem = zhihuDailyItems.get(holder.getAdapterPosition());
    if (DBUtils.getDB(mContext).isRead(Config.ZHIHU, zhihuDailyItem.getId(), 1))
        holder.textView.setTextColor(Color.GRAY);
    else
        holder.textView.setTextColor(Color.BLACK);
    holder.imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            goDescribeActivity(holder, zhihuDailyItem);
        }
    });
    holder.textView.setText(zhihuDailyItem.getTitle());
    holder.linearLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            goDescribeActivity(holder, zhihuDailyItem);
        }
    });
    Glide.with(mContext).load(zhihuDailyItems.get(position).getImages()[0]).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 (!zhihuDailyItem.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();
                        zhihuDailyItem.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) ZhihuDailyItem(com.looklook.xinghongfei.looklook.bean.zhihu.ZhihuDailyItem) 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) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Aggregations

Animator (android.animation.Animator)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 ObjectAnimator (android.animation.ObjectAnimator)3 ValueAnimator (android.animation.ValueAnimator)3 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)3 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)3 GlideDrawable (com.bumptech.glide.load.resource.drawable.GlideDrawable)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 TextView (android.widget.TextView)2 RequestListener (com.bumptech.glide.request.RequestListener)1 Target (com.bumptech.glide.request.target.Target)1 Meizi (com.looklook.xinghongfei.looklook.bean.meizi.Meizi)1 NewsBean (com.looklook.xinghongfei.looklook.bean.news.NewsBean)1 ZhihuDailyItem (com.looklook.xinghongfei.looklook.bean.zhihu.ZhihuDailyItem)1