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.twotoasters.jazzylistview.effects.FadeEffect.java

@Override
public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimatorCompat animator) {
    animator.setDuration(JazzyHelper.DURATION * DURATION_MULTIPLIER).alpha(JazzyHelper.OPAQUE);
}

From source file:aloha.shiningstarbase.util.itemanimator.SlideInOutRightItemAnimator.java

protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);//from   ww w  .j  a  va  2s .c o  m
    animation.setDuration(getRemoveDuration()).alpha(0)
            .translationX(+mRecyclerView.getLayoutManager().getWidth()).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.setTranslationX(view, +mRecyclerView.getLayoutManager().getWidth());
                    dispatchRemoveFinished(holder);
                    mRemoveAnimations.remove(holder);
                    dispatchFinishedWhenDone();
                }
            }).start();
}

From source file:aloha.shiningstarbase.util.itemanimator.SlideInOutLeftItemAnimator.java

protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);//w ww. j av  a2 s . com
    animation.setDuration(getRemoveDuration()).alpha(0)
            .translationX(-mRecyclerView.getLayoutManager().getWidth()).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.setTranslationX(view, -mRecyclerView.getLayoutManager().getWidth());
                    dispatchRemoveFinished(holder);
                    mRemoveAnimations.remove(holder);
                    dispatchFinishedWhenDone();
                }
            }).start();
}

From source file:aloha.shiningstarbase.util.itemanimator.SlideInOutTopItemAnimator.java

protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;
    retrieveItemHeight(holder);//  ww  w.  j  a v a  2s  .c o m
    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();
}

From source file:aloha.shiningstarbase.util.itemanimator.SlideInOutBottomItemAnimator.java

protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;

    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);//from   www .ja v a  2 s  . com
    animation.setDuration(getRemoveDuration()).alpha(0).translationY(+mDeltaY)
            .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, +mDeltaY);
                    dispatchRemoveFinished(holder);
                    mRemoveAnimations.remove(holder);
                    dispatchFinishedWhenDone();
                }
            }).start();
}

From source file:aloha.shiningstarbase.util.itemanimator.ScaleInOutItemAnimator.java

protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);/*from  w w w  .  j  a va2s .  c o m*/
    animation.setDuration(getRemoveDuration()).alpha(0).scaleX(0).scaleY(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);
                    ViewCompat.setScaleX(view, 0);
                    ViewCompat.setScaleY(view, 0);
                    dispatchRemoveFinished(holder);
                    mRemoveAnimations.remove(holder);
                    dispatchFinishedWhenDone();
                }
            }).start();
}

From source file:android.support.v7.internal.view.ViewPropertyAnimatorCompatSet.java

public void start() {
    if (mIsStarted)
        return;/*from ww  w  .  ja  v  a2s .c  o  m*/
    for (ViewPropertyAnimatorCompat animator : mAnimators) {
        if (mDuration >= 0) {
            animator.setDuration(mDuration);
        }
        if (mInterpolator != null) {
            animator.setInterpolator(mInterpolator);
        }
        if (mListener != null) {
            animator.setListener(mProxyListener);
        }
        animator.start();
    }

    mIsStarted = true;
}

From source file:aloha.shiningstarbase.util.itemanimator.SlideScaleInOutRightItemAnimator.java

protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;

    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);//from w w w  .j  av a  2s.  c  o m
    animation.setDuration(getRemoveDuration()).scaleX(0).scaleY(0).alpha(0)
            .translationX(+mRecyclerView.getLayoutManager().getWidth()).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.setScaleX(view, 0);
                    ViewCompat.setScaleY(view, 0);
                    ViewCompat.setTranslationX(view, +mRecyclerView.getLayoutManager().getWidth());
                    dispatchRemoveFinished(holder);
                    mRemoveAnimations.remove(holder);
                    dispatchFinishedWhenDone();
                }
            }).start();

}

From source file:vc908.stickerfactory.ui.advancedrecyclerview.draggable.BaseDraggableItemDecorator.java

protected void moveToDefaultPosition(View targetView, boolean animate) {
    final int curTranslationY = (int) (ViewCompat.getTranslationY(targetView));
    final int halfItemHeight = targetView.getHeight() / 2;
    final float translationProportion = (halfItemHeight > 0)
            ? Math.abs((float) curTranslationY / halfItemHeight)
            : 0;/*from ww  w .  ja v a2 s.c om*/
    final float t = 1.0f - Math.min(translationProportion, 1.0f);
    final int animDuration = (int) (mReturnToDefaultPositionDuration * (1.0f - (t * t)) + 0.5f);

    if (supportsViewPropertyAnimation() && animate
            && (animDuration > RETURN_TO_DEFAULT_POS_ANIMATE_THRESHOLD_MSEC)
            && (Math.abs(curTranslationY) > mReturnToDefaultPositionAnimateThreshold)) {
        final ViewPropertyAnimatorCompat animator = ViewCompat.animate(targetView);
        animator.cancel();
        animator.setDuration(animDuration);
        animator.setInterpolator(mReturnToDefaultPositionInterpolator);
        animator.translationY(0.0f);
        animator.setListener(new ViewPropertyAnimatorListener() {
            @Override
            public void onAnimationStart(View view) {
            }

            @Override
            public void onAnimationEnd(View view) {
                animator.setListener(null);
                ViewCompat.setTranslationY(view, 0);

                // invalidate explicitly to refresh other decorations
                if (view.getParent() instanceof RecyclerView) {
                    ViewCompat.postInvalidateOnAnimation((RecyclerView) view.getParent());
                }
            }

            @Override
            public void onAnimationCancel(View view) {
            }
        });
        animator.start();
    } else {
        ViewCompat.setTranslationY(targetView, 0);
    }
}

From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.draggable.BaseDraggableItemDecorator.java

protected void moveToDefaultPosition(View targetView, boolean animate) {
    final int curTranslationX = (int) (ViewCompat.getTranslationX(targetView));
    final int curTranslationY = (int) (ViewCompat.getTranslationY(targetView));
    final int halfItemWidth = targetView.getWidth() / 2;
    final int halfItemHeight = targetView.getHeight() / 2;
    final float translationProportionX = (halfItemWidth > 0) ? Math.abs((float) curTranslationX / halfItemWidth)
            : 0;//www. ja  va2s .c om
    final float translationProportionY = (halfItemHeight > 0)
            ? Math.abs((float) curTranslationY / halfItemHeight)
            : 0;
    final float tx = 1.0f - Math.min(translationProportionX, 1.0f);
    final float ty = 1.0f - Math.min(translationProportionY, 1.0f);
    final int animDurationX = (int) (mReturnToDefaultPositionDuration * (1.0f - (tx * tx)) + 0.5f);
    final int animDurationY = (int) (mReturnToDefaultPositionDuration * (1.0f - (ty * ty)) + 0.5f);
    final int animDuration = Math.max(animDurationX, animDurationY);
    final int maxAbsTranslation = Math.max(Math.abs(curTranslationX), Math.abs(curTranslationY));

    if (supportsViewPropertyAnimation() && animate
            && (animDuration > RETURN_TO_DEFAULT_POS_ANIMATE_THRESHOLD_MSEC)
            && (maxAbsTranslation > mReturnToDefaultPositionAnimateThreshold)) {
        final ViewPropertyAnimatorCompat animator = ViewCompat.animate(targetView);
        animator.cancel();
        animator.setDuration(animDuration);
        animator.setInterpolator(mReturnToDefaultPositionInterpolator);
        animator.translationX(0.0f);
        animator.translationY(0.0f);
        animator.setListener(new ViewPropertyAnimatorListener() {
            @Override
            public void onAnimationStart(View view) {
            }

            @Override
            public void onAnimationEnd(View view) {
                animator.setListener(null);
                ViewCompat.setTranslationX(view, 0);
                ViewCompat.setTranslationY(view, 0);

                // invalidate explicitly to refresh other decorations
                if (view.getParent() instanceof RecyclerView) {
                    ViewCompat.postInvalidateOnAnimation((RecyclerView) view.getParent());
                }
            }

            @Override
            public void onAnimationCancel(View view) {
            }
        });
        animator.start();
    } else {
        ViewCompat.setTranslationX(targetView, 0);
        ViewCompat.setTranslationY(targetView, 0);
    }
}