Ejemplo n.º 1
0
 /// <summary>Constructor used when an AnimationSet is loaded from a resource.</summary>
 /// <remarks>Constructor used when an AnimationSet 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 AnimationSet(android.content.Context context, android.util.AttributeSet attrs
                     ) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.AnimationSet);
     setFlag(PROPERTY_SHARE_INTERPOLATOR_MASK, a.getBoolean([email protected]
                                                            .AnimationSet_shareInterpolator, true));
     init();
     if (context.getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES
         .ICE_CREAM_SANDWICH)
     {
         if (a.hasValue([email protected]_duration))
         {
             mFlags |= PROPERTY_DURATION_MASK;
         }
         if (a.hasValue([email protected]_fillBefore))
         {
             mFlags |= PROPERTY_FILL_BEFORE_MASK;
         }
         if (a.hasValue([email protected]_fillAfter))
         {
             mFlags |= PROPERTY_FILL_AFTER_MASK;
         }
         if (a.hasValue([email protected]_repeatMode))
         {
             mFlags |= PROPERTY_REPEAT_MODE_MASK;
         }
         if (a.hasValue([email protected]_startOffset))
         {
             mFlags |= PROPERTY_START_OFFSET_MASK;
         }
     }
     a.recycle();
 }
Ejemplo n.º 2
0
 protected internal override void setBaseAttributes(android.content.res.TypedArray
                                                    a, int widthAttr, int heightAttr)
 {
     if (a.hasValue(widthAttr))
     {
         width = a.getLayoutDimension(widthAttr, "layout_width");
     }
     else
     {
         width = WRAP_CONTENT;
     }
     if (a.hasValue(heightAttr))
     {
         height = a.getLayoutDimension(heightAttr, "layout_height");
     }
     else
     {
         height = WRAP_CONTENT;
     }
 }
Ejemplo n.º 3
0
 protected internal override void setBaseAttributes(android.content.res.TypedArray
                                                    a, int widthAttr, int heightAttr)
 {
     this.width = MATCH_PARENT;
     if (a.hasValue(heightAttr))
     {
         this.height = a.getLayoutDimension(heightAttr, "layout_height");
     }
     else
     {
         this.height = WRAP_CONTENT;
     }
 }
Ejemplo n.º 4
0
 protected internal override void setBaseAttributes(android.content.res.TypedArray
                                                    a, int widthAttr, int heightAttr)
 {
     // We don't want to force users to specify a layout_width
     if (a.hasValue(widthAttr))
     {
         width = a.getLayoutDimension(widthAttr, "layout_width");
     }
     else
     {
         width = MATCH_PARENT;
     }
     // We don't want to force users to specify a layout_height
     if (a.hasValue(heightAttr))
     {
         height = a.getLayoutDimension(heightAttr, "layout_height");
     }
     else
     {
         height = WRAP_CONTENT;
     }
 }
Ejemplo n.º 5
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);
        }