am e260a358: am 7c3212b2: Merge "Propagate DrawableContainer state on mutate, fix ColorDrawable theming" into lmp-mr1-dev
* commit 'e260a358bfc945bf01d901f496b7f30784cbf920': Propagate DrawableContainer state on mutate, fix ColorDrawable theming
This commit is contained in:
@@ -251,6 +251,11 @@ public class ColorDrawable extends Drawable {
|
|||||||
state.mUseColor = state.mBaseColor;
|
state.mUseColor = state.mBaseColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canApplyTheme() {
|
||||||
|
return mColorState.canApplyTheme() || super.canApplyTheme();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyTheme(Theme t) {
|
public void applyTheme(Theme t) {
|
||||||
super.applyTheme(t);
|
super.applyTheme(t);
|
||||||
|
|||||||
@@ -447,36 +447,10 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
|||||||
mCurrDrawable = d;
|
mCurrDrawable = d;
|
||||||
mCurIndex = idx;
|
mCurIndex = idx;
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
d.mutate();
|
|
||||||
if (mDrawableContainerState.mEnterFadeDuration > 0) {
|
if (mDrawableContainerState.mEnterFadeDuration > 0) {
|
||||||
mEnterAnimationEnd = now + mDrawableContainerState.mEnterFadeDuration;
|
mEnterAnimationEnd = now + mDrawableContainerState.mEnterFadeDuration;
|
||||||
} else if (mHasAlpha) {
|
|
||||||
d.setAlpha(mAlpha);
|
|
||||||
}
|
|
||||||
if (mDrawableContainerState.mHasColorFilter) {
|
|
||||||
// Color filter always overrides tint.
|
|
||||||
d.setColorFilter(mDrawableContainerState.mColorFilter);
|
|
||||||
} else {
|
|
||||||
if (mDrawableContainerState.mHasTintList) {
|
|
||||||
d.setTintList(mDrawableContainerState.mTintList);
|
|
||||||
}
|
|
||||||
if (mDrawableContainerState.mHasTintMode) {
|
|
||||||
d.setTintMode(mDrawableContainerState.mTintMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
d.setVisible(isVisible(), true);
|
|
||||||
d.setDither(mDrawableContainerState.mDither);
|
|
||||||
d.setState(getState());
|
|
||||||
d.setLevel(getLevel());
|
|
||||||
d.setBounds(getBounds());
|
|
||||||
d.setLayoutDirection(getLayoutDirection());
|
|
||||||
d.setAutoMirrored(mDrawableContainerState.mAutoMirrored);
|
|
||||||
|
|
||||||
final Rect hotspotBounds = mHotspotBounds;
|
|
||||||
if (hotspotBounds != null) {
|
|
||||||
d.setHotspotBounds(hotspotBounds.left, hotspotBounds.top,
|
|
||||||
hotspotBounds.right, hotspotBounds.bottom);
|
|
||||||
}
|
}
|
||||||
|
initializeDrawableForDisplay(d);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mCurrDrawable = null;
|
mCurrDrawable = null;
|
||||||
@@ -503,6 +477,45 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes a drawable for display in this container.
|
||||||
|
*
|
||||||
|
* @param d The drawable to initialize.
|
||||||
|
*/
|
||||||
|
private void initializeDrawableForDisplay(Drawable d) {
|
||||||
|
d.mutate();
|
||||||
|
|
||||||
|
if (mDrawableContainerState.mEnterFadeDuration <= 0 && mHasAlpha) {
|
||||||
|
d.setAlpha(mAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mDrawableContainerState.mHasColorFilter) {
|
||||||
|
// Color filter always overrides tint.
|
||||||
|
d.setColorFilter(mDrawableContainerState.mColorFilter);
|
||||||
|
} else {
|
||||||
|
if (mDrawableContainerState.mHasTintList) {
|
||||||
|
d.setTintList(mDrawableContainerState.mTintList);
|
||||||
|
}
|
||||||
|
if (mDrawableContainerState.mHasTintMode) {
|
||||||
|
d.setTintMode(mDrawableContainerState.mTintMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d.setVisible(isVisible(), true);
|
||||||
|
d.setDither(mDrawableContainerState.mDither);
|
||||||
|
d.setState(getState());
|
||||||
|
d.setLevel(getLevel());
|
||||||
|
d.setBounds(getBounds());
|
||||||
|
d.setLayoutDirection(getLayoutDirection());
|
||||||
|
d.setAutoMirrored(mDrawableContainerState.mAutoMirrored);
|
||||||
|
|
||||||
|
final Rect hotspotBounds = mHotspotBounds;
|
||||||
|
if (hotspotBounds != null) {
|
||||||
|
d.setHotspotBounds(hotspotBounds.left, hotspotBounds.top,
|
||||||
|
hotspotBounds.right, hotspotBounds.bottom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void animate(boolean schedule) {
|
void animate(boolean schedule) {
|
||||||
mHasAlpha = true;
|
mHasAlpha = true;
|
||||||
|
|
||||||
@@ -1136,9 +1149,14 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
|||||||
// The locally cached drawables may have changed.
|
// The locally cached drawables may have changed.
|
||||||
if (mCurIndex >= 0) {
|
if (mCurIndex >= 0) {
|
||||||
mCurrDrawable = state.getChild(mCurIndex);
|
mCurrDrawable = state.getChild(mCurIndex);
|
||||||
|
if (mCurrDrawable != null) {
|
||||||
|
initializeDrawableForDisplay(mCurrDrawable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mLastIndex >= 0) {
|
|
||||||
mLastDrawable = state.getChild(mLastIndex);
|
// Clear out the last drawable. We don't have enough information to
|
||||||
}
|
// propagate local state from the past.
|
||||||
|
mLastIndex = -1;
|
||||||
|
mLastDrawable = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user