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.ccb.myrecyclerview.CustomItemAnimator.java

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

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

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

            }).start();

    mRemoveAnimations.add(holder);
}

From source file:com.multilevelview.animators.DefaultItemAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);//from  w  w  w.ja  v a  2s .  co m
    animation.setDuration(getRemoveDuration()).alpha(1).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.wl.mobail.day06_lollipopdemo.MyItemAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);/*from  w ww .  j  av  a  2 s .  com*/
    animation.setDuration(getRemoveDuration()).rotationBy(720).scaleX(0).scaleY(0)
            .setListener(new VpaListenerAdapter() {
                @Override
                public void onAnimationStart(View view) {
                    dispatchRemoveStarting(holder);
                }

                @Override
                public void onAnimationEnd(View view) {
                    animation.setListener(null);
                    //????  X?Y?
                    ViewCompat.setRotation(view, 0);
                    ViewCompat.setScaleX(view, 1);
                    ViewCompat.setScaleY(view, 1);
                    dispatchRemoveFinished(holder);
                    mRemoveAnimations.remove(holder);
                    dispatchFinishedWhenDone();
                }
            }).start();
}

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

private void animateMoveImpl(final RecyclerView.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  w  w  .  ja  va  2 s.  c  o m*/
    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();
}

From source file:com.huihui.android_recyclerview.MyItemAnimator.java

/**
 * //from w  ww .  ja  v  a  2 s .c o m
 * @param holder
 */
private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);
    animation.setDuration(getRemoveDuration()).rotationBy(720).translationX(view.getWidth())
            .setListener(new VpaListenerAdapter() {
                @Override
                public void onAnimationStart(View view) {
                    dispatchRemoveStarting(holder);
                }

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

From source file:com.lqr.recyclerview.LQRDefaultItemAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);/* ww  w  . jav a2 s  . com*/
    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.lqr.recyclerview.LQRDefaultItemAnimator.java

void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);//w  ww.j  a va 2 s  . c  o  m
    animation
            //                .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);
                }

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

From source file:com.lebron.imagebrowse.anim.MyItemAnimator.java

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

From source file:android.support.v7.widget.CustomItemAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);/* w  ww . j a  v a 2s. c om*/
    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:www.weimu.io.rxproject.ui.adapter.base.itemanimation.NoAlphaItemAnimator.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 w  w.  j a va 2s  .c  o  m*/
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }
    // 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();
}