Merge change 8218 into donut

* changes:
  DrawableContainer was not respecting the value returned by Drawable.getPadding(Rect).
This commit is contained in:
Android (Google) Code Review
2009-07-22 11:49:20 -07:00

View File

@@ -272,6 +272,8 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
boolean mCheckedConstantState;
boolean mCanConstantState;
boolean mPaddingChecked = false;
DrawableContainerState(DrawableContainerState orig, DrawableContainer owner) {
mOwner = owner;
@@ -334,6 +336,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
mHaveStateful = false;
mConstantPadding = null;
mPaddingChecked = false;
mComputedConstantSize = false;
return pos;
@@ -359,23 +362,25 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
if (mVariablePadding) {
return null;
}
if (mConstantPadding != null) {
if (mConstantPadding != null || mPaddingChecked) {
return mConstantPadding;
}
final Rect r = new Rect(0, 0, 0, 0);
Rect r = null;
final Rect t = new Rect();
final int N = getChildCount();
final Drawable[] drawables = mDrawables;
for (int i = 0; i < N; i++) {
if (drawables[i].getPadding(t)) {
if (r == null) r = new Rect(0, 0, 0, 0);
if (t.left > r.left) r.left = t.left;
if (t.top > r.top) r.top = t.top;
if (t.right > r.right) r.right = t.right;
if (t.bottom > r.bottom) r.bottom = t.bottom;
}
}
return (mConstantPadding=r);
mPaddingChecked = true;
return (mConstantPadding = r);
}
public final void setConstantSize(boolean constant) {