internal AnimatedRotateDrawable(android.graphics.drawable.AnimatedRotateDrawable. AnimatedRotateState rotateState, android.content.res.Resources res) { mState = new android.graphics.drawable.AnimatedRotateDrawable.AnimatedRotateState (rotateState, this, res); init(); }
internal AnimatedRotateDrawable(android.graphics.drawable.AnimatedRotateDrawable. AnimatedRotateState rotateState, android.content.res.Resources res) { mState = new android.graphics.drawable.AnimatedRotateDrawable.AnimatedRotateState (rotateState, this, res); init(); }
private void init() { android.graphics.drawable.AnimatedRotateDrawable.AnimatedRotateState state = mState; mIncrement = 360.0f / state.mFramesCount; android.graphics.drawable.Drawable drawable = state.mDrawable; if (drawable != null) { drawable.setFilterBitmap(true); if (drawable is android.graphics.drawable.BitmapDrawable) { ((android.graphics.drawable.BitmapDrawable)drawable).setAntiAlias(true); } } }
public override void draw(android.graphics.Canvas canvas) { int saveCount = canvas.save(); android.graphics.drawable.AnimatedRotateDrawable.AnimatedRotateState st = mState; android.graphics.drawable.Drawable drawable = st.mDrawable; android.graphics.Rect bounds = drawable.getBounds(); int w = bounds.right - bounds.left; int h = bounds.bottom - bounds.top; float px = st.mPivotXRel ? (w * st.mPivotX) : st.mPivotX; float py = st.mPivotYRel ? (h * st.mPivotY) : st.mPivotY; canvas.rotate(mCurrentDegrees, px + bounds.left, py + bounds.top); drawable.draw(canvas); canvas.restoreToCount(saveCount); }
internal AnimatedRotateState(android.graphics.drawable.AnimatedRotateDrawable.AnimatedRotateState source, android.graphics.drawable.AnimatedRotateDrawable owner, android.content.res.Resources res) { if (source != null) { if (res != null) { mDrawable = source.mDrawable.getConstantState().newDrawable(res); } else { mDrawable = source.mDrawable.getConstantState().newDrawable(); } mDrawable.setCallback(owner); mPivotXRel = source.mPivotXRel; mPivotX = source.mPivotX; mPivotYRel = source.mPivotYRel; mPivotY = source.mPivotY; mFramesCount = source.mFramesCount; mFrameDuration = source.mFrameDuration; mCanConstantState = mCheckedConstantState = true; } }
public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs) { android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]. styleable.AnimatedRotateDrawable); base.inflateWithAttributes(r, parser, a, [email protected]_visible ); android.util.TypedValue tv = a.peekValue([email protected]_pivotX ); bool pivotXRel = tv.type == android.util.TypedValue.TYPE_FRACTION; float pivotX = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); tv = a.peekValue([email protected]_pivotY); bool pivotYRel = tv.type == android.util.TypedValue.TYPE_FRACTION; float pivotY = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); setFramesCount(a.getInt([email protected]_framesCount , 12)); setFramesDuration(a.getInt([email protected]_frameDuration , 150)); int res = a.getResourceId([email protected]_drawable , 0); android.graphics.drawable.Drawable drawable = null; if (res > 0) { drawable = r.getDrawable(res); } a.recycle(); int outerDepth = parser.getDepth(); int type; while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT && (type != org.xmlpull.v1.XmlPullParserClass.END_TAG || parser.getDepth() > outerDepth )) { if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { continue; } if ((drawable = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs)) == null) { android.util.Log.w("drawable", "Bad element under <animated-rotate>: " + parser.getName ()); } } if (drawable == null) { android.util.Log.w("drawable", "No drawable specified for <animated-rotate>"); } android.graphics.drawable.AnimatedRotateDrawable.AnimatedRotateState rotateState = mState; rotateState.mDrawable = drawable; rotateState.mPivotXRel = pivotXRel; rotateState.mPivotX = pivotX; rotateState.mPivotYRel = pivotYRel; rotateState.mPivotY = pivotY; init(); if (drawable != null) { drawable.setCallback(this); } }