Пример #1
0
 public virtual void setEvaluator(android.animation.TypeEvaluator <object> value)
 {
     throw new System.NotImplementedException();
 }
Пример #2
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);
        }
Пример #3
0
 public static android.animation.ValueAnimator ofObject(android.animation.TypeEvaluator
                                                        <object> evaluator, params object[] values)
 {
     throw new System.NotImplementedException();
 }