I have the following AnimatorSet method:
private AnimatorSet dialCenterThrob() {
int bpm = workoutStream.getHeartRate();
dialCenterImageView.clearAnimation();
AnimatorSet finalSet = new AnimatorSet();
ObjectAnimator pulseX = ObjectAnimator.ofFloat(dialCenterImageView, View.SCALE_X, 0.98f, 1.06f);
ObjectAnimator pulseY = ObjectAnimator.ofFloat(dialCenterImageView, View.SCALE_Y, 0.98f, 1.06f);
pulseX.setRepeatMode(ObjectAnimator.REVERSE);
pulseX.setRepeatCount(ObjectAnimator.INFINITE);
pulseY.setRepeatMode(ObjectAnimator.REVERSE);
pulseY.setRepeatCount(ObjectAnimator.INFINITE);
pulseX.setDuration(bpm);
pulseY.setDuration(bpm);
pulseX.setInterpolator(new AccelerateInterpolator());
pulseY.setInterpolator(new AccelerateInterpolator());
finalSet.playTogether(pulseX, pulseY);
return finalSet;
}
This is set on a var, called throbber, and is occasionally updated by this method:
private void updateThrobbing() {
if (hasThrob()) {
throbber = dialCenterThrob();
throbber.start();
} else {
if (throbber != null && throbber.isRunning()) {
stopThrobbing();
}
}
}
But I cannot get it to stop animating, and here's the method that currently attempts to do so:
public void stopThrobbing() {
List<Animator> throbbers = throbber.getChildAnimations();
for(Animator animator : throbbers) {
//accomplishes nothing
((ObjectAnimator)animator).setRepeatCount(0);
((ObjectAnimator)animator).setRepeatMode(0);
}
throbber.pause(); //nothing
throbber.cancel(); //and again, nothing
throbber.end();//shocking, I know, but really, nothing
throbber = null;//you'd think this would definitely do it, but no
//desparate attempt, in vein, of course
dialCenterImageView.clearAnimation();
}
I cannot get it to stop animating. Update: I just tried storing local ref's to the individual object animators, and then calling setRepeatCount, mode, pause, end, cancel on each one, and still nothing.
clearAnimation
will have absolutely no effect here. That method clears a viewAnimation
, which is a totally different concept than objectAnimator
s. – EpicureanpulseX.setRepeatMode(ObjectAnimator.);
. Could you fix this? – Epicurean