Example usage for android.support.v4.view ViewPropertyAnimatorCompat setDuration

List of usage examples for android.support.v4.view ViewPropertyAnimatorCompat setDuration

Introduction

In this page you can find the example usage for android.support.v4.view ViewPropertyAnimatorCompat setDuration.

Prototype

public ViewPropertyAnimatorCompat setDuration(long j) 

Source Link

Usage

From source file:com.mwang.irregulargridview.DynamicItemAnimator.java

private void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);/*  w  ww  .  j  a  v a2  s. co m*/
    animation.setDuration(getRemoveDuration()).alpha(0).setListener(new VpaListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchRemoveStarting(holder);
        }

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            ViewCompat.setAlpha(view, 1);
            dispatchRemoveFinished(holder);
            mRemoveAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}

From source file:com.flexible.flexibleadapter.common.FlexibleItemAnimator.java

private void animateMoveImpl(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);
    }//w  ww  . jav  a  2  s  . c  om
    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.
    mMoveAnimations.add(holder);
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    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();
}

From source file:com.mwang.irregulargridview.DynamicItemAnimator.java

private void animateMoveImpl(final RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY,
        int fromWidth, int fromHeight, int toWidth, int toHeight) {
    final View view = holder.itemView;
    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    final float scaleX = toWidth == 0 ? 1 : (float) toWidth / fromWidth;
    final float scaleY = toHeight == 0 ? 1 : (float) toHeight / fromHeight;
    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }//w  w w . java 2s  .c o  m
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }
    if (scaleX != 1) {
        ViewCompat.animate(view).scaleX(1);
    }
    if (scaleY != 1) {
        ViewCompat.animate(view).scaleY(1);
    }

    // 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);
            }
            if (scaleX != 1) {
                ViewCompat.setScaleX(view, 1);
            }
            if (scaleY != 1) {
                ViewCompat.setScaleY(view, 1);
            }
        }

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            dispatchMoveFinished(holder);
            mMoveAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}

From source file:lewa.support.v7.internal.widget.ActionBarContextView.java

private ViewPropertyAnimatorCompatSet makeInAnimation() {
    ViewCompat.setTranslationX(mClose,//www .  ja v  a2  s.  c o m
            -mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin);
    ViewPropertyAnimatorCompat buttonAnimator = ViewCompat.animate(mClose).translationX(0);
    buttonAnimator.setDuration(200);
    buttonAnimator.setListener(this);
    buttonAnimator.setInterpolator(new DecelerateInterpolator());

    ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet();
    set.play(buttonAnimator);

    if (mMenuView != null) {
        final int count = mMenuView.getChildCount();
        if (count > 0) {
            for (int i = count - 1, j = 0; i >= 0; i--, j++) {
                View child = mMenuView.getChildAt(i);
                ViewCompat.setScaleY(child, 0);
                ViewPropertyAnimatorCompat a = ViewCompat.animate(child).scaleY(1);
                a.setDuration(300);
                set.play(a);
            }
        }
    }

    ///LEWA  BEGIN
    ViewPropertyAnimatorCompat rightBbuttonAnimator = makeRightButtonInAnimation();
    if (rightBbuttonAnimator != null) {
        set.play(rightBbuttonAnimator);
    }
    ///LEWA  END
    return set;
}

From source file:lewa.support.v7.internal.widget.ActionBarContextView.java

private ViewPropertyAnimatorCompatSet makeOutAnimation() {
    ViewPropertyAnimatorCompat buttonAnimator = ViewCompat.animate(mClose)
            .translationX(-mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin);
    buttonAnimator.setDuration(200);
    buttonAnimator.setListener(this);
    buttonAnimator.setInterpolator(new DecelerateInterpolator());

    ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet();
    set.play(buttonAnimator);/* w w w  .  j  a va2  s. c o m*/

    if (mMenuView != null) {
        final int count = mMenuView.getChildCount();
        if (count > 0) {
            for (int i = 0; i < 0; i++) {
                View child = mMenuView.getChildAt(i);
                ViewCompat.setScaleY(child, 1);
                ViewPropertyAnimatorCompat a = ViewCompat.animate(child).scaleY(0);
                a.setDuration(300);
                set.play(a);
            }
        }
    }
    ///LEWA BEGIN
    ViewPropertyAnimatorCompat rightBbuttonAnimator = makeRightButtonOutAnimation();
    if (rightBbuttonAnimator != null) {
        set.play(rightBbuttonAnimator);
    }
    ///LEWA END

    return set;
}