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

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

Introduction

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

Prototype

public ViewPropertyAnimatorCompat setListener(ViewPropertyAnimatorListener viewPropertyAnimatorListener) 

Source Link

Usage

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

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

    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);// w w w  .  j a v  a  2 s.co  m
    animation.scaleX(1).scaleY(1).translationX(0).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);
                    ViewCompat.setTranslationX(view, 0);
                    ViewCompat.setScaleX(view, 1);
                    ViewCompat.setScaleY(view, 1);
                }

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

}

From source file:com.example.recycleviewexample.ScaleInItemAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    ViewCompat.setPivotX(view, view.getWidth());
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    animation.setDuration(getRemoveDuration()).scaleX(0).setListener(new VpaListenerAdapter() {
        @Override/*from  w w w  .java 2  s. c o m*/
        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();
    mRemoveAnimations.add(holder);
}

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

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    animation.setDuration(getRemoveDuration()).alpha(0).setListener(new VpaListenerAdapter() {
        @Override//w ww.  j a v  a  2  s  .  c  o m
        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();
    mRemoveAnimations.add(holder);
}

From source file:com.example.administrator.demorecyler.MyItemAnimator.java

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

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

From source file:com.fanyafeng.testijkplayer.view.MyItemAnimator.java

private void animateChangeImpl(final ChangeInfo changeInfo) {
    final ViewHolder holder = changeInfo.oldHolder;
    final View view = holder == null ? null : holder.itemView;
    final ViewHolder newHolder = changeInfo.newHolder;
    final View newView = newHolder != null ? newHolder.itemView : null;
    if (view != null) {
        final ViewPropertyAnimatorCompat oldViewAnim = ViewCompat.animate(view)
                .setDuration(getChangeDuration());
        mChangeAnimations.add(changeInfo.oldHolder);
        oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
        oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
        oldViewAnim.
        //                    todo  
        //                    alpha(0).
                setListener(new VpaListenerAdapter() {
                    @Override//from w  ww .  j ava  2s  . c  o m
                    public void onAnimationStart(View view) {
                        dispatchChangeStarting(changeInfo.oldHolder, true);
                    }

                    @Override
                    public void onAnimationEnd(View view) {
                        oldViewAnim.setListener(null);
                        ViewCompat.setAlpha(view, 1);
                        ViewCompat.setTranslationX(view, 0);
                        ViewCompat.setTranslationY(view, 0);
                        dispatchChangeFinished(changeInfo.oldHolder, true);
                        mChangeAnimations.remove(changeInfo.oldHolder);
                        dispatchFinishedWhenDone();
                    }
                }).start();
    }
    if (newView != null) {
        final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newView);
        mChangeAnimations.add(changeInfo.newHolder);
        newViewAnimation.translationX(0).translationY(0).setDuration(getChangeDuration()).
        //                    todo 
        //                    alpha(1).
                setListener(new VpaListenerAdapter() {
                    @Override
                    public void onAnimationStart(View view) {
                        dispatchChangeStarting(changeInfo.newHolder, false);
                    }

                    @Override
                    public void onAnimationEnd(View view) {
                        newViewAnimation.setListener(null);
                        ViewCompat.setAlpha(newView, 1);
                        ViewCompat.setTranslationX(newView, 0);
                        ViewCompat.setTranslationY(newView, 0);
                        dispatchChangeFinished(changeInfo.newHolder, false);
                        mChangeAnimations.remove(changeInfo.newHolder);
                        dispatchFinishedWhenDone();
                    }
                }).start();
    }
}

From source file:net.simonvt.cathode.widget.ScalingItemAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    animation.setDuration(getRemoveDuration()).alpha(0).scaleY(0.5f).setListener(new VpaListenerAdapter() {
        @Override// w w  w .  ja  v a2 s . co  m
        public void onAnimationStart(View view) {
            dispatchRemoveStarting(holder);
        }

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

From source file:com.google.smartcity.ui.animation.RvItemAnimator.java

void animateChangeImpl(final ChangeInfo changeInfo) {
    final ViewHolder holder = changeInfo.oldHolder;
    final View view = holder == null ? null : holder.itemView;
    final ViewHolder newHolder = changeInfo.newHolder;
    final View newView = newHolder != null ? newHolder.itemView : null;
    if (view != null) {
        final ViewPropertyAnimatorCompat oldViewAnim = ViewCompat.animate(view)
                .setDuration(getChangeDuration());
        mChangeAnimations.add(changeInfo.oldHolder);
        oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
        oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
        oldViewAnim.setListener(new VpaListenerAdapter() {
            @Override/*from w ww . j  ava2 s.c  o m*/
            public void onAnimationStart(View view) {
                dispatchChangeStarting(changeInfo.oldHolder, true);
            }

            @Override
            public void onAnimationEnd(View view) {
                oldViewAnim.setListener(null);
                ViewCompat.setAlpha(view, 1);
                ViewCompat.setTranslationX(view, 0);
                ViewCompat.setTranslationY(view, 0);
                dispatchChangeFinished(changeInfo.oldHolder, true);
                mChangeAnimations.remove(changeInfo.oldHolder);
                dispatchFinishedWhenDone();
            }
        }).start();
    }
    if (newView != null) {
        final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newView);
        mChangeAnimations.add(changeInfo.newHolder);
        newViewAnimation.translationX(0).translationY(0).setDuration(getChangeDuration())
                .setListener(new VpaListenerAdapter() {
                    @Override
                    public void onAnimationStart(View view) {
                        dispatchChangeStarting(changeInfo.newHolder, false);
                    }

                    @Override
                    public void onAnimationEnd(View view) {
                        newViewAnimation.setListener(null);
                        ViewCompat.setAlpha(newView, 1);
                        ViewCompat.setTranslationX(newView, 0);
                        ViewCompat.setTranslationY(newView, 0);
                        dispatchChangeFinished(changeInfo.newHolder, false);
                        mChangeAnimations.remove(changeInfo.newHolder);
                        dispatchFinishedWhenDone();
                    }
                }).start();
    }
}

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 .j  a  v a  2 s  .  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.hippo.nimingban.itemanimator.FloatItemAnimator.java

private void animateAddImpl(final RecyclerView.ViewHolder holder, float translationY) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);

    view.setVisibility(View.VISIBLE);
    mAddAnimations.add(holder);/*from  w w w . j a  va 2s  . com*/
    view.setTranslationY(translationY);
    animation.translationY(0.0f).setDuration((long) (translationY / SPEED))
            .setInterpolator(AnimationUtils2.FAST_SLOW_INTERPOLATOR).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:io.apptik.multiview.animators.FlexiItemAnimator.java

@Override
protected void animateAddImpl(final RecyclerView.ViewHolder holder) {
    if (vpaAdd == null) {
        resetView(holder.itemView);/*from   w  w w . j  av  a  2  s  .  c  om*/
        dispatchAddFinished(holder);
        dispatchFinishedWhenDone();
        return;
    }
    mAddAnimations.add(holder);

    Runnable beforeAction = vpaAdd.getBeforeAction(holder);
    if (beforeAction != null) {
        beforeAction.run();
    }
    final ViewPropertyAnimatorCompat animation = vpaAdd.getAnim(holder);
    if (ipAdd != null) {
        animation.setInterpolator(ipAdd);
    }
    animation.setDuration(getAddDuration()).setListener(new VoidVpaListener() {
        @Override
        public void onAnimationStart(View view) {
            Log.v("start add anim: " + view);
            dispatchAddStarting(holder);
        }

        @Override
        public void onAnimationCancel(View view) {
            Log.v("cancel add anim: " + view);
            resetView(view);
        }

        @Override
        public void onAnimationEnd(View view) {
            Log.v("end add anim: " + view);
            animation.setListener(null);
            resetView(view);
            dispatchAddFinished(holder);
            mAddAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}