Fix NPE in ValueAnimator
- Reset mAnimationEndRequested to false in ValueAnimator#start(boolean)
so that previously canceled animated (with a start delay) can be
canceled again.
- In ObjectAnimator#animateValue(float) check if target == null
regardless of mTarget == null since it's possible the target was
explicitly set to null prior to the animator being cancelled.
Bug: 30190459
Change-Id: I6da55737df30a28f48355fc7a41ab91d05979deb
diff --git a/core/java/android/animation/ObjectAnimator.java b/core/java/android/animation/ObjectAnimator.java
index 5c4b979..9a2aa30 100644
--- a/core/java/android/animation/ObjectAnimator.java
+++ b/core/java/android/animation/ObjectAnimator.java
@@ -977,7 +977,7 @@
@Override
void animateValue(float fraction) {
final Object target = getTarget();
- if (mTarget != null && target == null) {
+ if (target == null) {
// We lost the target reference, cancel and clean up.
cancel();
return;
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index 0c7ee2c..e3f8fa4 100644
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -982,6 +982,7 @@
mStarted = true;
mPaused = false;
mRunning = false;
+ mAnimationEndRequested = false;
// Resets mLastFrameTime when start() is called, so that if the animation was running,
// calling start() would put the animation in the
// started-but-not-yet-reached-the-first-frame phase.