Methods Summary |
---|
public void | applyTheme(android.content.res.Resources.Theme t)
super.applyTheme(t);
final RotateState state = mState;
if (state == null) {
return;
}
if (state.mThemeAttrs != null) {
final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.RotateDrawable);
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)
final RotateState st = mState;
final Drawable d = st.mDrawable;
final Rect bounds = d.getBounds();
final int w = bounds.right - bounds.left;
final int h = bounds.bottom - bounds.top;
final float px = st.mPivotXRel ? (w * st.mPivotX) : st.mPivotX;
final float py = st.mPivotYRel ? (h * st.mPivotY) : st.mPivotY;
final int saveCount = canvas.save();
canvas.rotate(st.mCurrentDegrees, px + bounds.left, py + bounds.top);
d.draw(canvas);
canvas.restoreToCount(saveCount);
|
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 Drawable | getDrawable()
return mState.mDrawable;
|
public float | getFromDegrees()
return mState.mFromDegrees;
|
public int | getIntrinsicHeight()
return mState.mDrawable.getIntrinsicHeight();
|
public int | getIntrinsicWidth()
return mState.mDrawable.getIntrinsicWidth();
|
public int | getOpacity()
return mState.mDrawable.getOpacity();
|
public boolean | getPadding(android.graphics.Rect padding)
return mState.mDrawable.getPadding(padding);
|
public float | getPivotX()
return mState.mPivotX;
|
public float | getPivotY()
return mState.mPivotY;
|
public float | getToDegrees()
return mState.mToDegrees;
|
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.RotateDrawable);
super.inflateWithAttributes(r, parser, a, R.styleable.RotateDrawable_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)
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 | isPivotXRelative()
return mState.mPivotXRel;
|
public boolean | isPivotYRelative()
return mState.mPivotYRel;
|
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)
mState.mDrawable.setBounds(bounds.left, bounds.top,
bounds.right, bounds.bottom);
|
protected boolean | onLevelChange(int level)
mState.mDrawable.setLevel(level);
onBoundsChange(getBounds());
mState.mCurrentDegrees = mState.mFromDegrees +
(mState.mToDegrees - mState.mFromDegrees) *
(level / MAX_LEVEL);
invalidateSelf();
return true;
|
protected boolean | onStateChange(int[] state)
final 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 | setDrawable(Drawable drawable)Sets the drawable rotated by this RotateDrawable.
final Drawable oldDrawable = mState.mDrawable;
if (oldDrawable != drawable) {
if (oldDrawable != null) {
oldDrawable.setCallback(null);
}
mState.mDrawable = drawable;
if (drawable != null) {
drawable.setCallback(this);
}
}
|
public void | setFromDegrees(float fromDegrees)Sets the start angle for rotation.
if (mState.mFromDegrees != fromDegrees) {
mState.mFromDegrees = fromDegrees;
invalidateSelf();
}
|
public void | setPivotX(float pivotX)Sets the X position around which the drawable is rotated.
if (mState.mPivotX != pivotX) {
mState.mPivotX = pivotX;
invalidateSelf();
}
|
public void | setPivotXRelative(boolean relative)Sets whether the X pivot value represents a fraction of the drawable
width or an absolute value in pixels.
if (mState.mPivotXRel != relative) {
mState.mPivotXRel = relative;
invalidateSelf();
}
|
public void | setPivotY(float pivotY)Sets the Y position around which the drawable is rotated.
if (mState.mPivotY != pivotY) {
mState.mPivotY = pivotY;
invalidateSelf();
}
|
public void | setPivotYRelative(boolean relative)Sets whether the Y pivot value represents a fraction of the drawable
height or an absolute value in pixels.
if (mState.mPivotYRel != relative) {
mState.mPivotYRel = relative;
invalidateSelf();
}
|
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 void | setToDegrees(float toDegrees)Sets the end angle for rotation.
if (mState.mToDegrees != toDegrees) {
mState.mToDegrees = toDegrees;
invalidateSelf();
}
|
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 RotateState state = mState;
// Account for any configuration changes.
state.mChangingConfigurations |= a.getChangingConfigurations();
// Extract the theme attributes, if any.
state.mThemeAttrs = a.extractThemeAttrs();
if (a.hasValue(R.styleable.RotateDrawable_pivotX)) {
final TypedValue tv = a.peekValue(R.styleable.RotateDrawable_pivotX);
state.mPivotXRel = tv.type == TypedValue.TYPE_FRACTION;
state.mPivotX = state.mPivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
}
if (a.hasValue(R.styleable.RotateDrawable_pivotY)) {
final TypedValue tv = a.peekValue(R.styleable.RotateDrawable_pivotY);
state.mPivotYRel = tv.type == TypedValue.TYPE_FRACTION;
state.mPivotY = state.mPivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
}
state.mFromDegrees = a.getFloat(R.styleable.RotateDrawable_fromDegrees, state.mFromDegrees);
state.mToDegrees = a.getFloat(R.styleable.RotateDrawable_toDegrees, state.mToDegrees);
state.mCurrentDegrees = state.mFromDegrees;
final Drawable dr = a.getDrawable(R.styleable.RotateDrawable_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.ScaleDrawable_drawable] == 0)) {
throw new XmlPullParserException(a.getPositionDescription()
+ ": <rotate> tag requires a 'drawable' attribute or "
+ "child tag defining a drawable");
}
|