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.cs.test_recycview3.MyAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);/*from   ww w  . j  a  va2s. c o m*/
    animation.setDuration(getRemoveDuration()).translationX(view.getWidth() / 2)
            .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.bwie.myrecyclerviewdemo1.MyitemAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);/*from  ww  w. j  a v a 2s. co  m*/
    animation.setDuration(getRemoveDuration()).translationX(view.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, 0);
                    dispatchRemoveFinished(holder);
                    mRemoveAnimations.remove(holder);
                    dispatchFinishedWhenDone();
                }
            }).start();
}

From source file:com.hanbing.library.android.view.recycler.animator.BaseItemAnimator.java

protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);//w  w w.ja  v a  2  s. c  om

    animation.setDuration(getRemoveDuration()).setListener(new VpaListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchRemoveStarting(holder);
        }

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            afterAnimateRemove(holder);
            dispatchRemoveFinished(holder);
            mRemoveAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    });
    actAnimateRemove(holder, animation);

}

From source file:com.example.lulu.recyclerviewdemo.MyItemAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    //?/*from  w  w w  .  j  a  v a  2s.c o m*/
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);
    animation.setDuration(getRemoveDuration()).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.hanbing.library.android.view.recycler.animator.BaseItemAnimator.java

protected void animateAddImpl(final RecyclerView.ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);/*from  w ww  . ja  v  a 2  s  . c o  m*/

    animation.setDuration(getAddDuration()).setListener(new VpaListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchAddStarting(holder);
        }

        @Override
        public void onAnimationCancel(View view) {
            afterAnimateAdd(holder);
        }

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

    actAnimateAdd(holder, animation);
}

From source file:com.example.recyclerview.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  a2s  . c  o m
    animation.setDuration(getRemoveDuration()).alpha(0).translationX(view.getWidth() / 2)
            .setListener(new VpaListenerAdapter() {
                @Override
                public void onAnimationStart(View view) {
                    dispatchRemoveStarting(holder);
                }

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

From source file:practice.gaolei.textrecyclerview.MyItemAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    ///*from www  .jav  a  2s . c o  m*/
    final View view = holder.itemView;
    //?
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);
    animation.setDuration(getRemoveDuration()).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:android.room.play.com.nasadaily.animators.BaseItemAnimator.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);
    }//from  ww w.ja va  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.chenli.recycler.MyItemAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);//from   ww  w.j  ava 2  s .co m
    animation.setDuration(getRemoveDuration())//
            .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:net.nym.napply.library.recycler.BaseItemAnimator.java

private void animateAddImpl(final RecyclerView.ViewHolder holder) {
    final ViewPropertyAnimatorCompat animation = getAddAnimator(holder);
    mAddAnimations.add(holder);/*from ww  w  . java2 s  .c  o  m*/
    animation.setDuration(getAddDuration()).setListener(new VpaListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            ViewCompat.setAlpha(view, 1);
            dispatchAddStarting(holder);
        }

        @Override
        public void onAnimationCancel(View view) {
            clear(view);
        }

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