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.
AnimationListener
is for the old style View
animations, while AnimatorListener
is for the new (as of 3.0) Animator
APIs.
All AnimatorListenerAdapter
does is implement the AnimatorListener
interface with no functionality. You can easily create your own AnimationListenerAdapter
in the same way by creating a public non-final class which implements AnimationListener
with no functionality.
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) {
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With