Esempio n. 1
0
		public XmlPullParserException(string msg, org.xmlpull.v1.XmlPullParser parser, System.Exception
			 chain) : base((msg == null ? string.Empty : msg + " ") + (parser == null ? string.Empty
			 : "(position:" + parser.getPositionDescription() + ") ") + (chain == null ? string.Empty
			 : "caused by: " + chain))
		{
			// for license please see accompanying LICENSE.txt file (available also at http://www.xmlpull.org/)
			if (parser != null)
			{
				this.row = parser.getLineNumber();
				this.column = parser.getColumnNumber();
			}
			this.detail = chain;
		}
Esempio n. 2
0
		/// <summary>Inflate a new view hierarchy from the specified XML node.</summary>
		/// <remarks>
		/// Inflate a new view hierarchy from the specified XML node. Throws
		/// <see cref="InflateException">InflateException</see>
		/// if there is an error.
		/// <p>
		/// <em><strong>Important</strong></em>&nbsp;&nbsp;&nbsp;For performance
		/// reasons, view inflation relies heavily on pre-processing of XML files
		/// that is done at build time. Therefore, it is not currently possible to
		/// use LayoutInflater with an XmlPullParser over a plain XML file at runtime.
		/// </remarks>
		/// <param name="parser">
		/// XML dom node containing the description of the view
		/// hierarchy.
		/// </param>
		/// <param name="root">
		/// Optional view to be the parent of the generated hierarchy (if
		/// <em>attachToRoot</em> is true), or else simply an object that
		/// provides a set of LayoutParams values for root of the returned
		/// hierarchy (if <em>attachToRoot</em> is false.)
		/// </param>
		/// <param name="attachToRoot">
		/// Whether the inflated hierarchy should be attached to
		/// the root parameter? If false, root is only used to create the
		/// correct subclass of LayoutParams for the root view in the XML.
		/// </param>
		/// <returns>
		/// The root View of the inflated hierarchy. If root was supplied and
		/// attachToRoot is true, this is root; otherwise it is the root of
		/// the inflated XML file.
		/// </returns>
		public virtual android.view.View inflate(org.xmlpull.v1.XmlPullParser parser, android.view.ViewGroup
			 root, bool attachToRoot)
		{
			lock (mConstructorArgs)
			{
				android.util.AttributeSet attrs = android.util.Xml.asAttributeSet(parser);
				android.content.Context lastContext = (android.content.Context)mConstructorArgs[0
					];
				mConstructorArgs[0] = mContext;
				android.view.View result = root;
				try
				{
					// Look for the root node.
					int type;
					while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.START_TAG && type
						 != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT)
					{
					}
					// Empty
					if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
					{
						throw new android.view.InflateException(parser.getPositionDescription() + ": No start tag found!"
							);
					}
					string name = parser.getName();
					if (TAG_MERGE.Equals(name))
					{
						if (root == null || !attachToRoot)
						{
							throw new android.view.InflateException("<merge /> can be used only with a valid "
								 + "ViewGroup root and attachToRoot=true");
						}
						rInflate(parser, root, attrs, false);
					}
					else
					{
						// Temp is the root view that was found in the xml
						android.view.View temp;
						if (TAG_1995.Equals(name))
						{
							temp = new android.view.LayoutInflater.BlinkLayout(mContext, attrs);
						}
						else
						{
							temp = createViewFromTag(root, name, attrs);
						}
						android.view.ViewGroup.LayoutParams @params = null;
						if (root != null)
						{
							// Create layout params that match root, if supplied
							@params = root.generateLayoutParams(attrs);
							if (!attachToRoot)
							{
								// Set the layout params for temp if we are not
								// attaching. (If we are, we use addView, below)
								temp.setLayoutParams(@params);
							}
						}
						// Inflate all children under temp
						rInflate(parser, temp, attrs, true);
						// We are supposed to attach all the views we found (int temp)
						// to root. Do that now.
						if (root != null && attachToRoot)
						{
							root.addView(temp, @params);
						}
						// Decide whether to return the root that was passed in or the
						// top view found in xml.
						if (root == null || !attachToRoot)
						{
							result = temp;
						}
					}
				}
				catch (org.xmlpull.v1.XmlPullParserException e)
				{
					android.view.InflateException ex = new android.view.InflateException(e.Message);
					ex.InnerException = e;
					throw ex;
				}
				catch (System.IO.IOException e)
				{
					android.view.InflateException ex = new android.view.InflateException(parser.getPositionDescription
						() + ": " + e.Message);
					ex.InnerException = e;
					throw ex;
				}
				finally
				{
					// Don't retain static reference on context.
					mConstructorArgs[0] = lastContext;
					mConstructorArgs[1] = null;
				}
				return result;
			}
		}
Esempio n. 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);
			}
		}
Esempio n. 4
0
		/// <summary>Create from inside an XML document.</summary>
		/// <remarks>
		/// Create from inside an XML document.  Called on a parser positioned at
		/// a tag in an XML document, tries to create a Drawable from that tag.
		/// Returns null if the tag is not a valid drawable.
		/// </remarks>
		/// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public static android.graphics.drawable.Drawable createFromXmlInner(android.content.res.Resources
			 r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs)
		{
			android.graphics.drawable.Drawable drawable;
			string name = parser.getName();
			if (name.Equals("selector"))
			{
				drawable = new android.graphics.drawable.StateListDrawable();
			}
			else
			{
				if (name.Equals("level-list"))
				{
					drawable = new android.graphics.drawable.LevelListDrawable();
				}
				else
				{
					if (name.Equals("layer-list"))
					{
						drawable = new android.graphics.drawable.LayerDrawable();
					}
					else
					{
						if (name.Equals("transition"))
						{
							drawable = new android.graphics.drawable.TransitionDrawable();
						}
						else
						{
							if (name.Equals("color"))
							{
								drawable = new android.graphics.drawable.ColorDrawable();
							}
							else
							{
								if (name.Equals("shape"))
								{
									drawable = new android.graphics.drawable.GradientDrawable();
								}
								else
								{
									if (name.Equals("scale"))
									{
										drawable = new android.graphics.drawable.ScaleDrawable();
									}
									else
									{
										if (name.Equals("clip"))
										{
											drawable = new android.graphics.drawable.ClipDrawable();
										}
										else
										{
											if (name.Equals("rotate"))
											{
												drawable = new android.graphics.drawable.RotateDrawable();
											}
											else
											{
												if (name.Equals("animated-rotate"))
												{
													drawable = new android.graphics.drawable.AnimatedRotateDrawable();
												}
												else
												{
													if (name.Equals("animation-list"))
													{
														drawable = new android.graphics.drawable.AnimationDrawable();
													}
													else
													{
														if (name.Equals("inset"))
														{
															drawable = new android.graphics.drawable.InsetDrawable();
														}
														else
														{
															if (name.Equals("bitmap"))
															{
																drawable = new android.graphics.drawable.BitmapDrawable(r);
																if (r != null)
																{
																	((android.graphics.drawable.BitmapDrawable)drawable).setTargetDensity(r.getDisplayMetrics
																		());
																}
															}
															else
															{
																if (name.Equals("nine-patch"))
																{
																	drawable = new android.graphics.drawable.NinePatchDrawable();
																	if (r != null)
																	{
																		((android.graphics.drawable.NinePatchDrawable)drawable).setTargetDensity(r.getDisplayMetrics
																			());
																	}
																}
																else
																{
																	throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
																		 ": invalid drawable tag " + name);
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			drawable.inflate(r, parser, attrs);
			return drawable;
		}
Esempio n. 5
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();
		}
Esempio n. 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.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();
		}
Esempio n. 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);
			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());
		}
Esempio n. 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);
			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();
		}
Esempio n. 9
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());
		}
Esempio n. 10
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);
		}