Skip to content

Commit 362dac0

Browse files
cdotstoutAndroid (Google) Code Review
authored andcommitted
Merge "Fix NPEs when inflating a ValueAnimator." into lmp-dev
2 parents c8f3003 + 7f9988f commit 362dac0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

core/java/android/animation/AnimatorInflater.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,7 @@ public PathParser.PathDataNode[] evaluate(float fraction,
244244
}
245245

246246
/**
247-
* @param anim Null if this is a ValueAnimator, otherwise this is an
248-
* ObjectAnimator
247+
* @param anim The animator, must not be null
249248
* @param arrayAnimator Incoming typed array for Animator's attributes.
250249
* @param arrayObjectAnimator Incoming typed array for Object Animator's
251250
* attributes.
@@ -259,10 +258,6 @@ private static void parseAnimatorFromTypeArray(ValueAnimator anim,
259258
int valueType = arrayAnimator.getInt(R.styleable.Animator_valueType,
260259
VALUE_TYPE_FLOAT);
261260

262-
if (anim == null) {
263-
anim = new ValueAnimator();
264-
}
265-
266261
TypeEvaluator evaluator = null;
267262

268263
boolean getFloats = (valueType == VALUE_TYPE_FLOAT);
@@ -592,6 +587,11 @@ private static ValueAnimator loadAnimator(Resources res, Theme theme,
592587
arrayObjectAnimator = res.obtainAttributes(attrs, R.styleable.PropertyAnimator);
593588
}
594589
}
590+
591+
if (anim == null) {
592+
anim = new ValueAnimator();
593+
}
594+
595595
parseAnimatorFromTypeArray(anim, arrayAnimator, arrayObjectAnimator);
596596

597597
final int resID =
@@ -601,7 +601,9 @@ private static ValueAnimator loadAnimator(Resources res, Theme theme,
601601
}
602602

603603
arrayAnimator.recycle();
604-
arrayObjectAnimator.recycle();
604+
if (arrayObjectAnimator != null) {
605+
arrayObjectAnimator.recycle();
606+
}
605607

606608
return anim;
607609
}

0 commit comments

Comments
 (0)