I know that API level 19 supports pause () and resume () for ObjectAnimators. But in my project at API level 14, I have an ObjectAnimator that is used to view an image to rotate it. I want to pause the animation provided by ObjectAnimator with a touch and resume it from where the image was (until it touches).
So, I tried to save the current playback time and cancel the object animator on my stopAnimation () function.
private void stopAnimation(){ currentTime = mGlobeAnimator.getCurrentPlayTime(); mGlobeAnimator.cancel(); }
In the startAnimation () function, I recreate the animator, set its target to the image view, set the saved playback time, and start it.
private void startAnimation(Context context, View view, float startAngle) { ObjectAnimator globeAnimatorClone = (ObjectAnimator)AnimatorInflater.loadAnimator(context, R.animator.rotate_globe); globeAnimatorClone.setTarget(mImageView); globeAnimatorClone.setCurrentPlayTime(currentTime); globeAnimatorClone.start(); }
This does not work. Will anyone help with any pause pointers and resume animations provided by the animator for API level up to 19?
source share