Exemple #1
0
        /// <summary>Retrieve the styled string value for the attribute at <var>index</var>.</summary>
        /// <remarks>Retrieve the styled string value for the attribute at <var>index</var>.</remarks>
        /// <param name="index">Index of attribute to retrieve.</param>
        /// <returns>
        /// CharSequence holding string data.  May be styled.  Returns
        /// null if the attribute is not defined.
        /// </returns>
        public virtual java.lang.CharSequence getText(int index)
        {
            index *= android.content.res.AssetManager.STYLE_NUM_ENTRIES;
            int[] data = mData;
            int   type = data[index + android.content.res.AssetManager.STYLE_TYPE];

            if (type == android.util.TypedValue.TYPE_NULL)
            {
                return(null);
            }
            else
            {
                if (type == android.util.TypedValue.TYPE_STRING)
                {
                    return(loadStringValueAt(index));
                }
            }
            android.util.TypedValue v = mValue;
            if (getValueAt(index, v))
            {
                android.util.Log.w(android.content.res.Resources.TAG, "Converting to string: " +
                                   v);
                return(v.coerceToString());
            }
            android.util.Log.w(android.content.res.Resources.TAG, "getString of bad type: 0x"
                               + Sharpen.Util.IntToHexString(type));
            return(null);
        }
Exemple #2
0
        /// <hide>
        /// Retrieve the string value for the attribute at <var>index</var> that is
        /// not allowed to change with the given configurations.
        /// </hide>
        /// <param name="index">Index of attribute to retrieve.</param>
        /// <param name="allowedChangingConfigs">
        /// Bit mask of configurations from
        /// ActivityInfo that are allowed to change.
        /// </param>
        /// <returns>
        /// String holding string data.  Any styling information is
        /// removed.  Returns null if the attribute is not defined.
        /// </returns>
        public virtual string getNonConfigurationString(int index, int allowedChangingConfigs
                                                        )
        {
            index *= android.content.res.AssetManager.STYLE_NUM_ENTRIES;
            int[] data = mData;
            int   type = data[index + android.content.res.AssetManager.STYLE_TYPE];

            if ((data[index + android.content.res.AssetManager.STYLE_CHANGING_CONFIGURATIONS]
                 & ~allowedChangingConfigs) != 0)
            {
                return(null);
            }
            if (type == android.util.TypedValue.TYPE_NULL)
            {
                return(null);
            }
            else
            {
                if (type == android.util.TypedValue.TYPE_STRING)
                {
                    return(loadStringValueAt(index).ToString());
                }
            }
            android.util.TypedValue v = mValue;
            if (getValueAt(index, v))
            {
                android.util.Log.w(android.content.res.Resources.TAG, "Converting to string: " +
                                   v);
                java.lang.CharSequence cs = v.coerceToString();
                return(cs != null?cs.ToString() : null);
            }
            android.util.Log.w(android.content.res.Resources.TAG, "getString of bad type: 0x"
                               + Sharpen.Util.IntToHexString(type));
            return(null);
        }
Exemple #3
0
        /// <summary>Retrieve the color value for the attribute at <var>index</var>.</summary>
        /// <remarks>
        /// Retrieve the color value for the attribute at <var>index</var>.  If
        /// the attribute references a color resource holding a complex
        /// <see cref="ColorStateList">ColorStateList</see>
        /// , then the default color from
        /// the set is returned.
        /// </remarks>
        /// <param name="index">Index of attribute to retrieve.</param>
        /// <param name="defValue">
        /// Value to return if the attribute is not defined or
        /// not a resource.
        /// </param>
        /// <returns>Attribute color value, or defValue if not defined.</returns>
        public virtual int getColor(int index, int defValue)
        {
            index *= android.content.res.AssetManager.STYLE_NUM_ENTRIES;
            int[] data = mData;
            int   type = data[index + android.content.res.AssetManager.STYLE_TYPE];

            if (type == android.util.TypedValue.TYPE_NULL)
            {
                return(defValue);
            }
            else
            {
                if (type >= android.util.TypedValue.TYPE_FIRST_INT && type <= android.util.TypedValue
                    .TYPE_LAST_INT)
                {
                    return(data[index + android.content.res.AssetManager.STYLE_DATA]);
                }
                else
                {
                    if (type == android.util.TypedValue.TYPE_STRING)
                    {
                        android.util.TypedValue value = mValue;
                        if (getValueAt(index, value))
                        {
                            android.content.res.ColorStateList csl = mResources.loadColorStateList(value, value
                                                                                                   .resourceId);
                            return(csl.getDefaultColor());
                        }
                        return(defValue);
                    }
                }
            }
            throw new System.NotSupportedException("Can't convert to color: type=0x" + Sharpen.Util.IntToHexString
                                                       (type));
        }
Exemple #4
0
        /// <summary>Retrieve the integer value for the attribute at <var>index</var>.</summary>
        /// <remarks>Retrieve the integer value for the attribute at <var>index</var>.</remarks>
        /// <param name="index">Index of attribute to retrieve.</param>
        /// <param name="defValue">Value to return if the attribute is not defined.</param>
        /// <returns>Attribute int value, or defValue if not defined.</returns>
        public virtual int getInt(int index, int defValue)
        {
            index *= android.content.res.AssetManager.STYLE_NUM_ENTRIES;
            int[] data = mData;
            int   type = data[index + android.content.res.AssetManager.STYLE_TYPE];

            if (type == android.util.TypedValue.TYPE_NULL)
            {
                return(defValue);
            }
            else
            {
                if (type >= android.util.TypedValue.TYPE_FIRST_INT && type <= android.util.TypedValue
                    .TYPE_LAST_INT)
                {
                    return(data[index + android.content.res.AssetManager.STYLE_DATA]);
                }
            }
            android.util.TypedValue v = mValue;
            if (getValueAt(index, v))
            {
                android.util.Log.w(android.content.res.Resources.TAG, "Converting to int: " + v);
                return([email protected](v.coerceToString(), defValue
                                                                         ));
            }
            android.util.Log.w(android.content.res.Resources.TAG, "getInt of bad type: 0x" +
                               Sharpen.Util.IntToHexString(type));
            return(defValue);
        }
Exemple #5
0
 // do nothing here
 /// <summary>Decode a new Bitmap from an InputStream.</summary>
 /// <remarks>
 /// Decode a new Bitmap from an InputStream. This InputStream was obtained from
 /// resources, which we pass to be able to scale the bitmap accordingly.
 /// </remarks>
 public static android.graphics.Bitmap decodeResourceStream(android.content.res.Resources
                                                            res, android.util.TypedValue value, java.io.InputStream @is, android.graphics.Rect
                                                            pad, android.graphics.BitmapFactory.Options opts)
 {
     if (opts == null)
     {
         opts = new android.graphics.BitmapFactory.Options();
     }
     if (opts.inDensity == 0 && value != null)
     {
         int density = value.density;
         if (density == android.util.TypedValue.DENSITY_DEFAULT)
         {
             opts.inDensity = android.util.DisplayMetrics.DENSITY_DEFAULT;
         }
         else
         {
             if (density != android.util.TypedValue.DENSITY_NONE)
             {
                 opts.inDensity = density;
             }
         }
     }
     if (opts.inTargetDensity == 0 && res != null)
     {
         opts.inTargetDensity = res.getDisplayMetrics().densityDpi;
     }
     return(decodeStream(@is, pad, opts));
 }
Exemple #6
0
 /// <summary>
 /// Synonym for opening the given resource and calling
 /// <see cref="decodeResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, Rect, Options)
 ///     ">decodeResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, Rect, Options)
 ///     </see>
 /// .
 /// </summary>
 /// <param name="res">The resources object containing the image data</param>
 /// <param name="id">The resource id of the image data</param>
 /// <param name="opts">
 /// null-ok; Options that control downsampling and whether the
 /// image should be completely decoded, or just is size returned.
 /// </param>
 /// <returns>
 /// The decoded bitmap, or null if the image data could not be
 /// decoded, or, if opts is non-null, if opts requested only the
 /// size be returned (in opts.outWidth and opts.outHeight)
 /// </returns>
 public static android.graphics.Bitmap decodeResource(android.content.res.Resources
                                                      res, int id, android.graphics.BitmapFactory.Options opts)
 {
     android.graphics.Bitmap bm  = null;
     java.io.InputStream     @is = null;
     try
     {
         android.util.TypedValue value = new android.util.TypedValue();
         @is = res.openRawResource(id, value);
         bm  = decodeResourceStream(res, value, @is, null, opts);
     }
     catch (System.Exception)
     {
     }
     finally
     {
         try
         {
             if (@is != null)
             {
                 @is.close();
             }
         }
         catch (System.IO.IOException)
         {
         }
     }
     // Ignore
     if (bm == null && opts != null && opts.inBitmap != null)
     {
         throw new System.ArgumentException("Problem decoding into existing bitmap");
     }
     return(bm);
 }
 private static bool shouldCenterSingleButton(android.content.Context context)
 {
     android.util.TypedValue outValue = new android.util.TypedValue();
     context.getTheme().resolveAttribute([email protected]
                                         , outValue, true);
     return(outValue.data != 0);
 }
Exemple #8
0
 public virtual void setTo(android.util.TypedValue other)
 {
     type        = other.type;
     @string     = other.@string;
     data        = other.data;
     assetCookie = other.assetCookie;
     resourceId  = other.resourceId;
     density     = other.density;
 }
Exemple #9
0
 /// <summary>
 /// Retrieve the raw TypedValue for the attribute at <var>index</var>
 /// and return a temporary object holding its data.
 /// </summary>
 /// <remarks>
 /// Retrieve the raw TypedValue for the attribute at <var>index</var>
 /// and return a temporary object holding its data.  This object is only
 /// valid until the next call on to
 /// <see cref="TypedArray">TypedArray</see>
 /// .
 /// </remarks>
 /// <param name="index">Index of attribute to retrieve.</param>
 /// <returns>
 /// Returns a TypedValue object if the attribute is defined,
 /// containing its data; otherwise returns null.  (You will not
 /// receive a TypedValue whose type is TYPE_NULL.)
 /// </returns>
 public virtual android.util.TypedValue peekValue(int index)
 {
     android.util.TypedValue value = mValue;
     if (getValueAt(index * android.content.res.AssetManager.STYLE_NUM_ENTRIES, value))
     {
         return(value);
     }
     return(null);
 }
Exemple #10
0
 /// <summary>Retrieve the ColorStateList for the attribute at <var>index</var>.</summary>
 /// <remarks>
 /// Retrieve the ColorStateList for the attribute at <var>index</var>.
 /// The value may be either a single solid color or a reference to
 /// a color or complex
 /// <see cref="ColorStateList">ColorStateList</see>
 /// description.
 /// </remarks>
 /// <param name="index">Index of attribute to retrieve.</param>
 /// <returns>ColorStateList for the attribute, or null if not defined.</returns>
 public virtual android.content.res.ColorStateList getColorStateList(int index)
 {
     android.util.TypedValue value = mValue;
     if (getValueAt(index * android.content.res.AssetManager.STYLE_NUM_ENTRIES, value))
     {
         return(mResources.loadColorStateList(value, value.resourceId));
     }
     return(null);
 }
Exemple #11
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            base.inflate(r, parser, attrs);
            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.NinePatchDrawable);
            int id = a.getResourceId([email protected]_src, 0);

            if (id == 0)
            {
                throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                ": <nine-patch> requires a valid src attribute");
            }
            bool dither = a.getBoolean([email protected]_dither
                                       , DEFAULT_DITHER);

            android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory
                                                             .Options();
            if (dither)
            {
                options.inDither = false;
            }
            options.inScreenDensity = android.util.DisplayMetrics.DENSITY_DEVICE;
            android.graphics.Rect   padding = new android.graphics.Rect();
            android.graphics.Bitmap bitmap  = null;
            try
            {
                android.util.TypedValue value = new android.util.TypedValue();
                java.io.InputStream     @is   = r.openRawResource(id, value);
                bitmap = android.graphics.BitmapFactory.decodeResourceStream(r, value, @is, padding
                                                                             , options);
                @is.close();
            }
            catch (System.IO.IOException)
            {
            }
            // Ignore
            if (bitmap == null)
            {
                throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                ": <nine-patch> requires a valid src attribute");
            }
            else
            {
                if (bitmap.getNinePatchChunk() == null)
                {
                    throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                    ": <nine-patch> requires a valid 9-patch source image");
                }
            }
            setNinePatchState(new android.graphics.drawable.NinePatchDrawable.NinePatchState(
                                  new android.graphics.NinePatch(bitmap, bitmap.getNinePatchChunk(), "XML 9-patch"
                                                                 ), padding, dither), r);
            mNinePatchState.mTargetDensity = mTargetDensity;
            a.recycle();
        }
Exemple #12
0
 public static System.IntPtr ManagedToNative(android.util.TypedValue arg)
 {
     if (arg == null)
     {
         return(System.IntPtr.Zero);
     }
     System.IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TypedValue_Struct)
                                                             ));
     android.util.TypedValue.TypedValue_Helper.MarshalIn(ptr, arg);
     return(ptr);
 }
Exemple #13
0
 public virtual void setTo(android.util.TypedValue arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         @__env.CallVoidMethod(this.JvmHandle, global::android.util.TypedValue._setTo8637, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
     }
     else
     {
         @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.util.TypedValue.staticClass, global::android.util.TypedValue._setTo8637, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
     }
 }
Exemple #14
0
            public static void MarshalIn(System.IntPtr ptr, android.util.TypedValue arg)
            {
                TypedValue_Struct obj = new TypedValue_Struct();

                obj._owner      = 0x972f3813;
                obj.type        = arg.type;
                obj.data        = arg.data;
                obj.assetCookie = arg.assetCookie;
                obj.resourceId  = arg.resourceId;
                obj.density     = arg.density;
                Marshal.StructureToPtr(obj, ptr, false);
            }
Exemple #15
0
            public static void MarshalOut(System.IntPtr ptr, android.util.TypedValue arg)
            {
                TypedValue_Struct obj = (TypedValue_Struct)Marshal.PtrToStructure(ptr, typeof(TypedValue_Struct
                                                                                              ));

                arg.type        = obj.type;
                arg.data        = obj.data;
                arg.@string     = null;
                arg.assetCookie = obj.assetCookie;
                arg.resourceId  = obj.resourceId;
                arg.density     = obj.density;
            }
Exemple #16
0
 public virtual bool getValue(int arg0, android.util.TypedValue arg1)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(@__env.CallBooleanMethod(this.JvmHandle, global::android.content.res.TypedArray._getValue2346, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1)));
     }
     else
     {
         return(@__env.CallNonVirtualBooleanMethod(this.JvmHandle, global::android.content.res.TypedArray.staticClass, global::android.content.res.TypedArray._getValue2346, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1)));
     }
 }
 private java.lang.CharSequence formatUrl(java.lang.CharSequence url)
 {
     if (mUrlColor == null)
     {
         // Lazily get the URL color from the current theme.
         android.util.TypedValue colorValue = new android.util.TypedValue();
         mContext.getTheme().resolveAttribute([email protected],
                                              colorValue, true);
         mUrlColor = mContext.getResources().getColorStateList(colorValue.resourceId);
     }
     android.text.SpannableString text = new android.text.SpannableString(url);
     text.setSpan(new android.text.style.TextAppearanceSpan(null, 0, 0, mUrlColor, null
                                                            ), 0, url.Length, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE);
     return(text);
 }
Exemple #18
0
            public static android.util.TypedValue NativeToManaged(System.IntPtr ptr)
            {
                if (ptr == System.IntPtr.Zero)
                {
                    return(null);
                }
                TypedValue_Struct obj = (TypedValue_Struct)Marshal.PtrToStructure(ptr, typeof(TypedValue_Struct
                                                                                              ));

                android.util.TypedValue arg = new android.util.TypedValue();
                arg.type        = obj.type;
                arg.data        = obj.data;
                arg.@string     = null;
                arg.assetCookie = obj.assetCookie;
                arg.resourceId  = obj.resourceId;
                arg.density     = obj.density;
                return(arg);
            }
Exemple #19
0
 /// <summary>Retrieve the CharSequence[] for the attribute at <var>index</var>.</summary>
 /// <remarks>
 /// Retrieve the CharSequence[] for the attribute at <var>index</var>.
 /// This gets the resource ID of the selected attribute, and uses
 /// <see cref="Resources.getTextArray(int)">Resources.getTextArray</see>
 /// of the owning
 /// Resources object to retrieve its String[].
 /// </remarks>
 /// <param name="index">Index of attribute to retrieve.</param>
 /// <returns>CharSequence[] for the attribute, or null if not defined.</returns>
 public virtual java.lang.CharSequence[] getTextArray(int index)
 {
     android.util.TypedValue value = mValue;
     if (getValueAt(index * android.content.res.AssetManager.STYLE_NUM_ENTRIES, value))
     {
         if (false)
         {
             java.io.Console.Out.println("******************************************************************"
                                         );
             java.io.Console.Out.println("Got drawable resource: type=" + value.type + " str="
                                         + value.@string + " int=0x" + Sharpen.Util.IntToHexString(value.data) + " cookie="
                                         + value.assetCookie);
             java.io.Console.Out.println("******************************************************************"
                                         );
         }
         return(mResources.getTextArray(value.resourceId));
     }
     return(null);
 }
Exemple #20
0
 public override android.content.Context getThemedContext()
 {
     if (mThemedContext == null)
     {
         android.util.TypedValue             outValue     = new android.util.TypedValue();
         android.content.res.Resources.Theme currentTheme = mContext.getTheme();
         currentTheme.resolveAttribute([email protected], outValue
                                       , true);
         int targetThemeRes = outValue.resourceId;
         if (targetThemeRes != 0 && mContext.getThemeResId() != targetThemeRes)
         {
             mThemedContext = new android.view.ContextThemeWrapper(mContext, targetThemeRes);
         }
         else
         {
             mThemedContext = mContext;
         }
     }
     return(mThemedContext);
 }
Exemple #21
0
        /// <summary>Retrieve the float value for the attribute at <var>index</var>.</summary>
        /// <remarks>Retrieve the float value for the attribute at <var>index</var>.</remarks>
        /// <param name="index">Index of attribute to retrieve.</param>
        /// <returns>Attribute float value, or defValue if not defined..</returns>
        public virtual float getFloat(int index, float defValue)
        {
            index *= android.content.res.AssetManager.STYLE_NUM_ENTRIES;
            int[] data = mData;
            int   type = data[index + android.content.res.AssetManager.STYLE_TYPE];

            if (type == android.util.TypedValue.TYPE_NULL)
            {
                return(defValue);
            }
            else
            {
                if (type == android.util.TypedValue.TYPE_FLOAT)
                {
                    return(Sharpen.Util.IntBitsToFloat(data[index + android.content.res.AssetManager.
                                                            STYLE_DATA]));
                }
                else
                {
                    if (type >= android.util.TypedValue.TYPE_FIRST_INT && type <= android.util.TypedValue
                        .TYPE_LAST_INT)
                    {
                        return(data[index + android.content.res.AssetManager.STYLE_DATA]);
                    }
                }
            }
            android.util.TypedValue v = mValue;
            if (getValueAt(index, v))
            {
                android.util.Log.w(android.content.res.Resources.TAG, "Converting to float: " + v
                                   );
                java.lang.CharSequence str = v.coerceToString();
                if (str != null)
                {
                    return(float.Parse(str.ToString()));
                }
            }
            android.util.Log.w(android.content.res.Resources.TAG, "getFloat of bad type: 0x"
                               + Sharpen.Util.IntToHexString(type));
            return(defValue);
        }
Exemple #22
0
        private bool getValueAt(int index, android.util.TypedValue outValue)
        {
            int[] data = mData;
            int   type = data[index + android.content.res.AssetManager.STYLE_TYPE];

            if (type == android.util.TypedValue.TYPE_NULL)
            {
                return(false);
            }
            outValue.type        = type;
            outValue.data        = data[index + android.content.res.AssetManager.STYLE_DATA];
            outValue.assetCookie = data[index + android.content.res.AssetManager.STYLE_ASSET_COOKIE
                                   ];
            outValue.resourceId = data[index + android.content.res.AssetManager.STYLE_RESOURCE_ID
                                  ];
            outValue.changingConfigurations = data[index + android.content.res.AssetManager.STYLE_CHANGING_CONFIGURATIONS
                                              ];
            outValue.density = data[index + android.content.res.AssetManager.STYLE_DENSITY];
            outValue.@string = (type == android.util.TypedValue.TYPE_STRING) ? loadStringValueAt
                                   (index) : null;
            return(true);
        }
 public override android.view.View onCreateActionView()
 {
     // Create the view and set its data model.
     android.widget.ActivityChooserModel dataModel = android.widget.ActivityChooserModel
                                                     .get(mContext, mShareHistoryFileName);
     android.widget.ActivityChooserView activityChooserView = new android.widget.ActivityChooserView
                                                                  (mContext);
     activityChooserView.setActivityChooserModel(dataModel);
     // Lookup and set the expand action icon.
     android.util.TypedValue outTypedValue = new android.util.TypedValue();
     mContext.getTheme().resolveAttribute([email protected]
                                          , outTypedValue, true);
     android.graphics.drawable.Drawable drawable = mContext.getResources().getDrawable
                                                       (outTypedValue.resourceId);
     activityChooserView.setExpandActivityOverflowButtonDrawable(drawable);
     activityChooserView.setProvider(this);
     // Set content description.
     activityChooserView.setDefaultActionButtonContentDescription([email protected].
                                                                  @string.shareactionprovider_share_with_application);
     activityChooserView.setExpandActivityOverflowButtonContentDescription([email protected]
                                                                           [email protected]_share_with);
     return(activityChooserView);
 }
Exemple #24
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);
            }
        }
Exemple #25
0
		/// <summary>
		/// Synonym for opening the given resource and calling
		/// <see cref="decodeResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, Rect, Options)
		/// 	">decodeResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, Rect, Options)
		/// 	</see>
		/// .
		/// </summary>
		/// <param name="res">The resources object containing the image data</param>
		/// <param name="id">The resource id of the image data</param>
		/// <param name="opts">
		/// null-ok; Options that control downsampling and whether the
		/// image should be completely decoded, or just is size returned.
		/// </param>
		/// <returns>
		/// The decoded bitmap, or null if the image data could not be
		/// decoded, or, if opts is non-null, if opts requested only the
		/// size be returned (in opts.outWidth and opts.outHeight)
		/// </returns>
		public static android.graphics.Bitmap decodeResource(android.content.res.Resources
			 res, int id, android.graphics.BitmapFactory.Options opts)
		{
			android.graphics.Bitmap bm = null;
			java.io.InputStream @is = null;
			try
			{
				android.util.TypedValue value = new android.util.TypedValue();
				@is = res.openRawResource(id, value);
				bm = decodeResourceStream(res, value, @is, null, opts);
			}
			catch (System.Exception)
			{
			}
			finally
			{
				try
				{
					if (@is != null)
					{
						@is.close();
					}
				}
				catch (System.IO.IOException)
				{
				}
			}
			// Ignore
			if (bm == null && opts != null && opts.inBitmap != null)
			{
				throw new System.ArgumentException("Problem decoding into existing bitmap");
			}
			return bm;
		}
Exemple #26
0
		private int getSearchIconId()
		{
			android.util.TypedValue outValue = new android.util.TypedValue();
			getContext().getTheme().resolveAttribute([email protected]
				, outValue, true);
			return outValue.resourceId;
		}
Exemple #27
0
			public static android.util.TypedValue NativeToManaged(System.IntPtr ptr)
			{
				if (ptr == System.IntPtr.Zero)
				{
					return null;
				}
				TypedValue_Struct obj = (TypedValue_Struct)Marshal.PtrToStructure(ptr, typeof(TypedValue_Struct
					));
				android.util.TypedValue arg = new android.util.TypedValue();
				arg.type = obj.type;
				arg.data = obj.data;
				arg.@string = null;
				arg.assetCookie = obj.assetCookie;
				arg.resourceId = obj.resourceId;
				arg.density = obj.density;
				return arg;
			}
		public override android.view.View onCreateActionView()
		{
			// Create the view and set its data model.
			android.widget.ActivityChooserModel dataModel = android.widget.ActivityChooserModel
				.get(mContext, mShareHistoryFileName);
			android.widget.ActivityChooserView activityChooserView = new android.widget.ActivityChooserView
				(mContext);
			activityChooserView.setActivityChooserModel(dataModel);
			// Lookup and set the expand action icon.
			android.util.TypedValue outTypedValue = new android.util.TypedValue();
			mContext.getTheme().resolveAttribute([email protected]
				, outTypedValue, true);
			android.graphics.drawable.Drawable drawable = mContext.getResources().getDrawable
				(outTypedValue.resourceId);
			activityChooserView.setExpandActivityOverflowButtonDrawable(drawable);
			activityChooserView.setProvider(this);
			// Set content description.
			activityChooserView.setDefaultActionButtonContentDescription([email protected].
				@string.shareactionprovider_share_with_application);
			activityChooserView.setExpandActivityOverflowButtonContentDescription([email protected]
				[email protected]_share_with);
			return activityChooserView;
		}
Exemple #29
0
			/// <summary>
			/// Return a StyledAttributes holding the values defined by the style
			/// resource <var>resid</var> which are listed in <var>attrs</var>.
			/// </summary>
			/// <remarks>
			/// Return a StyledAttributes holding the values defined by the style
			/// resource <var>resid</var> which are listed in <var>attrs</var>.
			/// <p>Be sure to call StyledAttributes.recycle() when you are done with
			/// the array.
			/// </remarks>
			/// <param name="resid">The desired style resource.</param>
			/// <param name="attrs">The desired attributes in the style.</param>
			/// <exception cref="NotFoundException">Throws NotFoundException if the given ID does not exist.
			/// 	</exception>
			/// <returns>
			/// Returns a TypedArray holding an array of the attribute values.
			/// Be sure to call
			/// <see cref="TypedArray.recycle()">TypedArray.recycle()</see>
			/// when done with it.
			/// </returns>
			/// <seealso cref="Resources.obtainAttributes(android.util.AttributeSet, int[])">Resources.obtainAttributes(android.util.AttributeSet, int[])
			/// 	</seealso>
			/// <seealso cref="obtainStyledAttributes(int[])">obtainStyledAttributes(int[])</seealso>
			/// <seealso cref="obtainStyledAttributes(android.util.AttributeSet, int[], int, int)
			/// 	">obtainStyledAttributes(android.util.AttributeSet, int[], int, int)</seealso>
			/// <exception cref="android.content.res.Resources.NotFoundException"></exception>
			public android.content.res.TypedArray obtainStyledAttributes(int resid, int[] attrs
				)
			{
				int len = attrs.Length;
				android.content.res.TypedArray array = this._enclosing.getCachedStyledAttributes(
					len);
				array.mRsrcs = attrs;
				android.content.res.AssetManager.applyStyle(this.mTheme, 0, resid, null, attrs, array
					.mData, array.mIndices);
				if (false)
				{
					int[] data = array.mData;
					java.io.Console.Out.println("**********************************************************"
						);
					java.io.Console.Out.println("**********************************************************"
						);
					java.io.Console.Out.println("**********************************************************"
						);
					java.io.Console.Out.println("Attributes:");
					string s = "  Attrs:";
					int i;
					for (i = 0; i < attrs.Length; i++)
					{
						s = s + " 0x" + Sharpen.Util.IntToHexString(attrs[i]);
					}
					java.io.Console.Out.println(s);
					s = "  Found:";
					android.util.TypedValue value = new android.util.TypedValue();
					for (i = 0; i < attrs.Length; i++)
					{
						int d = i * android.content.res.AssetManager.STYLE_NUM_ENTRIES;
						value.type = data[d + android.content.res.AssetManager.STYLE_TYPE];
						value.data = data[d + android.content.res.AssetManager.STYLE_DATA];
						value.assetCookie = data[d + android.content.res.AssetManager.STYLE_ASSET_COOKIE];
						value.resourceId = data[d + android.content.res.AssetManager.STYLE_RESOURCE_ID];
						s = s + " 0x" + Sharpen.Util.IntToHexString(attrs[i]) + "=" + value;
					}
					java.io.Console.Out.println(s);
				}
				return array;
			}
		private java.lang.CharSequence formatUrl(java.lang.CharSequence url)
		{
			if (mUrlColor == null)
			{
				// Lazily get the URL color from the current theme.
				android.util.TypedValue colorValue = new android.util.TypedValue();
				mContext.getTheme().resolveAttribute([email protected], 
					colorValue, true);
				mUrlColor = mContext.getResources().getColorStateList(colorValue.resourceId);
			}
			android.text.SpannableString text = new android.text.SpannableString(url);
			text.setSpan(new android.text.style.TextAppearanceSpan(null, 0, 0, mUrlColor, null
				), 0, url.Length, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE);
			return text;
		}
Exemple #31
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);
        }
Exemple #32
0
 /// <summary>Retrieve the raw TypedValue for the attribute at <var>index</var>.</summary>
 /// <remarks>Retrieve the raw TypedValue for the attribute at <var>index</var>.</remarks>
 /// <param name="index">Index of attribute to retrieve.</param>
 /// <param name="outValue">
 /// TypedValue object in which to place the attribute's
 /// data.
 /// </param>
 /// <returns>Returns true if the value was retrieved, else false.</returns>
 public virtual bool getValue(int index, android.util.TypedValue outValue)
 {
     return(getValueAt(index * android.content.res.AssetManager.STYLE_NUM_ENTRIES, outValue
                       ));
 }
Exemple #33
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();
 }
Exemple #34
0
 public static global::android.graphics.Bitmap decodeResourceStream(android.content.res.Resources arg0, android.util.TypedValue arg1, java.io.InputStream arg2, android.graphics.Rect arg3, android.graphics.BitmapFactory.Options arg4)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     return(global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallStaticObjectMethod(android.graphics.BitmapFactory.staticClass, global::android.graphics.BitmapFactory._decodeResourceStream3149, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg4))) as android.graphics.Bitmap);
 }
Exemple #35
0
 // Util
 private int convertDpToPx(Context context, float dp)
 {
     return((int)TypedValue.applyDimension(COMPLEX_UNIT_DIP, dp, context.Resources.DisplayMetrics));
 }
Exemple #36
0
		public override android.content.Context getThemedContext()
		{
			if (mThemedContext == null)
			{
				android.util.TypedValue outValue = new android.util.TypedValue();
				android.content.res.Resources.Theme currentTheme = mContext.getTheme();
				currentTheme.resolveAttribute([email protected], outValue
					, true);
				int targetThemeRes = outValue.resourceId;
				if (targetThemeRes != 0 && mContext.getThemeResId() != targetThemeRes)
				{
					mThemedContext = new android.view.ContextThemeWrapper(mContext, targetThemeRes);
				}
				else
				{
					mThemedContext = mContext;
				}
			}
			return mThemedContext;
		}
Exemple #37
0
		public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
			 parser, android.util.AttributeSet attrs)
		{
			base.inflate(r, parser, attrs);
			android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
				styleable.NinePatchDrawable);
			int id = a.getResourceId([email protected]_src, 0);
			if (id == 0)
			{
				throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
					 ": <nine-patch> requires a valid src attribute");
			}
			bool dither = a.getBoolean([email protected]_dither
				, DEFAULT_DITHER);
			android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory
				.Options();
			if (dither)
			{
				options.inDither = false;
			}
			options.inScreenDensity = android.util.DisplayMetrics.DENSITY_DEVICE;
			android.graphics.Rect padding = new android.graphics.Rect();
			android.graphics.Bitmap bitmap = null;
			try
			{
				android.util.TypedValue value = new android.util.TypedValue();
				java.io.InputStream @is = r.openRawResource(id, value);
				bitmap = android.graphics.BitmapFactory.decodeResourceStream(r, value, @is, padding
					, options);
				@is.close();
			}
			catch (System.IO.IOException)
			{
			}
			// Ignore
			if (bitmap == null)
			{
				throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
					 ": <nine-patch> requires a valid src attribute");
			}
			else
			{
				if (bitmap.getNinePatchChunk() == null)
				{
					throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
						 ": <nine-patch> requires a valid 9-patch source image");
				}
			}
			setNinePatchState(new android.graphics.drawable.NinePatchDrawable.NinePatchState(
				new android.graphics.NinePatch(bitmap, bitmap.getNinePatchChunk(), "XML 9-patch"
				), padding, dither), r);
			mNinePatchState.mTargetDensity = mTargetDensity;
			a.recycle();
		}
Exemple #38
0
			/// <summary>
			/// Return a StyledAttributes holding the attribute values in
			/// <var>set</var>
			/// that are listed in <var>attrs</var>.
			/// </summary>
			/// <remarks>
			/// Return a StyledAttributes holding the attribute values in
			/// <var>set</var>
			/// that are listed in <var>attrs</var>.  In addition, if the given
			/// AttributeSet specifies a style class (through the "style" attribute),
			/// that style will be applied on top of the base attributes it defines.
			/// <p>Be sure to call StyledAttributes.recycle() when you are done with
			/// the array.
			/// <p>When determining the final value of a particular attribute, there
			/// are four inputs that come into play:</p>
			/// <ol>
			/// <li> Any attribute values in the given AttributeSet.
			/// <li> The style resource specified in the AttributeSet (named
			/// "style").
			/// <li> The default style specified by <var>defStyleAttr</var> and
			/// <var>defStyleRes</var>
			/// <li> The base values in this theme.
			/// </ol>
			/// <p>Each of these inputs is considered in-order, with the first listed
			/// taking precedence over the following ones.  In other words, if in the
			/// AttributeSet you have supplied <code>&lt;Button
			/// textColor="#ff000000"&gt;</code>, then the button's text will
			/// <em>always</em> be black, regardless of what is specified in any of
			/// the styles.
			/// </remarks>
			/// <param name="set">The base set of attribute values.  May be null.</param>
			/// <param name="attrs">The desired attributes to be retrieved.</param>
			/// <param name="defStyleAttr">
			/// An attribute in the current theme that contains a
			/// reference to a style resource that supplies
			/// defaults values for the StyledAttributes.  Can be
			/// 0 to not look for defaults.
			/// </param>
			/// <param name="defStyleRes">
			/// A resource identifier of a style resource that
			/// supplies default values for the StyledAttributes,
			/// used only if defStyleAttr is 0 or can not be found
			/// in the theme.  Can be 0 to not look for defaults.
			/// </param>
			/// <returns>
			/// Returns a TypedArray holding an array of the attribute values.
			/// Be sure to call
			/// <see cref="TypedArray.recycle()">TypedArray.recycle()</see>
			/// when done with it.
			/// </returns>
			/// <seealso cref="Resources.obtainAttributes(android.util.AttributeSet, int[])">Resources.obtainAttributes(android.util.AttributeSet, int[])
			/// 	</seealso>
			/// <seealso cref="obtainStyledAttributes(int[])">obtainStyledAttributes(int[])</seealso>
			/// <seealso cref="obtainStyledAttributes(int, int[])">obtainStyledAttributes(int, int[])
			/// 	</seealso>
			public android.content.res.TypedArray obtainStyledAttributes(android.util.AttributeSet
				 set, int[] attrs, int defStyleAttr, int defStyleRes)
			{
				int len = attrs.Length;
				android.content.res.TypedArray array = this._enclosing.getCachedStyledAttributes(
					len);
				// XXX note that for now we only work with compiled XML files.
				// To support generic XML files we will need to manually parse
				// out the attributes from the XML file (applying type information
				// contained in the resources and such).
				android.content.res.XmlBlock.Parser parser = (android.content.res.XmlBlock.Parser
					)set;
				android.content.res.AssetManager.applyStyle(this.mTheme, defStyleAttr, defStyleRes
					, parser != null ? parser.mParseState : null, attrs, array.mData, array.mIndices
					);
				array.mRsrcs = attrs;
				array.mXml = parser;
				if (false)
				{
					int[] data = array.mData;
					java.io.Console.Out.println("Attributes:");
					string s = "  Attrs:";
					int i;
					for (i = 0; i < set.getAttributeCount(); i++)
					{
						s = s + " " + set.getAttributeName(i);
						int id = set.getAttributeNameResource(i);
						if (id != 0)
						{
							s = s + "(0x" + Sharpen.Util.IntToHexString(id) + ")";
						}
						s = s + "=" + set.getAttributeValue(i);
					}
					java.io.Console.Out.println(s);
					s = "  Found:";
					android.util.TypedValue value = new android.util.TypedValue();
					for (i = 0; i < attrs.Length; i++)
					{
						int d = i * android.content.res.AssetManager.STYLE_NUM_ENTRIES;
						value.type = data[d + android.content.res.AssetManager.STYLE_TYPE];
						value.data = data[d + android.content.res.AssetManager.STYLE_DATA];
						value.assetCookie = data[d + android.content.res.AssetManager.STYLE_ASSET_COOKIE];
						value.resourceId = data[d + android.content.res.AssetManager.STYLE_RESOURCE_ID];
						s = s + " 0x" + Sharpen.Util.IntToHexString(attrs[i]) + "=" + value;
					}
					java.io.Console.Out.println(s);
				}
				return array;
			}
Exemple #39
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);
            }
        }