What is the difference between AnimationListener and AnimatorListener?

Viewed 2523

I would like to use the AnimatorListenerAdapter, specified here:

http://developer.android.com/reference/android/animation/AnimatorListenerAdapter.html

But, it implements the AnimatorListener interface. On a View, such as an ImageView, there is a method called setAnimationListener(), but it takes, as a parameter, an AnimationListener. There doesn't seem to be an associated AnimationListenerAdapter available.

My question is what is the difference between AnimatorListener and AnimationListener, and why do the two separate interfaces exist? It seems like they both provide the same functionality. The only difference I can see is that one of them was introduced in a later API version.

2 Answers

For lazy people as us :

import android.view.animation.Animation

/**
 * Adapter to reduce code implementation of Animation.AnimationListener when there are unused
 * functions.
 */
open class AnimationListenerAdapter: Animation.AnimationListener {

    /**
     *
     * Notifies the start of the animation.
     *
     * @param animation The started animation.
     */
    override fun onAnimationStart(animation: Animation) {

    }

    /**
     *
     * Notifies the end of the animation. This callback is not invoked
     * for animations with repeat count set to INFINITE.
     *
     * @param animation The animation which reached its end.
     */
    override fun onAnimationEnd(animation: Animation) {

    }

    /**
     *
     * Notifies the repetition of the animation.
     *
     * @param animation The animation which was repeated.
     */
    override fun onAnimationRepeat(animation: Animation) {

    }

}

Related