Avoid creating futures for drawables with no constant state
We don't need to create futures for drawables without constant state, since we only copy on mutate and we don't need to do any work on mutate() for drawables without shared constant state. Also we would crash in that case, so avoiding the NPE is nice too. Rider: Also fixes elevations again. BUG: 18696100 Change-Id: I4d7737f39ce3efc5830704e5ce412c540603e6ac
This commit is contained in:
@@ -714,10 +714,17 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
||||
mDrawableFutures = new SparseArray<ConstantStateFuture>(mNumChildren);
|
||||
}
|
||||
|
||||
// Create futures for drawables with constant states. If a
|
||||
// drawable doesn't have a constant state, then we can't clone
|
||||
// it and we'll have to reference the original.
|
||||
final int N = mNumChildren;
|
||||
for (int i = 0; i < N; i++) {
|
||||
if (origDr[i] != null) {
|
||||
mDrawableFutures.put(i, new ConstantStateFuture(origDr[i]));
|
||||
if (origDr[i].getConstantState() != null) {
|
||||
mDrawableFutures.put(i, new ConstantStateFuture(origDr[i]));
|
||||
} else {
|
||||
mDrawables[i] = origDr[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user