Search in sources :

Example 31 with ViewPropertyAnimatorCompat

use of android.support.v4.view.ViewPropertyAnimatorCompat in project RecyclerViewItemAnimators by gabrielemariotti.

the class SlideInOutTopItemAnimator method animateRemoveImpl.

protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;
    retrieveItemHeight(holder);
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);
    animation.setDuration(getRemoveDuration()).alpha(0).translationY(-mOriginalY).setListener(new VpaListenerAdapter() {

        @Override
        public void onAnimationStart(View view) {
            dispatchRemoveStarting(holder);
        }

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            ViewCompat.setAlpha(view, 1);
            ViewCompat.setTranslationY(view, -mOriginalY);
            dispatchRemoveFinished(holder);
            mRemoveAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}
Also used : ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 32 with ViewPropertyAnimatorCompat

use of android.support.v4.view.ViewPropertyAnimatorCompat in project RecyclerViewItemAnimators by gabrielemariotti.

the class SlideScaleInOutRightItemAnimator method animateAddImpl.

protected void animateAddImpl(final RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);
    animation.scaleX(1).scaleY(1).translationX(0).alpha(1).setDuration(getAddDuration()).setListener(new VpaListenerAdapter() {

        @Override
        public void onAnimationStart(View view) {
            dispatchAddStarting(holder);
        }

        @Override
        public void onAnimationCancel(View view) {
            ViewCompat.setAlpha(view, 1);
            ViewCompat.setTranslationX(view, 0);
            ViewCompat.setScaleX(view, 1);
            ViewCompat.setScaleY(view, 1);
        }

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            ViewCompat.setAlpha(view, 1);
            ViewCompat.setTranslationX(view, 0);
            ViewCompat.setScaleX(view, 1);
            ViewCompat.setScaleY(view, 1);
            dispatchAddFinished(holder);
            mAddAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}
Also used : ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 33 with ViewPropertyAnimatorCompat

use of android.support.v4.view.ViewPropertyAnimatorCompat in project android-advancedrecyclerview by h6ah4i.

the class SwapTargetItemOperator method setSwapTargetItem.

public void setSwapTargetItem(RecyclerView.ViewHolder swapTargetItem) {
    if (mSwapTargetItem == swapTargetItem) {
        return;
    }
    // reset Y-translation if the swap target has been changed
    if (mSwapTargetItem != null) {
        ViewPropertyAnimatorCompat animator = ViewCompat.animate(mSwapTargetItem.itemView);
        animator.cancel();
        animator.setDuration(10).translationX(0).translationY(0).setListener(RESET_TRANSLATION_LISTENER).start();
    }
    mSwapTargetItem = swapTargetItem;
    if (mSwapTargetItem != null) {
        ViewPropertyAnimatorCompat animator = ViewCompat.animate(mSwapTargetItem.itemView);
        animator.cancel();
    }
    mSwapTargetItemChanged = true;
}
Also used : ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat)

Example 34 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)

Example 35 with ViewPropertyAnimatorCompat

use of android.support.v4.view.ViewPropertyAnimatorCompat in project recyclerview-animators by wasabeef.

the class BaseItemAnimator 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) {
        mChangeAnimations.add(changeInfo.oldHolder);
        final ViewPropertyAnimatorCompat oldViewAnim = ViewCompat.animate(view).setDuration(getChangeDuration());
        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) {
        mChangeAnimations.add(changeInfo.newHolder);
        final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newView);
        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 : AnimateViewHolder(jp.wasabeef.recyclerview.animators.holder.AnimateViewHolder) ViewHolder(android.support.v7.widget.RecyclerView.ViewHolder) ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)46 View (android.view.View)40 RecyclerView (android.support.v7.widget.RecyclerView)33 ViewHolder (android.support.v7.widget.RecyclerView.ViewHolder)6 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)3 BezierDecelerateInterpolator (acr.browser.lightning.interpolator.BezierDecelerateInterpolator)2 ViewPropertyAnimatorListener (android.support.v4.view.ViewPropertyAnimatorListener)2 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)2 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 ViewPropertyAnimatorUpdateListener (android.support.v4.view.ViewPropertyAnimatorUpdateListener)1 AbsListView (android.widget.AbsListView)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