im trying to set an animator listener so in the end the objectanimators something happens ! Here is my code so far :
as=new AnimatorSet();
as.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
om.Initialize();
System.out.println("GotIn");
DataBase.eaten=false;
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
float distance=CalcDistance();
float angle=CalcAngle();
tongue.setPivotX(2);
tongue.setPivotY(0);
rotate_tongue=ObjectAnimator.ofFloat(tongue, "rotation",0,90+angle);
rotate_tongue.setDuration(0);
rotate_tongue.start();
tongue.setVisibility(View.VISIBLE);
scale_tongue=ObjectAnimator.ofFloat(tongue,"scaleY",1.0f,1.0f*(distance/4));
scale_tongue.setDuration(500);
shrink_tongue=ObjectAnimator.ofFloat(tongue,"scaleY",1.0f*(distance/4),1.0f);
shrink_tongue.setDuration(400);
as.play(rotate_tongue).with(scale_tongue).before(shrink_tongue);
as.start();
the problem is that the Listener doesnt actually work as nothing happens when the animatorsetend ! How to fix this ? thank you !
try this, if you still haven't figured it out in 3 years :)
as.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
// your code here
}
});
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