Example usage for android.animation Animator getListeners

List of usage examples for android.animation Animator getListeners

Introduction

In this page you can find the example usage for android.animation Animator getListeners.

Prototype

public ArrayList<AnimatorListener> getListeners() 

Source Link

Document

Gets the set of android.animation.Animator.AnimatorListener objects that are currently listening for events on this Animator object.

Usage

From source file:com.sinyuk.jianyi.utils.list.SlideInItemAnimator.java

@Override
public void runPendingAnimations() {
    super.runPendingAnimations();
    if (!pendingAdds.isEmpty()) {
        for (int i = pendingAdds.size() - 1; i >= 0; i--) {
            final RecyclerView.ViewHolder holder = pendingAdds.get(i);
            holder.itemView.animate().alpha(1f).translationX(0f).translationY(0f).setDuration(getAddDuration())
                    .setListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationStart(Animator animation) {
                            dispatchAddStarting(holder);
                        }/*from  w  w  w.ja v  a  2 s  .  c  o m*/

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            animation.getListeners().remove(this);
                            dispatchAddFinished(holder);
                            dispatchFinishedWhenDone();
                        }

                        @Override
                        public void onAnimationCancel(Animator animation) {
                            clearAnimatedValues(holder.itemView);
                        }
                    }).setInterpolator(new FastOutSlowInInterpolator());
            pendingAdds.remove(i);
        }
    }
}

From source file:de.dreier.mytargets.utils.SlideInItemAnimator.java

@Override
public void runPendingAnimations() {
    super.runPendingAnimations();
    if (!pendingAdds.isEmpty()) {
        for (int i = pendingAdds.size() - 1; i >= 0; i--) {
            final RecyclerView.ViewHolder holder = pendingAdds.get(i);
            new Handler().postDelayed(() -> holder.itemView.animate().alpha(1f).translationX(0f)
                    .translationY(0f).setDuration(getAddDuration()).setListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationStart(Animator animation) {
                            dispatchAddStarting(holder);
                        }/*w ww  .  j  a v  a2  s.com*/

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            animation.getListeners().remove(this);
                            dispatchAddFinished(holder);
                            dispatchFinishedWhenDone();
                        }

                        @Override
                        public void onAnimationCancel(Animator animation) {
                            clearAnimatedValues(holder.itemView);
                        }
                    }).setInterpolator(new LinearOutSlowInInterpolator()), holder.getAdapterPosition() * 30);
            pendingAdds.remove(i);
        }
        useDefaultAnimator = true;
    }
}