Methods Summary |
---|
public void | applyTheme(android.content.res.Resources.Theme t)
super.applyTheme(t);
final InsetState state = mState;
if (state == null) {
return;
}
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);
}
|
public boolean | canApplyTheme()
return (mState != null && mState.canApplyTheme()) || super.canApplyTheme();
|
public void | clearMutated()
super.clearMutated();
mState.mDrawable.clearMutated();
mMutated = false;
|
public void | draw(android.graphics.Canvas canvas)
mState.mDrawable.draw(canvas);
|
public int | getAlpha()
return mState.mDrawable.getAlpha();
|
public int | getChangingConfigurations()
return super.getChangingConfigurations()
| mState.mChangingConfigurations
| mState.mDrawable.getChangingConfigurations();
|
public android.graphics.drawable.Drawable.ConstantState | getConstantState()
if (mState.canConstantState()) {
mState.mChangingConfigurations = getChangingConfigurations();
return mState;
}
return null;
|
public Drawable | getDrawable()Returns the drawable wrapped by this InsetDrawable. May be null.
return mState.mDrawable;
|
public void | getHotspotBounds(android.graphics.Rect outRect)
mState.mDrawable.getHotspotBounds(outRect);
|
public int | getIntrinsicHeight()
return mState.mDrawable.getIntrinsicHeight()
+ mState.mInsetTop + mState.mInsetBottom;
|
public int | getIntrinsicWidth()
return mState.mDrawable.getIntrinsicWidth()
+ mState.mInsetLeft + mState.mInsetRight;
|
public int | getOpacity()
final InsetState state = mState;
final int opacity = state.mDrawable.getOpacity();
if (opacity == PixelFormat.OPAQUE && (state.mInsetLeft > 0 || state.mInsetTop > 0
|| state.mInsetRight > 0 || state.mInsetBottom > 0)) {
return PixelFormat.TRANSLUCENT;
}
return opacity;
|
public android.graphics.Insets | getOpticalInsets()
final Insets contentInsets = super.getOpticalInsets();
return Insets.of(contentInsets.left + mState.mInsetLeft,
contentInsets.top + mState.mInsetTop,
contentInsets.right + mState.mInsetRight,
contentInsets.bottom + mState.mInsetBottom);
|
public void | getOutline(android.graphics.Outline outline)
mState.mDrawable.getOutline(outline);
|
public boolean | getPadding(android.graphics.Rect padding)
boolean pad = mState.mDrawable.getPadding(padding);
padding.left += mState.mInsetLeft;
padding.right += mState.mInsetRight;
padding.top += mState.mInsetTop;
padding.bottom += mState.mInsetBottom;
return pad || (mState.mInsetLeft | mState.mInsetRight |
mState.mInsetTop | mState.mInsetBottom) != 0;
|
public void | inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs, android.content.res.Resources.Theme theme)
final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.InsetDrawable);
super.inflateWithAttributes(r, parser, a, R.styleable.InsetDrawable_visible);
// Reset mDrawable to preserve old multiple-inflate behavior. This is
// silly, but we have CTS tests that rely on it.
mState.mDrawable = null;
updateStateFromTypedArray(a);
inflateChildElements(r, parser, attrs, theme);
verifyRequiredAttributes(a);
a.recycle();
|
private void | inflateChildElements(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs, android.content.res.Resources.Theme theme)
// Load inner XML elements.
if (mState.mDrawable == null) {
int type;
while ((type=parser.next()) == XmlPullParser.TEXT) {
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException(
parser.getPositionDescription()
+ ": <inset> tag requires a 'drawable' attribute or "
+ "child tag defining a drawable");
}
final Drawable dr = Drawable.createFromXmlInner(r, parser, attrs, theme);
mState.mDrawable = dr;
dr.setCallback(this);
}
|
public void | invalidateDrawable(Drawable who)
final Callback callback = getCallback();
if (callback != null) {
callback.invalidateDrawable(this);
}
|
public boolean | isStateful()
return mState.mDrawable.isStateful();
|
public Drawable | mutate()
if (!mMutated && super.mutate() == this) {
mState.mDrawable.mutate();
mMutated = true;
}
return this;
|
protected void | onBoundsChange(android.graphics.Rect bounds)
final Rect r = mTmpRect;
r.set(bounds);
r.left += mState.mInsetLeft;
r.top += mState.mInsetTop;
r.right -= mState.mInsetRight;
r.bottom -= mState.mInsetBottom;
mState.mDrawable.setBounds(r.left, r.top, r.right, r.bottom);
|
protected boolean | onLevelChange(int level)
return mState.mDrawable.setLevel(level);
|
protected boolean | onStateChange(int[] state)
boolean changed = mState.mDrawable.setState(state);
onBoundsChange(getBounds());
return changed;
|
public void | scheduleDrawable(Drawable who, java.lang.Runnable what, long when)
final Callback callback = getCallback();
if (callback != null) {
callback.scheduleDrawable(this, what, when);
}
|
public void | setAlpha(int alpha)
mState.mDrawable.setAlpha(alpha);
|
public void | setColorFilter(android.graphics.ColorFilter cf)
mState.mDrawable.setColorFilter(cf);
|
public void | setHotspot(float x, float y)
mState.mDrawable.setHotspot(x, y);
|
public void | setHotspotBounds(int left, int top, int right, int bottom)
mState.mDrawable.setHotspotBounds(left, top, right, bottom);
|
public void | setLayoutDirection(int layoutDirection){@hide}
mState.mDrawable.setLayoutDirection(layoutDirection);
|
public void | setTintList(android.content.res.ColorStateList tint)
mState.mDrawable.setTintList(tint);
|
public void | setTintMode(android.graphics.PorterDuff.Mode tintMode)
mState.mDrawable.setTintMode(tintMode);
|
public boolean | setVisible(boolean visible, boolean restart)
mState.mDrawable.setVisible(visible, restart);
return super.setVisible(visible, restart);
|
public void | unscheduleDrawable(Drawable who, java.lang.Runnable what)
final Callback callback = getCallback();
if (callback != null) {
callback.unscheduleDrawable(this, what);
}
|
private void | updateStateFromTypedArray(android.content.res.TypedArray a)
final InsetState state = mState;
// Account for any configuration changes.
state.mChangingConfigurations |= a.getChangingConfigurations();
// Extract the theme attributes, if any.
state.mThemeAttrs = a.extractThemeAttrs();
final int N = a.getIndexCount();
for (int i = 0; i < N; i++) {
final int attr = a.getIndex(i);
switch (attr) {
case R.styleable.InsetDrawable_drawable:
final Drawable dr = a.getDrawable(attr);
if (dr != null) {
state.mDrawable = dr;
dr.setCallback(this);
}
break;
case R.styleable.InsetDrawable_inset:
final int inset = a.getDimensionPixelOffset(attr, Integer.MIN_VALUE);
if (inset != Integer.MIN_VALUE) {
state.mInsetLeft = inset;
state.mInsetTop = inset;
state.mInsetRight = inset;
state.mInsetBottom = inset;
}
break;
case R.styleable.InsetDrawable_insetLeft:
state.mInsetLeft = a.getDimensionPixelOffset(attr, state.mInsetLeft);
break;
case R.styleable.InsetDrawable_insetTop:
state.mInsetTop = a.getDimensionPixelOffset(attr, state.mInsetTop);
break;
case R.styleable.InsetDrawable_insetRight:
state.mInsetRight = a.getDimensionPixelOffset(attr, state.mInsetRight);
break;
case R.styleable.InsetDrawable_insetBottom:
state.mInsetBottom = a.getDimensionPixelOffset(attr, state.mInsetBottom);
break;
}
}
|
private void | verifyRequiredAttributes(android.content.res.TypedArray a)
// If we're not waiting on a theme, verify required attributes.
if (mState.mDrawable == null && (mState.mThemeAttrs == null
|| mState.mThemeAttrs[R.styleable.InsetDrawable_drawable] == 0)) {
throw new XmlPullParserException(a.getPositionDescription()
+ ": <inset> tag requires a 'drawable' attribute or "
+ "child tag defining a drawable");
}
|