Exemplo n.º 1
0
		private static float getPercent(android.content.res.TypedArray a, int name)
		{
			string s = a.getString(name);
			if (s != null)
			{
				if (s.EndsWith("%"))
				{
					string f = Sharpen.StringHelper.Substring(s, 0, s.Length - 1);
					return float.Parse(f) / 100.0f;
				}
			}
			return -1;
		}
Exemplo n.º 2
0
		public override java.lang.CharSequence convertToString(android.database.Cursor cursor
			)
		{
			if (mCursorToStringConverter != null)
			{
				return mCursorToStringConverter.convertToString(cursor);
			}
			else
			{
				if (mStringConversionColumn > -1)
				{
					return java.lang.CharSequenceProxy.Wrap(cursor.getString(mStringConversionColumn)
						);
				}
			}
			return base.convertToString(cursor);
		}
Exemplo n.º 3
0
		public override void bindView(android.view.View view, android.content.Context context
			, android.database.Cursor cursor)
		{
			android.widget.SimpleCursorAdapter.ViewBinder binder = mViewBinder;
			int count = mTo.Length;
			int[] from = mFrom;
			int[] to = mTo;
			{
				for (int i = 0; i < count; i++)
				{
					android.view.View v = view.findViewById(to[i]);
					if (v != null)
					{
						bool bound = false;
						if (binder != null)
						{
							bound = binder.setViewValue(v, cursor, from[i]);
						}
						if (!bound)
						{
							string text = cursor.getString(from[i]);
							if (text == null)
							{
								text = string.Empty;
							}
							if (v is android.widget.TextView)
							{
								setViewText((android.widget.TextView)v, text);
							}
							else
							{
								if (v is android.widget.ImageView)
								{
									setViewImage((android.widget.ImageView)v, text);
								}
								else
								{
									throw new System.InvalidOperationException(v.GetType().FullName + " is not a " + 
										" view that can be bounds by this SimpleCursorAdapter");
								}
							}
						}
					}
				}
			}
		}
Exemplo n.º 4
0
		private void bindView(android.view.View view, android.content.Context context, android.database.Cursor
			 cursor, int[] from, int[] to)
		{
			android.widget.SimpleCursorTreeAdapter.ViewBinder binder = mViewBinder;
			{
				for (int i = 0; i < to.Length; i++)
				{
					android.view.View v = view.findViewById(to[i]);
					if (v != null)
					{
						bool bound = false;
						if (binder != null)
						{
							bound = binder.setViewValue(v, cursor, from[i]);
						}
						if (!bound)
						{
							string text = cursor.getString(from[i]);
							if (text == null)
							{
								text = string.Empty;
							}
							if (v is android.widget.TextView)
							{
								setViewText((android.widget.TextView)v, text);
							}
							else
							{
								if (v is android.widget.ImageView)
								{
									setViewImage((android.widget.ImageView)v, text);
								}
								else
								{
									throw new System.InvalidOperationException("SimpleCursorTreeAdapter can bind values"
										 + " only to TextView and ImageView!");
								}
							}
						}
					}
				}
			}
		}
Exemplo n.º 5
0
		private static string getStringOrNull(android.database.Cursor cursor, int col)
		{
			if (col == INVALID_INDEX)
			{
				return null;
			}
			try
			{
				return cursor.getString(col);
			}
			catch (System.Exception e)
			{
				android.util.Log.e(LOG_TAG, "unexpected error retrieving valid column from cursor, "
					 + "did the remote process die?", e);
				return null;
			}
		}
Exemplo n.º 6
0
		private android.graphics.drawable.Drawable getIcon2(android.database.Cursor cursor
			)
		{
			if (mIconName2Col == INVALID_INDEX)
			{
				return null;
			}
			string value = cursor.getString(mIconName2Col);
			return getDrawableFromResourceValue(value);
		}
Exemplo n.º 7
0
		private android.graphics.drawable.Drawable getIcon1(android.database.Cursor cursor
			)
		{
			if (mIconName1Col == INVALID_INDEX)
			{
				return null;
			}
			string value = cursor.getString(mIconName1Col);
			android.graphics.drawable.Drawable drawable = getDrawableFromResourceValue(value);
			if (drawable != null)
			{
				return drawable;
			}
			return getDefaultIcon1(cursor);
		}