Closed sheharyarn closed 9 years ago
You can add listener through:
SupportAnimator reveal = ViewAnimationUtils.createCircularReveal(view, cX, cY, 0, radius);
if(reveal.isNativeAnimator()){
ObjectAnimator a = (ObjectAnimator) reveal.get();
//TODO add listener to android.animation.ObjectAnimator
}else{
ObjectAnimator a = (ObjectAnimator) reveal.get();
//TODO add listener to nineoldandroids
}
It seems to be working on Pre-lollipop devices but doesn't work on Lollipop. I get this error:
java.lang.ClassCastException: android.animation.RevealAnimator cannot be cast to android.animation.ObjectAnimator
This is my code:
if (reveal.isNativeAnimator()) {
android.animation.ObjectAnimator a = (android.animation.ObjectAnimator) reveal.get();
a.addListener(new Animator.AnimatorListener() {
public void onAnimationCancel (Animator animation) { }
public void onAnimationRepeat (Animator animation) { }
public void onAnimationStart (Animator animation) { commonOnStartStuff(); }
public void onAnimationEnd (Animator animation) { commonOnEndStuff(); }
});
} else {
com.nineoldandroids.animation.ObjectAnimator a = (com.nineoldandroids.animation.ObjectAnimator) reveal.get();
a.addListener(new com.nineoldandroids.animation.Animator.AnimatorListener() {
public void onAnimationCancel (com.nineoldandroids.animation.Animator animation) { }
public void onAnimationRepeat (com.nineoldandroids.animation.Animator animation) { }
public void onAnimationStart (com.nineoldandroids.animation.Animator animation) { commonOnStartStuff(); }
public void onAnimationEnd (com.nineoldandroids.animation.Animator animation) { commonOnEndStuff(); }
});
}
Okay, with a little messing around, I was able to fix it. I changed ObjectAnimator
to Animator
. This is my code:
if (reveal.isNativeAnimator()) {
Animator a = (Animator) reveal.get();
a.addListener(new Animator.AnimatorListener() {
// ...
});
} else {
com.nineoldandroids.animation.ObjectAnimator a = (com.nineoldandroids.animation.ObjectAnimator) reveal.get();
a.addListener(new com.nineoldandroids.animation.Animator.AnimatorListener() {
// ...
});
}
I don't think that I should close this issue yet, I think this should be implemented within the library. Anyways, awesome lib and thanks for the quick reply!
Thanks, have you an idea to solve this problem?
Yeah, a custom implementation of `AnimatorListerner' that does this?
I'm unable to add an
AnimatorListener
to an instance of yourSupportAnimator
. On a regular Circular Reveal Animation, I just do this:There doesn't seem to be a
setListener()
oraddListener()
or anything similar.