Beispiel #1
0
		public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
			 parser, android.util.AttributeSet attrs)
		{
			base.inflate(r, parser, attrs);
			int type;
			android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
				styleable.ClipDrawable);
			int orientation = a.getInt([email protected]_clipOrientation
				, HORIZONTAL);
			int g = a.getInt([email protected]_gravity, android.view.Gravity
				.LEFT);
			android.graphics.drawable.Drawable dr = a.getDrawable([email protected]
				.ClipDrawable_drawable);
			a.recycle();
			int outerDepth = parser.getDepth();
			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;
				}
				dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
			}
			if (dr == null)
			{
				throw new System.ArgumentException("No drawable specified for <clip>");
			}
			mClipState.mDrawable = dr;
			mClipState.mOrientation = orientation;
			mClipState.mGravity = g;
			dr.setCallback(this);
		}
Beispiel #2
0
		protected internal override bool inflateTag(string name, android.content.res.Resources
			 r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs)
		{
			if (name.Equals("corners"))
			{
				android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
					styleable.DrawableCorners);
				int radius = a.getDimensionPixelSize([email protected]_radius
					, 0);
				setCornerRadius(radius);
				// now check of they have any per-corner radii
				int topLeftRadius = a.getDimensionPixelSize([email protected]_topLeftRadius
					, radius);
				int topRightRadius = a.getDimensionPixelSize([email protected]_topRightRadius
					, radius);
				int bottomLeftRadius = a.getDimensionPixelSize([email protected]_bottomLeftRadius
					, radius);
				int bottomRightRadius = a.getDimensionPixelSize([email protected]_bottomRightRadius
					, radius);
				if (topLeftRadius != radius || topRightRadius != radius || bottomLeftRadius != radius
					 || bottomRightRadius != radius)
				{
					setCornerRadii(new float[] { topLeftRadius, topLeftRadius, topRightRadius, topRightRadius
						, bottomLeftRadius, bottomLeftRadius, bottomRightRadius, bottomRightRadius });
				}
				a.recycle();
				return true;
			}
			return base.inflateTag(name, r, parser, attrs);
		}
Beispiel #3
0
		public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
			 parser, android.util.AttributeSet attrs)
		{
			int type;
			android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
				styleable.InsetDrawable);
			base.inflateWithAttributes(r, parser, a, [email protected]_visible
				);
			int drawableRes = a.getResourceId([email protected]_drawable
				, 0);
			int inLeft = a.getDimensionPixelOffset([email protected]_insetLeft
				, 0);
			int inTop = a.getDimensionPixelOffset([email protected]_insetTop
				, 0);
			int inRight = a.getDimensionPixelOffset([email protected]_insetRight
				, 0);
			int inBottom = a.getDimensionPixelOffset([email protected]_insetBottom
				, 0);
			a.recycle();
			android.graphics.drawable.Drawable dr;
			if (drawableRes != 0)
			{
				dr = r.getDrawable(drawableRes);
			}
			else
			{
				while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
				{
				}
				if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
				{
					throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
						 ": <inset> tag requires a 'drawable' attribute or " + "child tag defining a drawable"
						);
				}
				dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
			}
			if (dr == null)
			{
				android.util.Log.w("drawable", "No drawable specified for <inset>");
			}
			mInsetState.mDrawable = dr;
			mInsetState.mInsetLeft = inLeft;
			mInsetState.mInsetRight = inRight;
			mInsetState.mInsetTop = inTop;
			mInsetState.mInsetBottom = inBottom;
			if (dr != null)
			{
				dr.setCallback(this);
			}
		}
Beispiel #4
0
		public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
			 parser, android.util.AttributeSet attrs)
		{
			base.inflate(r, parser, attrs);
			int type;
			android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
				styleable.ScaleDrawable);
			float sw = getPercent(a, [email protected]_scaleWidth);
			float sh = getPercent(a, [email protected]_scaleHeight);
			int g = a.getInt([email protected]_scaleGravity, android.view.Gravity
				.LEFT);
			bool min = a.getBoolean([email protected]_useIntrinsicSizeAsMinimum
				, false);
			android.graphics.drawable.Drawable dr = a.getDrawable([email protected]
				.ScaleDrawable_drawable);
			a.recycle();
			int outerDepth = parser.getDepth();
			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;
				}
				dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
			}
			if (dr == null)
			{
				throw new System.ArgumentException("No drawable specified for <scale>");
			}
			mScaleState.mDrawable = dr;
			mScaleState.mScaleWidth = sw;
			mScaleState.mScaleHeight = sh;
			mScaleState.mGravity = g;
			mScaleState.mUseIntrinsicSizeAsMin = min;
			if (dr != null)
			{
				dr.setCallback(this);
			}
		}
Beispiel #5
0
		/// <summary>Inflate this Drawable from an XML resource.</summary>
		/// <remarks>Inflate this Drawable from an XML resource.</remarks>
		/// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public virtual 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.Drawable);
			inflateWithAttributes(r, parser, a, [email protected]_visible
				);
			a.recycle();
		}
Beispiel #6
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.BitmapDrawable);
			int id = a.getResourceId([email protected]_src, 0);
			if (id == 0)
			{
				throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
					 ": <bitmap> requires a valid src attribute");
			}
			android.graphics.Bitmap bitmap = android.graphics.BitmapFactory.decodeResource(r, 
				id);
			if (bitmap == null)
			{
				throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
					 ": <bitmap> requires a valid src attribute");
			}
			mBitmapState.mBitmap = bitmap;
			setBitmap(bitmap);
			setTargetDensity(r.getDisplayMetrics());
			android.graphics.Paint paint = mBitmapState.mPaint;
			paint.setAntiAlias(a.getBoolean([email protected]_antialias
				, paint.isAntiAlias()));
			paint.setFilterBitmap(a.getBoolean([email protected]_filter
				, paint.isFilterBitmap()));
			paint.setDither(a.getBoolean([email protected]_dither, 
				paint.isDither()));
			setGravity(a.getInt([email protected]_gravity, android.view.Gravity
				.FILL));
			int tileMode = a.getInt([email protected]_tileMode, -1
				);
			if (tileMode != -1)
			{
				switch (tileMode)
				{
					case 0:
					{
						setTileModeXY(android.graphics.Shader.TileMode.CLAMP, android.graphics.Shader.TileMode
							.CLAMP);
						break;
					}

					case 1:
					{
						setTileModeXY(android.graphics.Shader.TileMode.REPEAT, android.graphics.Shader.TileMode
							.REPEAT);
						break;
					}

					case 2:
					{
						setTileModeXY(android.graphics.Shader.TileMode.MIRROR, android.graphics.Shader.TileMode
							.MIRROR);
						break;
					}
				}
			}
			a.recycle();
		}
Beispiel #7
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.ColorDrawable);
			int color = mState.mBaseColor;
			color = a.getColor([email protected]_color, color);
			mState.mBaseColor = mState.mUseColor = color;
			a.recycle();
		}
Beispiel #8
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.ShapeDrawable);
			int color = mShapeState.mPaint.getColor();
			color = a.getColor([email protected]_color, color);
			mShapeState.mPaint.setColor(color);
			bool dither = a.getBoolean([email protected]_dither, false
				);
			mShapeState.mPaint.setDither(dither);
			setIntrinsicWidth((int)a.getDimension([email protected]_width
				, 0f));
			setIntrinsicHeight((int)a.getDimension([email protected]_height
				, 0f));
			a.recycle();
			int type;
			int outerDepth = parser.getDepth();
			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;
				}
				string name = parser.getName();
				// call our subclass
				if (!inflateTag(name, r, parser, attrs))
				{
					android.util.Log.w("drawable", "Unknown element: " + name + " for ShapeDrawable "
						 + this);
				}
			}
		}
Beispiel #9
0
		/// <summary>Subclasses override this to parse custom subelements.</summary>
		/// <remarks>
		/// Subclasses override this to parse custom subelements.
		/// If you handle it, return true, else return <em>super.inflateTag(...)</em>.
		/// </remarks>
		protected internal virtual bool inflateTag(string name, android.content.res.Resources
			 r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs)
		{
			if ("padding".Equals(name))
			{
				android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
					styleable.ShapeDrawablePadding);
				setPadding(a.getDimensionPixelOffset([email protected]_left
					, 0), a.getDimensionPixelOffset([email protected]_top
					, 0), a.getDimensionPixelOffset([email protected]_right
					, 0), a.getDimensionPixelOffset([email protected]_bottom
					, 0));
				a.recycle();
				return true;
			}
			return false;
		}
Beispiel #10
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();
		}
Beispiel #11
0
		public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
			 parser, android.util.AttributeSet attrs)
		{
			android.graphics.drawable.GradientDrawable.GradientState st = mGradientState;
			android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
				styleable.GradientDrawable);
			base.inflateWithAttributes(r, parser, a, [email protected]_visible
				);
			int shapeType = a.getInt([email protected]_shape, RECTANGLE
				);
			bool dither = a.getBoolean([email protected]_dither, 
				false);
			if (shapeType == RING)
			{
				st.mInnerRadius = a.getDimensionPixelSize([email protected]_innerRadius
					, -1);
				if (st.mInnerRadius == -1)
				{
					st.mInnerRadiusRatio = a.getFloat([email protected]_innerRadiusRatio
						, 3.0f);
				}
				st.mThickness = a.getDimensionPixelSize([email protected]_thickness
					, -1);
				if (st.mThickness == -1)
				{
					st.mThicknessRatio = a.getFloat([email protected]_thicknessRatio
						, 9.0f);
				}
				st.mUseLevelForShape = a.getBoolean([email protected]_useLevel
					, true);
			}
			a.recycle();
			setShape(shapeType);
			setDither(dither);
			int type;
			int innerDepth = parser.getDepth() + 1;
			int depth;
			while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
				 ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
				))
			{
				if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
				{
					continue;
				}
				if (depth > innerDepth)
				{
					continue;
				}
				string name = parser.getName();
				if (name.Equals("size"))
				{
					a = r.obtainAttributes(attrs, [email protected]);
					int width = a.getDimensionPixelSize([email protected]_width
						, -1);
					int height = a.getDimensionPixelSize([email protected]_height
						, -1);
					a.recycle();
					setSize(width, height);
				}
				else
				{
					if (name.Equals("gradient"))
					{
						a = r.obtainAttributes(attrs, [email protected]
							);
						int startColor = a.getColor([email protected]_startColor
							, 0);
						bool hasCenterColor = a.hasValue([email protected]_centerColor
							);
						int centerColor = a.getColor([email protected]_centerColor
							, 0);
						int endColor = a.getColor([email protected]_endColor
							, 0);
						int gradientType = a.getInt([email protected]_type
							, LINEAR_GRADIENT);
						st.mCenterX = getFloatOrFraction(a, [email protected]_centerX
							, 0.5f);
						st.mCenterY = getFloatOrFraction(a, [email protected]_centerY
							, 0.5f);
						st.mUseLevel = a.getBoolean([email protected]_useLevel
							, false);
						st.mGradient = gradientType;
						if (gradientType == LINEAR_GRADIENT)
						{
							int angle = (int)a.getFloat([email protected]_angle
								, 0);
							angle %= 360;
							if (angle % 45 != 0)
							{
								throw new org.xmlpull.v1.XmlPullParserException(a.getPositionDescription() + "<gradient> tag requires 'angle' attribute to "
									 + "be a multiple of 45");
							}
							switch (angle)
							{
								case 0:
								{
									st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.LEFT_RIGHT;
									break;
								}

								case 45:
								{
									st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.BL_TR;
									break;
								}

								case 90:
								{
									st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.BOTTOM_TOP;
									break;
								}

								case 135:
								{
									st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.BR_TL;
									break;
								}

								case 180:
								{
									st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.RIGHT_LEFT;
									break;
								}

								case 225:
								{
									st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.TR_BL;
									break;
								}

								case 270:
								{
									st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.TOP_BOTTOM;
									break;
								}

								case 315:
								{
									st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.TL_BR;
									break;
								}
							}
						}
						else
						{
							android.util.TypedValue tv = a.peekValue([email protected]_gradientRadius
								);
							if (tv != null)
							{
								bool radiusRel = tv.type == android.util.TypedValue.TYPE_FRACTION;
								st.mGradientRadius = radiusRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
							}
							else
							{
								if (gradientType == RADIAL_GRADIENT)
								{
									throw new org.xmlpull.v1.XmlPullParserException(a.getPositionDescription() + "<gradient> tag requires 'gradientRadius' "
										 + "attribute with radial type");
								}
							}
						}
						a.recycle();
						if (hasCenterColor)
						{
							st.mColors = new int[3];
							st.mColors[0] = startColor;
							st.mColors[1] = centerColor;
							st.mColors[2] = endColor;
							st.mPositions = new float[3];
							st.mPositions[0] = 0.0f;
							// Since 0.5f is default value, try to take the one that isn't 0.5f
							st.mPositions[1] = st.mCenterX != 0.5f ? st.mCenterX : st.mCenterY;
							st.mPositions[2] = 1f;
						}
						else
						{
							st.mColors = new int[2];
							st.mColors[0] = startColor;
							st.mColors[1] = endColor;
						}
					}
					else
					{
						if (name.Equals("solid"))
						{
							a = r.obtainAttributes(attrs, [email protected]
								);
							int argb = a.getColor([email protected]_color, 
								0);
							a.recycle();
							setColor(argb);
						}
						else
						{
							if (name.Equals("stroke"))
							{
								a = r.obtainAttributes(attrs, [email protected]
									);
								int width = a.getDimensionPixelSize([email protected]_width
									, 0);
								int color = a.getColor([email protected]_color
									, 0);
								float dashWidth = a.getDimension([email protected]_dashWidth
									, 0);
								if (dashWidth != 0.0f)
								{
									float dashGap = a.getDimension([email protected]_dashGap
										, 0);
									setStroke(width, color, dashWidth, dashGap);
								}
								else
								{
									setStroke(width, color);
								}
								a.recycle();
							}
							else
							{
								if (name.Equals("corners"))
								{
									a = r.obtainAttributes(attrs, [email protected]);
									int radius = a.getDimensionPixelSize([email protected]_radius
										, 0);
									setCornerRadius(radius);
									int topLeftRadius = a.getDimensionPixelSize([email protected]_topLeftRadius
										, radius);
									int topRightRadius = a.getDimensionPixelSize([email protected]_topRightRadius
										, radius);
									int bottomLeftRadius = a.getDimensionPixelSize([email protected]_bottomLeftRadius
										, radius);
									int bottomRightRadius = a.getDimensionPixelSize([email protected]_bottomRightRadius
										, radius);
									if (topLeftRadius != radius || topRightRadius != radius || bottomLeftRadius != radius
										 || bottomRightRadius != radius)
									{
										// The corner radii are specified in clockwise order (see Path.addRoundRect())
										setCornerRadii(new float[] { topLeftRadius, topLeftRadius, topRightRadius, topRightRadius
											, bottomRightRadius, bottomRightRadius, bottomLeftRadius, bottomLeftRadius });
									}
									a.recycle();
								}
								else
								{
									if (name.Equals("padding"))
									{
										a = r.obtainAttributes(attrs, [email protected]
											);
										mPadding = new android.graphics.Rect(a.getDimensionPixelOffset([email protected]
											.styleable.GradientDrawablePadding_left, 0), a.getDimensionPixelOffset([email protected]
											.styleable.GradientDrawablePadding_top, 0), a.getDimensionPixelOffset([email protected]
											.styleable.GradientDrawablePadding_right, 0), a.getDimensionPixelOffset([email protected]
											.styleable.GradientDrawablePadding_bottom, 0));
										a.recycle();
										mGradientState.mPadding = mPadding;
									}
									else
									{
										android.util.Log.w("drawable", "Bad element under <shape>: " + name);
									}
								}
							}
						}
					}
				}
			}
		}
Beispiel #12
0
		public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
			 parser, android.util.AttributeSet attrs)
		{
			base.inflate(r, parser, attrs);
			int type;
			int innerDepth = parser.getDepth() + 1;
			int depth;
			while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
				 ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
				))
			{
				if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
				{
					continue;
				}
				if (depth > innerDepth || !parser.getName().Equals("item"))
				{
					continue;
				}
				android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
					styleable.MipmapDrawableItem);
				int drawableRes = a.getResourceId([email protected]_drawable
					, 0);
				a.recycle();
				android.graphics.drawable.Drawable dr;
				if (drawableRes != 0)
				{
					dr = r.getDrawable(drawableRes);
				}
				else
				{
					while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
					{
					}
					if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
					{
						throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
							 ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable"
							);
					}
					dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
				}
				mMipmapContainerState.addDrawable(dr);
			}
			onDrawableAdded();
		}
Beispiel #13
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.StateListDrawable);
			base.inflateWithAttributes(r, parser, a, [email protected]_visible
				);
			mStateListState.setVariablePadding(a.getBoolean([email protected]_variablePadding
				, false));
			mStateListState.setConstantSize(a.getBoolean([email protected]_constantSize
				, false));
			mStateListState.setEnterFadeDuration(a.getInt([email protected]_enterFadeDuration
				, 0));
			mStateListState.setExitFadeDuration(a.getInt([email protected]_exitFadeDuration
				, 0));
			setDither(a.getBoolean([email protected]_dither, DEFAULT_DITHER
				));
			a.recycle();
			int type;
			int innerDepth = parser.getDepth() + 1;
			int depth;
			while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
				 ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
				))
			{
				if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
				{
					continue;
				}
				if (depth > innerDepth || !parser.getName().Equals("item"))
				{
					continue;
				}
				int drawableRes = 0;
				int i;
				int j = 0;
				int numAttrs = attrs.getAttributeCount();
				int[] states = new int[numAttrs];
				for (i = 0; i < numAttrs; i++)
				{
					int stateResId = attrs.getAttributeNameResource(i);
					if (stateResId == 0)
					{
						break;
					}
					if (stateResId == [email protected])
					{
						drawableRes = attrs.getAttributeResourceValue(i, 0);
					}
					else
					{
						states[j++] = attrs.getAttributeBooleanValue(i, false) ? stateResId : -stateResId;
					}
				}
				states = android.util.StateSet.trimStateSet(states, j);
				android.graphics.drawable.Drawable dr;
				if (drawableRes != 0)
				{
					dr = r.getDrawable(drawableRes);
				}
				else
				{
					while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
					{
					}
					if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
					{
						throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
							 ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable"
							);
					}
					dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
				}
				mStateListState.addStateSet(states, dr);
			}
			onStateChange(getState());
		}
Beispiel #14
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);
			}
		}
Beispiel #15
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.AnimationDrawable);
			base.inflateWithAttributes(r, parser, a, [email protected]_visible
				);
			mAnimationState.setVariablePadding(a.getBoolean([email protected]_variablePadding
				, false));
			mAnimationState.mOneShot = a.getBoolean([email protected]_oneshot
				, false);
			a.recycle();
			int type;
			int innerDepth = parser.getDepth() + 1;
			int depth;
			while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
				 ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
				))
			{
				if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
				{
					continue;
				}
				if (depth > innerDepth || !parser.getName().Equals("item"))
				{
					continue;
				}
				a = r.obtainAttributes(attrs, [email protected]
					);
				int duration = a.getInt([email protected]_duration
					, -1);
				if (duration < 0)
				{
					throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
						 ": <item> tag requires a 'duration' attribute");
				}
				int drawableRes = a.getResourceId([email protected]_drawable
					, 0);
				a.recycle();
				android.graphics.drawable.Drawable dr;
				if (drawableRes != 0)
				{
					dr = r.getDrawable(drawableRes);
				}
				else
				{
					while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
					{
					}
					// Empty
					if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
					{
						throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
							 ": <item> tag requires a 'drawable' attribute or child tag" + " defining a drawable"
							);
					}
					dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
				}
				mAnimationState.addFrame(dr, duration);
				if (dr != null)
				{
					dr.setCallback(this);
				}
			}
			setFrame(0, true, false);
		}
Beispiel #16
0
		public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
			 parser, android.util.AttributeSet attrs)
		{
			base.inflate(r, parser, attrs);
			int type;
			android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
				styleable.LayerDrawable);
			mOpacityOverride = a.getInt([email protected]_opacity, 
				android.graphics.PixelFormat.UNKNOWN);
			a.recycle();
			int innerDepth = parser.getDepth() + 1;
			int depth;
			while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
				 ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
				))
			{
				if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
				{
					continue;
				}
				if (depth > innerDepth || !parser.getName().Equals("item"))
				{
					continue;
				}
				a = r.obtainAttributes(attrs, [email protected]);
				int left = a.getDimensionPixelOffset([email protected]_left
					, 0);
				int top = a.getDimensionPixelOffset([email protected]_top
					, 0);
				int right = a.getDimensionPixelOffset([email protected]_right
					, 0);
				int bottom = a.getDimensionPixelOffset([email protected]_bottom
					, 0);
				int drawableRes = a.getResourceId([email protected]_drawable
					, 0);
				int id = a.getResourceId([email protected]_id, android.view.View
					.NO_ID);
				a.recycle();
				android.graphics.drawable.Drawable dr;
				if (drawableRes != 0)
				{
					dr = r.getDrawable(drawableRes);
				}
				else
				{
					while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
					{
					}
					if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
					{
						throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
							 ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable"
							);
					}
					dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
				}
				addLayer(dr, id, left, top, right, bottom);
			}
			ensurePadding();
			onStateChange(getState());
		}
		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);
			}
		}