diff options
author | 2016-06-23 10:34:17 -0700 | |
---|---|---|
committer | 2016-06-24 00:01:39 +0000 | |
commit | c470466d7c89b55d8c5a13d79076fa2f8d624da1 (patch) | |
tree | 0217a6def380ef1817fdf91a6f279c6801277d12 | |
parent | 33657640ec420968dd97e68bbe84556fbdb86d87 (diff) |
Fix NPE for checking for whether animators should play together
BUG: 29586505
Change-Id: Ic2a67d51d2ac8d5bfb11ed7773c7c7e413cc28c7
-rw-r--r-- | core/java/android/animation/AnimatorSet.java | 6 | ||||
-rw-r--r-- | libs/hwui/PropertyValuesAnimatorSet.cpp | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/core/java/android/animation/AnimatorSet.java b/core/java/android/animation/AnimatorSet.java index 7841d29b5700..053ba7d5fa0a 100644 --- a/core/java/android/animation/AnimatorSet.java +++ b/core/java/android/animation/AnimatorSet.java @@ -1064,15 +1064,15 @@ public final class AnimatorSet extends Animator { /** * @hide * TODO: For animatorSet defined in XML, we can use a flag to indicate what the play order - * if defined (i.e. sequential or together), then we can use the flag instead of calculate - * dynamically. + * if defined (i.e. sequential or together), then we can use the flag instead of calculating + * dynamically. Note that when AnimatorSet is empty this method returns true. * @return whether all the animators in the set are supposed to play together */ public boolean shouldPlayTogether() { updateAnimatorsDuration(); createDependencyGraph(); // All the child nodes are set out to play right after the delay animation - return mRootNode.mChildNodes.size() == mNodes.size() - 1; + return mRootNode.mChildNodes == null || mRootNode.mChildNodes.size() == mNodes.size() - 1; } @Override diff --git a/libs/hwui/PropertyValuesAnimatorSet.cpp b/libs/hwui/PropertyValuesAnimatorSet.cpp index e416e0c0061d..796c73b9c3e7 100644 --- a/libs/hwui/PropertyValuesAnimatorSet.cpp +++ b/libs/hwui/PropertyValuesAnimatorSet.cpp @@ -29,7 +29,6 @@ void PropertyValuesAnimatorSet::addPropertyAnimator(PropertyValuesHolder* proper PropertyAnimator* animator = new PropertyAnimator(propertyValuesHolder, interpolator, startDelay, duration, repeatCount); mAnimators.emplace_back(animator); - setListener(new PropertyAnimatorSetListener(this)); // Check whether any child animator is infinite after adding it them to the set. if (repeatCount == -1) { @@ -42,6 +41,7 @@ PropertyValuesAnimatorSet::PropertyValuesAnimatorSet() setStartValue(0); mLastFraction = 0.0f; setInterpolator(new LinearInterpolator()); + setListener(new PropertyAnimatorSetListener(this)); } void PropertyValuesAnimatorSet::onFinished(BaseRenderNodeAnimator* animator) { @@ -115,7 +115,7 @@ void PropertyValuesAnimatorSet::init() { std::sort(mAnimators.begin(), mAnimators.end(), [](auto& a, auto&b) { return a->getTotalDuration() < b->getTotalDuration(); }); - mDuration = mAnimators[mAnimators.size() - 1]->getTotalDuration(); + mDuration = mAnimators.empty() ? 0 : mAnimators[mAnimators.size() - 1]->getTotalDuration(); mInitialized = true; } |