Methods Summary |
---|
public void | applyTheme(android.content.res.Resources.Theme t)
super.applyTheme(t);
final ClipState state = mState;
if (state == null || state.mThemeAttrs == null) {
return;
}
final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.ClipDrawable);
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(Canvas canvas)
if (mState.mDrawable.getLevel() == 0) {
return;
}
final Rect r = mTmpRect;
final Rect bounds = getBounds();
int level = getLevel();
int w = bounds.width();
final int iw = 0; //mState.mDrawable.getIntrinsicWidth();
if ((mState.mOrientation & HORIZONTAL) != 0) {
w -= (w - iw) * (10000 - level) / 10000;
}
int h = bounds.height();
final int ih = 0; //mState.mDrawable.getIntrinsicHeight();
if ((mState.mOrientation & VERTICAL) != 0) {
h -= (h - ih) * (10000 - level) / 10000;
}
final int layoutDirection = getLayoutDirection();
Gravity.apply(mState.mGravity, w, h, bounds, r, layoutDirection);
if (w > 0 && h > 0) {
canvas.save();
canvas.clipRect(r);
mState.mDrawable.draw(canvas);
canvas.restore();
}
|
public int | getAlpha()
return mState.mDrawable.getAlpha();
|
public int | getChangingConfigurations()
return super.getChangingConfigurations()
| mState.mChangingConfigurations
| mState.mDrawable.getChangingConfigurations();
|
public ConstantState | getConstantState()
if (mState.canConstantState()) {
mState.mChangingConfigurations = getChangingConfigurations();
return mState;
}
return null;
|
public int | getIntrinsicHeight()
return mState.mDrawable.getIntrinsicHeight();
|
public int | getIntrinsicWidth()
return mState.mDrawable.getIntrinsicWidth();
|
public int | getOpacity()
return mState.mDrawable.getOpacity();
|
public boolean | getPadding(Rect padding)
// XXX need to adjust padding!
return mState.mDrawable.getPadding(padding);
|
public void | inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs, android.content.res.Resources.Theme theme)
super.inflate(r, parser, attrs, theme);
final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.ClipDrawable);
// 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)
Drawable dr = null;
int type;
final int outerDepth = parser.getDepth();
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
if (type != XmlPullParser.START_TAG) {
continue;
}
dr = Drawable.createFromXmlInner(r, parser, attrs, theme);
}
if (dr != null) {
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(Rect bounds)
mState.mDrawable.setBounds(bounds);
|
protected boolean | onLevelChange(int level)
mState.mDrawable.setLevel(level);
invalidateSelf();
return true;
|
protected boolean | onStateChange(int[] state)
return mState.mDrawable.setState(state);
|
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(ColorFilter cf)
mState.mDrawable.setColorFilter(cf);
|
public void | setLayoutDirection(int layoutDirection)
mState.mDrawable.setLayoutDirection(layoutDirection);
super.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 ClipState state = mState;
// Account for any configuration changes.
state.mChangingConfigurations |= a.getChangingConfigurations();
// Extract the theme attributes, if any.
state.mThemeAttrs = a.extractThemeAttrs();
state.mOrientation = a.getInt(R.styleable.ClipDrawable_clipOrientation, state.mOrientation);
state.mGravity = a.getInt(R.styleable.ClipDrawable_gravity, state.mGravity);
final Drawable dr = a.getDrawable(R.styleable.ClipDrawable_drawable);
if (dr != null) {
state.mDrawable = dr;
dr.setCallback(this);
}
|
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.ClipDrawable_drawable] == 0)) {
throw new XmlPullParserException(a.getPositionDescription()
+ ": <clip> tag requires a 'drawable' attribute or "
+ "child tag defining a drawable");
}
|