Search in sources :

Example 46 with ViewPropertyAnimatorCompat

use of android.support.v4.view.ViewPropertyAnimatorCompat in project actor-platform by actorapp.

the class CustomItemAnimator method animateChangeImpl.

private void animateChangeImpl(final ChangeInfo changeInfo) {
    final ViewHolder holder = changeInfo.oldHolder;
    final View view = holder == null ? null : holder.itemView;
    final ViewHolder newHolder = changeInfo.newHolder;
    final View newView = newHolder != null ? newHolder.itemView : null;
    if (view != null) {
        final ViewPropertyAnimatorCompat oldViewAnim = ViewCompat.animate(view).setDuration(getChangeDuration());
        mChangeAnimations.add(changeInfo.oldHolder);
        oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
        oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
        oldViewAnim.alpha(0).setListener(new VpaListenerAdapter() {

            @Override
            public void onAnimationStart(View view) {
                dispatchChangeStarting(changeInfo.oldHolder, true);
            }

            @Override
            public void onAnimationEnd(View view) {
                oldViewAnim.setListener(null);
                ViewCompat.setAlpha(view, 1);
                ViewCompat.setTranslationX(view, 0);
                ViewCompat.setTranslationY(view, 0);
                dispatchChangeFinished(changeInfo.oldHolder, true);
                mChangeAnimations.remove(changeInfo.oldHolder);
                dispatchFinishedWhenDone();
            }
        }).start();
    }
    if (newView != null) {
        final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newView);
        mChangeAnimations.add(changeInfo.newHolder);
        newViewAnimation.translationX(0).translationY(0).setDuration(getChangeDuration()).alpha(1).setListener(new VpaListenerAdapter() {

            @Override
            public void onAnimationStart(View view) {
                dispatchChangeStarting(changeInfo.newHolder, false);
            }

            @Override
            public void onAnimationEnd(View view) {
                newViewAnimation.setListener(null);
                ViewCompat.setAlpha(newView, 1);
                ViewCompat.setTranslationX(newView, 0);
                ViewCompat.setTranslationY(newView, 0);
                dispatchChangeFinished(changeInfo.newHolder, false);
                mChangeAnimations.remove(changeInfo.newHolder);
                dispatchFinishedWhenDone();
            }
        }).start();
    }
}
Also used : AnimatorViewHolder(im.actor.sdk.controllers.fragment.AnimatorViewHolder) ViewHolder(android.support.v7.widget.RecyclerView.ViewHolder) ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) View(android.view.View)

Aggregations

ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)46 View (android.view.View)40 RecyclerView (android.support.v7.widget.RecyclerView)32 ViewHolder (android.support.v7.widget.RecyclerView.ViewHolder)6 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)5 BezierDecelerateInterpolator (acr.browser.lightning.interpolator.BezierDecelerateInterpolator)2 ViewPropertyAnimatorUpdateListener (android.support.v4.view.ViewPropertyAnimatorUpdateListener)2 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)2 AbsListView (android.widget.AbsListView)2 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 ViewPropertyAnimatorListener (android.support.v4.view.ViewPropertyAnimatorListener)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 AnimatorViewHolder (im.actor.sdk.controllers.fragment.AnimatorViewHolder)1 AnimateViewHolder (jp.wasabeef.recyclerview.animators.holder.AnimateViewHolder)1