Пример #1
0
 /// <summary>Constructor used when a ScaleAnimation is loaded from a resource.</summary>
 /// <remarks>Constructor used when a ScaleAnimation is loaded from a resource.</remarks>
 /// <param name="context">Application context to use</param>
 /// <param name="attrs">Attribute set from which to read values</param>
 public ScaleAnimation(android.content.Context context, android.util.AttributeSet
                       attrs) : base(context, attrs)
 {
     mResources = context.getResources();
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.ScaleAnimation);
     android.util.TypedValue tv = a.peekValue([email protected]_fromXScale
                                              );
     mFromX = 0.0f;
     if (tv != null)
     {
         if (tv.type == android.util.TypedValue.TYPE_FLOAT)
         {
             // This is a scaling factor.
             mFromX = tv.getFloat();
         }
         else
         {
             mFromXType = tv.type;
             mFromXData = tv.data;
         }
     }
     tv   = a.peekValue([email protected]_toXScale);
     mToX = 0.0f;
     if (tv != null)
     {
         if (tv.type == android.util.TypedValue.TYPE_FLOAT)
         {
             // This is a scaling factor.
             mToX = tv.getFloat();
         }
         else
         {
             mToXType = tv.type;
             mToXData = tv.data;
         }
     }
     tv     = a.peekValue([email protected]_fromYScale);
     mFromY = 0.0f;
     if (tv != null)
     {
         if (tv.type == android.util.TypedValue.TYPE_FLOAT)
         {
             // This is a scaling factor.
             mFromY = tv.getFloat();
         }
         else
         {
             mFromYType = tv.type;
             mFromYData = tv.data;
         }
     }
     tv   = a.peekValue([email protected]_toYScale);
     mToY = 0.0f;
     if (tv != null)
     {
         if (tv.type == android.util.TypedValue.TYPE_FLOAT)
         {
             // This is a scaling factor.
             mToY = tv.getFloat();
         }
         else
         {
             mToYType = tv.type;
             mToYData = tv.data;
         }
     }
     android.view.animation.Animation.Description d = android.view.animation.Animation
                                                      .Description.parseValue(a.peekValue([email protected]_pivotX
                                                                                          ));
     mPivotXType  = d.type;
     mPivotXValue = d.value;
     d            = android.view.animation.Animation.Description.parseValue(a.peekValue([email protected]
                                                                                        .styleable.ScaleAnimation_pivotY));
     mPivotYType  = d.type;
     mPivotYValue = d.value;
     a.recycle();
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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.RotateDrawable);
            base.inflateWithAttributes(r, parser, a, [email protected]_visible
                                       );
            android.util.TypedValue tv = a.peekValue([email protected]_pivotX
                                                     );
            bool  pivotXRel;
            float pivotX;

            if (tv == null)
            {
                pivotXRel = true;
                pivotX    = 0.5f;
            }
            else
            {
                pivotXRel = tv.type == android.util.TypedValue.TYPE_FRACTION;
                pivotX    = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
            }
            tv = a.peekValue([email protected]_pivotY);
            bool  pivotYRel;
            float pivotY;

            if (tv == null)
            {
                pivotYRel = true;
                pivotY    = 0.5f;
            }
            else
            {
                pivotYRel = tv.type == android.util.TypedValue.TYPE_FRACTION;
                pivotY    = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
            }
            float fromDegrees = a.getFloat([email protected]_fromDegrees
                                           , 0.0f);
            float toDegrees = a.getFloat([email protected]_toDegrees
                                         , 360.0f);
            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 <rotate>: " + parser.getName());
                }
            }
            if (drawable == null)
            {
                android.util.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);
            }
        }