Methods Summary |
---|
public void | draw(android.graphics.Canvas canvas)
int saveCount = canvas.save();
Rect bounds = mState.mDrawable.getBounds();
int w = bounds.right - bounds.left;
int h = bounds.bottom - bounds.top;
final RotateState st = mState;
float px = st.mPivotXRel ? (w * st.mPivotX) : st.mPivotX;
float py = st.mPivotYRel ? (h * st.mPivotY) : st.mPivotY;
canvas.rotate(st.mCurrentDegrees, px, py);
st.mDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
|
public int | getChangingConfigurations()
return super.getChangingConfigurations()
| mState.mChangingConfigurations
| mState.mDrawable.getChangingConfigurations();
|
public ConstantState | getConstantState()
if (mState.canConstantState()) {
mState.mChangingConfigurations = super.getChangingConfigurations();
return mState;
}
return null;
|
public Drawable | getDrawable()Returns the drawable rotated by this RotateDrawable.
return mState.mDrawable;
|
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 void | inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs)
TypedArray a = r.obtainAttributes(attrs,
com.android.internal.R.styleable.RotateDrawable);
super.inflateWithAttributes(r, parser, a,
com.android.internal.R.styleable.RotateDrawable_visible);
TypedValue tv = a.peekValue(com.android.internal.R.styleable.RotateDrawable_pivotX);
boolean pivotXRel = tv.type == TypedValue.TYPE_FRACTION;
float pivotX = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
tv = a.peekValue(com.android.internal.R.styleable.RotateDrawable_pivotY);
boolean pivotYRel = tv.type == TypedValue.TYPE_FRACTION;
float pivotY = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
float fromDegrees = a.getFloat(
com.android.internal.R.styleable.RotateDrawable_fromDegrees, 0.0f);
float toDegrees = a.getFloat(
com.android.internal.R.styleable.RotateDrawable_toDegrees, 360.0f);
toDegrees = Math.max(fromDegrees, toDegrees);
int res = a.getResourceId(
com.android.internal.R.styleable.RotateDrawable_drawable, 0);
Drawable drawable = null;
if (res > 0) {
drawable = r.getDrawable(res);
}
a.recycle();
int outerDepth = parser.getDepth();
int type;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT &&
(type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
if (type != XmlPullParser.START_TAG) {
continue;
}
if ((drawable = Drawable.createFromXmlInner(r, parser, attrs)) == null) {
Log.w("drawable", "Bad element under <rotate>: "
+ parser .getName());
}
}
if (drawable == null) {
Log.w("drawable", "No drawable specified for <rotate>");
}
mState.mDrawable = drawable;
mState.mPivotXRel = pivotXRel;
mState.mPivotX = pivotX;
mState.mPivotYRel = pivotYRel;
mState.mPivotY = pivotY;
mState.mFromDegrees = mState.mCurrentDegrees = fromDegrees;
mState.mToDegrees = toDegrees;
if (drawable != null) {
drawable.setCallback(this);
}
|
public void | invalidateDrawable(Drawable who)
if (mCallback != null) {
mCallback.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)
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) *
((float) level / MAX_LEVEL);
invalidateSelf();
return true;
|
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)
if (mCallback != null) {
mCallback.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 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)
if (mCallback != null) {
mCallback.unscheduleDrawable(this, what);
}
|