/// <summary>Creates a new layout animation controller from external resources.</summary>
        /// <remarks>Creates a new layout animation controller from external resources.</remarks>
        /// <param name="context">
        /// the Context the view  group is running in, through which
        /// it can access the resources
        /// </param>
        /// <param name="attrs">
        /// the attributes of the XML tag that is inflating the
        /// layout animation controller
        /// </param>
        public LayoutAnimationController(android.content.Context context, android.util.AttributeSet
                                         attrs)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.LayoutAnimation);
            android.view.animation.Animation.Description d = android.view.animation.Animation
                                                             .Description.parseValue(a.peekValue([email protected]_delay
                                                                                                 ));
            mDelay = d.value;
            mOrder = a.getInt([email protected]_animationOrder, ORDER_NORMAL
                              );
            int resource = a.getResourceId([email protected]_animation
                                           , 0);

            if (resource > 0)
            {
                setAnimation(context, resource);
            }
            resource = a.getResourceId([email protected]_interpolator
                                       , 0);
            if (resource > 0)
            {
                setInterpolator(context, resource);
            }
            a.recycle();
        }
 /// <summary>Creates a new grid layout animation controller from external resources.</summary>
 /// <remarks>Creates a new grid layout animation controller from external resources.</remarks>
 /// <param name="context">
 /// the Context the view  group is running in, through which
 /// it can access the resources
 /// </param>
 /// <param name="attrs">
 /// the attributes of the XML tag that is inflating the
 /// layout animation controller
 /// </param>
 public GridLayoutAnimationController(android.content.Context context, android.util.AttributeSet
                                      attrs) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.GridLayoutAnimation);
     android.view.animation.Animation.Description d = android.view.animation.Animation
                                                      .Description.parseValue(a.peekValue([email protected]_columnDelay
                                                                                          ));
     mColumnDelay = d.value;
     d            = android.view.animation.Animation.Description.parseValue(a.peekValue([email protected]
                                                                                        .styleable.GridLayoutAnimation_rowDelay));
     mRowDelay = d.value;
     //noinspection PointlessBitwiseExpression
     mDirection = a.getInt([email protected]_direction
                           , DIRECTION_LEFT_TO_RIGHT | DIRECTION_TOP_TO_BOTTOM);
     mDirectionPriority = a.getInt([email protected]_directionPriority
                                   , PRIORITY_NONE);
     a.recycle();
 }
Exemplo n.º 3
0
 /// <summary>Constructor used when a RotateAnimation is loaded from a resource.</summary>
 /// <remarks>Constructor used when a RotateAnimation 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 RotateAnimation(android.content.Context context, android.util.AttributeSet
                        attrs) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.RotateAnimation);
     mFromDegrees = a.getFloat([email protected]_fromDegrees
                               , 0.0f);
     mToDegrees = a.getFloat([email protected]_toDegrees,
                             0.0f);
     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.RotateAnimation_pivotY));
     mPivotYType  = d.type;
     mPivotYValue = d.value;
     a.recycle();
 }
Exemplo n.º 4
0
 /// <summary>Constructor used when a TranslateAnimation is loaded from a resource.</summary>
 /// <remarks>Constructor used when a TranslateAnimation 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 TranslateAnimation(android.content.Context context, android.util.AttributeSet
                           attrs) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.TranslateAnimation);
     android.view.animation.Animation.Description d = android.view.animation.Animation
                                                      .Description.parseValue(a.peekValue([email protected]_fromXDelta
                                                                                          ));
     mFromXType  = d.type;
     mFromXValue = d.value;
     d           = android.view.animation.Animation.Description.parseValue(a.peekValue([email protected]
                                                                                       .styleable.TranslateAnimation_toXDelta));
     mToXType  = d.type;
     mToXValue = d.value;
     d         = android.view.animation.Animation.Description.parseValue(a.peekValue([email protected]
                                                                                     .styleable.TranslateAnimation_fromYDelta));
     mFromYType  = d.type;
     mFromYValue = d.value;
     d           = android.view.animation.Animation.Description.parseValue(a.peekValue([email protected]
                                                                                       .styleable.TranslateAnimation_toYDelta));
     mToYType  = d.type;
     mToYValue = d.value;
     a.recycle();
 }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new animation whose parameters come from the specified context and
        /// attributes set.
        /// </summary>
        /// <remarks>
        /// Creates a new animation whose parameters come from the specified context and
        /// attributes set.
        /// </remarks>
        /// <param name="context">the application environment</param>
        /// <param name="attrs">the set of attributes holding the animation parameters</param>
        /// <exception cref="android.content.res.Resources.NotFoundException"></exception>
        private static android.animation.ValueAnimator loadAnimator(android.content.Context
                                                                    context, android.util.AttributeSet attrs, android.animation.ValueAnimator anim)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.Animator);
            long duration   = a.getInt([email protected]_duration, 0);
            long startDelay = a.getInt([email protected]_startOffset, 0);
            int  valueType  = a.getInt([email protected]_valueType, VALUE_TYPE_FLOAT
                                       );

            if (anim == null)
            {
                anim = new android.animation.ValueAnimator();
            }
            android.animation.TypeEvaluator <object> evaluator = null;
            int  valueFromIndex = [email protected]_valueFrom;
            int  valueToIndex   = [email protected]_valueTo;
            bool getFloats      = (valueType == VALUE_TYPE_FLOAT);

            android.util.TypedValue tvFrom = a.peekValue(valueFromIndex);
            bool hasFrom  = (tvFrom != null);
            int  fromType = hasFrom ? tvFrom.type : 0;

            android.util.TypedValue tvTo = a.peekValue(valueToIndex);
            bool hasTo  = (tvTo != null);
            int  toType = hasTo ? tvTo.type : 0;

            if ((hasFrom && (fromType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (fromType
                                                                                           <= android.util.TypedValue.TYPE_LAST_COLOR_INT)) || (hasTo && (toType >= android.util.TypedValue
                                                                                                                                                          .TYPE_FIRST_COLOR_INT) && (toType <= android.util.TypedValue.TYPE_LAST_COLOR_INT
                                                                                                                                                                                     )))
            {
                // special case for colors: ignore valueType and get ints
                getFloats = false;
                anim.setEvaluator(new android.animation.ArgbEvaluator());
            }
            if (getFloats)
            {
                float valueFrom;
                float valueTo;
                if (hasFrom)
                {
                    if (fromType == android.util.TypedValue.TYPE_DIMENSION)
                    {
                        valueFrom = a.getDimension(valueFromIndex, 0f);
                    }
                    else
                    {
                        valueFrom = a.getFloat(valueFromIndex, 0f);
                    }
                    if (hasTo)
                    {
                        if (toType == android.util.TypedValue.TYPE_DIMENSION)
                        {
                            valueTo = a.getDimension(valueToIndex, 0f);
                        }
                        else
                        {
                            valueTo = a.getFloat(valueToIndex, 0f);
                        }
                        anim.setFloatValues(valueFrom, valueTo);
                    }
                    else
                    {
                        anim.setFloatValues(valueFrom);
                    }
                }
                else
                {
                    if (toType == android.util.TypedValue.TYPE_DIMENSION)
                    {
                        valueTo = a.getDimension(valueToIndex, 0f);
                    }
                    else
                    {
                        valueTo = a.getFloat(valueToIndex, 0f);
                    }
                    anim.setFloatValues(valueTo);
                }
            }
            else
            {
                int valueFrom;
                int valueTo;
                if (hasFrom)
                {
                    if (fromType == android.util.TypedValue.TYPE_DIMENSION)
                    {
                        valueFrom = (int)a.getDimension(valueFromIndex, 0f);
                    }
                    else
                    {
                        if ((fromType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (fromType <= android.util.TypedValue
                                                                                           .TYPE_LAST_COLOR_INT))
                        {
                            valueFrom = a.getColor(valueFromIndex, 0);
                        }
                        else
                        {
                            valueFrom = a.getInt(valueFromIndex, 0);
                        }
                    }
                    if (hasTo)
                    {
                        if (toType == android.util.TypedValue.TYPE_DIMENSION)
                        {
                            valueTo = (int)a.getDimension(valueToIndex, 0f);
                        }
                        else
                        {
                            if ((toType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (toType <= android.util.TypedValue
                                                                                             .TYPE_LAST_COLOR_INT))
                            {
                                valueTo = a.getColor(valueToIndex, 0);
                            }
                            else
                            {
                                valueTo = a.getInt(valueToIndex, 0);
                            }
                        }
                        anim.setIntValues(valueFrom, valueTo);
                    }
                    else
                    {
                        anim.setIntValues(valueFrom);
                    }
                }
                else
                {
                    if (hasTo)
                    {
                        if (toType == android.util.TypedValue.TYPE_DIMENSION)
                        {
                            valueTo = (int)a.getDimension(valueToIndex, 0f);
                        }
                        else
                        {
                            if ((toType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (toType <= android.util.TypedValue
                                                                                             .TYPE_LAST_COLOR_INT))
                            {
                                valueTo = a.getColor(valueToIndex, 0);
                            }
                            else
                            {
                                valueTo = a.getInt(valueToIndex, 0);
                            }
                        }
                        anim.setIntValues(valueTo);
                    }
                }
            }
            anim.setDuration(duration);
            anim.setStartDelay(startDelay);
            if (a.hasValue([email protected]_repeatCount))
            {
                anim.setRepeatCount(a.getInt([email protected]_repeatCount,
                                             0));
            }
            if (a.hasValue([email protected]_repeatMode))
            {
                anim.setRepeatMode(a.getInt([email protected]_repeatMode, android.animation.ValueAnimator
                                            .RESTART));
            }
            if (evaluator != null)
            {
                anim.setEvaluator(evaluator);
            }
            int resID = a.getResourceId([email protected]_interpolator,
                                        0);

            if (resID > 0)
            {
                anim.setInterpolator(android.view.animation.AnimationUtils.loadInterpolator(context
                                                                                            , resID));
            }
            a.recycle();
            return(anim);
        }
Exemplo n.º 7
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();
 }
Exemplo n.º 8
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);
            }
        }