Search in sources :

Example 11 with ViewPropertyAnimatorCompat

use of androidx.core.view.ViewPropertyAnimatorCompat in project Lightning-Browser by anthonycr.

the class VerticalItemAnimator method animateAddImpl.

private void animateAddImpl(@NonNull final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);
    animation.alpha(1).translationX(0).setDuration(getAddDuration()).setInterpolator(new BezierDecelerateInterpolator()).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);
        }

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            dispatchAddFinished(holder);
            mAddAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}
Also used : BezierDecelerateInterpolator(acr.browser.lightning.interpolator.BezierDecelerateInterpolator) ViewPropertyAnimatorCompat(androidx.core.view.ViewPropertyAnimatorCompat) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 12 with ViewPropertyAnimatorCompat

use of androidx.core.view.ViewPropertyAnimatorCompat in project Lightning-Browser by anthonycr.

the class VerticalItemAnimator method animateMoveImpl.

private void animateMoveImpl(@NonNull final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    final View view = holder.itemView;
    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }
    // TODO: make EndActions end listeners instead, since end actions aren't called when
    // vpas are canceled (and can't end them. why?)
    // need listener functionality in VPACompat for this. Ick.
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mMoveAnimations.add(holder);
    animation.setDuration(getMoveDuration()).setListener(new VpaListenerAdapter() {

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

        @Override
        public void onAnimationCancel(View view) {
            if (deltaX != 0) {
                ViewCompat.setTranslationX(view, 0);
            }
            if (deltaY != 0) {
                ViewCompat.setTranslationY(view, 0);
            }
        }

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            dispatchMoveFinished(holder);
            mMoveAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}
Also used : ViewPropertyAnimatorCompat(androidx.core.view.ViewPropertyAnimatorCompat) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

ViewPropertyAnimatorCompat (androidx.core.view.ViewPropertyAnimatorCompat)12 View (android.view.View)11 RecyclerView (androidx.recyclerview.widget.RecyclerView)10 ViewHolder (androidx.recyclerview.widget.RecyclerView.ViewHolder)3 BezierDecelerateInterpolator (acr.browser.lightning.interpolator.BezierDecelerateInterpolator)2 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)2 TextView (android.widget.TextView)2 ViewPropertyAnimatorListener (androidx.core.view.ViewPropertyAnimatorListener)1 AnimatedViewHolder (eu.davidea.viewholders.AnimatedViewHolder)1