Search in sources :

Example 21 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project LookLook by xinghongfei.

the class ZhihuDescribeActivity method expandImageAndFinish.

private void expandImageAndFinish() {
    if (mShot.getOffset() != 0f) {
        Animator expandImage = ObjectAnimator.ofFloat(mShot, ParallaxScrimageView.OFFSET, 0f);
        expandImage.setDuration(80);
        expandImage.setInterpolator(new AccelerateInterpolator());
        expandImage.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    finishAfterTransition();
                } else {
                    finish();
                }
            }
        });
        expandImage.start();
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            finishAfterTransition();
        } else {
            finish();
        }
    }
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 22 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator 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 23 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator 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 24 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project WordPress-Android by wordpress-mobile.

the class AniUtils method animateBar.

private static void animateBar(View view, boolean show, boolean isTopBar, Duration duration) {
    int newVisibility = (show ? View.VISIBLE : View.GONE);
    if (view == null || view.getVisibility() == newVisibility) {
        return;
    }
    float fromY;
    float toY;
    if (isTopBar) {
        fromY = (show ? -1f : 0f);
        toY = (show ? 0f : -1f);
    } else {
        fromY = (show ? 1f : 0f);
        toY = (show ? 0f : 1f);
    }
    Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, fromY, Animation.RELATIVE_TO_SELF, toY);
    long durationMillis = duration.toMillis(view.getContext());
    animation.setDuration(durationMillis);
    if (show) {
        animation.setInterpolator(new DecelerateInterpolator());
    } else {
        animation.setInterpolator(new AccelerateInterpolator());
    }
    view.clearAnimation();
    view.startAnimation(animation);
    view.setVisibility(newVisibility);
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation)

Example 25 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project WordPress-Android by wordpress-mobile.

the class AniUtils method showFab.

/*
     * in/out animation for floating action button
     */
public static void showFab(final View view, final boolean show) {
    if (view == null)
        return;
    Context context = view.getContext();
    int fabHeight = context.getResources().getDimensionPixelSize(android.support.design.R.dimen.design_fab_size_normal);
    int fabMargin = context.getResources().getDimensionPixelSize(R.dimen.fab_margin);
    int max = (fabHeight + fabMargin) * 2;
    float fromY = (show ? max : 0f);
    float toY = (show ? 0f : max);
    ObjectAnimator anim = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, fromY, toY);
    if (show) {
        anim.setInterpolator(new DecelerateInterpolator());
    } else {
        anim.setInterpolator(new AccelerateInterpolator());
    }
    anim.setDuration(show ? Duration.LONG.toMillis(context) : Duration.SHORT.toMillis(context));
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            if (view.getVisibility() != View.VISIBLE) {
                view.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (!show) {
                view.setVisibility(View.GONE);
            }
        }
    });
    anim.start();
}
Also used : Context(android.content.Context) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Aggregations

AccelerateInterpolator (android.view.animation.AccelerateInterpolator)186 Animator (android.animation.Animator)62 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)54 View (android.view.View)52 ObjectAnimator (android.animation.ObjectAnimator)41 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40 ImageView (android.widget.ImageView)26 AnimatorSet (android.animation.AnimatorSet)24 TextView (android.widget.TextView)23 Animation (android.view.animation.Animation)21 ValueAnimator (android.animation.ValueAnimator)17 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)14 OvershootInterpolator (android.view.animation.OvershootInterpolator)13 Point (android.graphics.Point)12 Paint (android.graphics.Paint)10 Interpolator (android.view.animation.Interpolator)9 AlphaAnimation (android.view.animation.AlphaAnimation)8 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)8