Update preload list, clean up drawable theming

Removes all implementations of three-arg ConstantState constructor, since
we handle mutation and applyTheme() in Resources now. Moves progress bar
tinting to android:tint attribute. Correctly implements applyTheme() and
canApplyTheme() in all drawable wrapper and container classes.

Change-Id: Ic9cb43d0d6228aa4914f3124bed234b837beaa41
This commit is contained in:
Alan Viverette
2014-10-14 14:07:21 -07:00
parent 2f82e48abb
commit 17cd4dfe3a
22 changed files with 333 additions and 402 deletions

View File

@@ -170,24 +170,30 @@ public class InsetDrawable extends Drawable implements Drawable.Callback {
super.applyTheme(t);
final InsetState state = mInsetState;
if (state == null || state.mThemeAttrs == null) {
if (state == null) {
return;
}
final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.InsetDrawable);
try {
updateStateFromTypedArray(a);
verifyRequiredAttributes(a);
} catch (XmlPullParserException e) {
throw new RuntimeException(e);
} finally {
a.recycle();
if (state.mThemeAttrs != null) {
final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.InsetDrawable);
try {
updateStateFromTypedArray(a);
verifyRequiredAttributes(a);
} catch (XmlPullParserException e) {
throw new RuntimeException(e);
} finally {
a.recycle();
}
}
if (state.mDrawable != null && state.mDrawable.canApplyTheme()) {
state.mDrawable.applyTheme(t);
}
}
@Override
public boolean canApplyTheme() {
return mInsetState != null && mInsetState.mThemeAttrs != null;
return super.canApplyTheme() || mInsetState != null && mInsetState.canApplyTheme();
}
@Override
@@ -438,6 +444,12 @@ public class InsetDrawable extends Drawable implements Drawable.Callback {
return mChangingConfigurations;
}
@Override
public boolean canApplyTheme() {
return super.canApplyTheme() || mThemeAttrs != null
|| mDrawable != null && mDrawable.canApplyTheme();
}
boolean canConstantState() {
if (!mCheckedConstantState) {
mCanConstantState = mDrawable.getConstantState() != null;