Merge "Prevent callbacks during DrawableContainer child initialization" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0f1ae5fa0f
@@ -500,34 +500,44 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
|||||||
* @param d The drawable to initialize.
|
* @param d The drawable to initialize.
|
||||||
*/
|
*/
|
||||||
private void initializeDrawableForDisplay(Drawable d) {
|
private void initializeDrawableForDisplay(Drawable d) {
|
||||||
if (mDrawableContainerState.mEnterFadeDuration <= 0 && mHasAlpha) {
|
// Temporary fix for suspending callbacks during initialization. We
|
||||||
d.setAlpha(mAlpha);
|
// don't want any of these setters causing an invalidate() since that
|
||||||
}
|
// may call back into DrawableContainer.
|
||||||
|
final Callback cb = d.getCallback();
|
||||||
|
d.setCallback(null);
|
||||||
|
|
||||||
if (mDrawableContainerState.mHasColorFilter) {
|
try {
|
||||||
// Color filter always overrides tint.
|
if (mDrawableContainerState.mEnterFadeDuration <= 0 && mHasAlpha) {
|
||||||
d.setColorFilter(mDrawableContainerState.mColorFilter);
|
d.setAlpha(mAlpha);
|
||||||
} else {
|
|
||||||
if (mDrawableContainerState.mHasTintList) {
|
|
||||||
d.setTintList(mDrawableContainerState.mTintList);
|
|
||||||
}
|
}
|
||||||
if (mDrawableContainerState.mHasTintMode) {
|
|
||||||
d.setTintMode(mDrawableContainerState.mTintMode);
|
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.setVisible(isVisible(), true);
|
||||||
d.setDither(mDrawableContainerState.mDither);
|
d.setDither(mDrawableContainerState.mDither);
|
||||||
d.setState(getState());
|
d.setState(getState());
|
||||||
d.setLevel(getLevel());
|
d.setLevel(getLevel());
|
||||||
d.setBounds(getBounds());
|
d.setBounds(getBounds());
|
||||||
d.setLayoutDirection(getLayoutDirection());
|
d.setLayoutDirection(getLayoutDirection());
|
||||||
d.setAutoMirrored(mDrawableContainerState.mAutoMirrored);
|
d.setAutoMirrored(mDrawableContainerState.mAutoMirrored);
|
||||||
|
|
||||||
final Rect hotspotBounds = mHotspotBounds;
|
final Rect hotspotBounds = mHotspotBounds;
|
||||||
if (hotspotBounds != null) {
|
if (hotspotBounds != null) {
|
||||||
d.setHotspotBounds(hotspotBounds.left, hotspotBounds.top,
|
d.setHotspotBounds(hotspotBounds.left, hotspotBounds.top,
|
||||||
hotspotBounds.right, hotspotBounds.bottom);
|
hotspotBounds.right, hotspotBounds.bottom);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
d.setCallback(cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user