コード例 #1
0
ファイル: CursorAdapter.cs プロジェクト: hakeemsm/XobotOS
		/// <summary>Swap in a new Cursor, returning the old Cursor.</summary>
		/// <remarks>
		/// Swap in a new Cursor, returning the old Cursor.  Unlike
		/// <see cref="changeCursor(android.database.Cursor)">changeCursor(android.database.Cursor)
		/// 	</see>
		/// , the returned old Cursor is <em>not</em>
		/// closed.
		/// </remarks>
		/// <param name="newCursor">The new cursor to be used.</param>
		/// <returns>
		/// Returns the previously set Cursor, or null if there wasa not one.
		/// If the given new Cursor is the same instance is the previously set
		/// Cursor, null is also returned.
		/// </returns>
		public virtual android.database.Cursor swapCursor(android.database.Cursor newCursor
			)
		{
			if (newCursor == mCursor)
			{
				return null;
			}
			android.database.Cursor oldCursor = mCursor;
			if (oldCursor != null)
			{
				if (mChangeObserver != null)
				{
					oldCursor.unregisterContentObserver(mChangeObserver);
				}
				if (mDataSetObserver != null)
				{
					oldCursor.unregisterDataSetObserver(mDataSetObserver);
				}
			}
			mCursor = newCursor;
			if (newCursor != null)
			{
				if (mChangeObserver != null)
				{
					newCursor.registerContentObserver(mChangeObserver);
				}
				if (mDataSetObserver != null)
				{
					newCursor.registerDataSetObserver(mDataSetObserver);
				}
				mRowIDColumn = newCursor.getColumnIndexOrThrow("_id");
				mDataValid = true;
				// notify the observers about the new cursor
				notifyDataSetChanged();
			}
			else
			{
				mRowIDColumn = -1;
				mDataValid = false;
				// notify the observers about the lack of a data set
				notifyDataSetInvalidated();
			}
			return oldCursor;
		}
コード例 #2
0
ファイル: CursorAdapter.cs プロジェクト: hakeemsm/XobotOS
		internal virtual void init(android.content.Context context, android.database.Cursor
			 c, int flags)
		{
			if ((flags & FLAG_AUTO_REQUERY) == FLAG_AUTO_REQUERY)
			{
				flags |= FLAG_REGISTER_CONTENT_OBSERVER;
				mAutoRequery = true;
			}
			else
			{
				mAutoRequery = false;
			}
			bool cursorPresent = c != null;
			mCursor = c;
			mDataValid = cursorPresent;
			mContext = context;
			mRowIDColumn = cursorPresent ? c.getColumnIndexOrThrow("_id") : -1;
			if ((flags & FLAG_REGISTER_CONTENT_OBSERVER) == FLAG_REGISTER_CONTENT_OBSERVER)
			{
				mChangeObserver = new android.widget.CursorAdapter.ChangeObserver(this);
				mDataSetObserver = new android.widget.CursorAdapter.MyDataSetObserver(this);
			}
			else
			{
				mChangeObserver = null;
				mDataSetObserver = null;
			}
			if (cursorPresent)
			{
				if (mChangeObserver != null)
				{
					c.registerContentObserver(mChangeObserver);
				}
				if (mDataSetObserver != null)
				{
					c.registerDataSetObserver(mDataSetObserver);
				}
			}
		}
コード例 #3
0
ファイル: ListPopupWindow.cs プロジェクト: hakeemsm/XobotOS
		/// <summary>
		/// Sets the adapter that provides the data and the views to represent the data
		/// in this popup window.
		/// </summary>
		/// <remarks>
		/// Sets the adapter that provides the data and the views to represent the data
		/// in this popup window.
		/// </remarks>
		/// <param name="adapter">The adapter to use to create this window's content.</param>
		public virtual void setAdapter(android.widget.ListAdapter adapter)
		{
			if (mObserver == null)
			{
				mObserver = new android.widget.ListPopupWindow.PopupDataSetObserver(this);
			}
			else
			{
				if (mAdapter != null)
				{
					mAdapter.unregisterDataSetObserver(mObserver);
				}
			}
			mAdapter = adapter;
			if (mAdapter != null)
			{
				adapter.registerDataSetObserver(mObserver);
			}
			if (mDropDownList != null)
			{
				mDropDownList.setAdapter(mAdapter);
			}
		}
コード例 #4
0
ファイル: CursorTreeAdapter.cs プロジェクト: hakeemsm/XobotOS
			internal virtual void changeCursor(android.database.Cursor cursor, bool releaseCursors
				)
			{
				if (cursor == this.mCursor)
				{
					return;
				}
				this.deactivate();
				this.mCursor = cursor;
				if (cursor != null)
				{
					cursor.registerContentObserver(this.mContentObserver);
					cursor.registerDataSetObserver(this.mDataSetObserver);
					this.mRowIDColumn = cursor.getColumnIndex("_id");
					this.mDataValid = true;
					// notify the observers about the new cursor
					this._enclosing.notifyDataSetChanged(releaseCursors);
				}
				else
				{
					this.mRowIDColumn = -1;
					this.mDataValid = false;
					// notify the observers about the lack of a data set
					this._enclosing.notifyDataSetInvalidated();
				}
			}
コード例 #5
0
ファイル: CursorTreeAdapter.cs プロジェクト: hakeemsm/XobotOS
			internal MyCursorHelper(CursorTreeAdapter _enclosing, android.database.Cursor cursor
				)
			{
				this._enclosing = _enclosing;
				bool cursorPresent = cursor != null;
				this.mCursor = cursor;
				this.mDataValid = cursorPresent;
				this.mRowIDColumn = cursorPresent ? cursor.getColumnIndex("_id") : -1;
				this.mContentObserver = new android.widget.CursorTreeAdapter.MyCursorHelper.MyContentObserver
					(this);
				this.mDataSetObserver = new android.widget.CursorTreeAdapter.MyCursorHelper.MyDataSetObserver
					(this);
				if (cursorPresent)
				{
					cursor.registerContentObserver(this.mContentObserver);
					cursor.registerDataSetObserver(this.mDataSetObserver);
				}
			}
コード例 #6
0
ファイル: GridView.cs プロジェクト: hakeemsm/XobotOS
		public override void setAdapter(android.widget.ListAdapter adapter)
		{
			if (mAdapter != null && mDataSetObserver != null)
			{
				mAdapter.unregisterDataSetObserver(mDataSetObserver);
			}
			resetList();
			mRecycler.clear();
			mAdapter = adapter;
			mOldSelectedPosition = android.widget.AdapterView.INVALID_POSITION;
			mOldSelectedRowId = android.widget.AdapterView.INVALID_ROW_ID;
			// AbsListView#setAdapter will update choice mode states.
			base.setAdapter(adapter);
			if (mAdapter != null)
			{
				mOldItemCount = mItemCount;
				mItemCount = mAdapter.getCount();
				mDataChanged = true;
				checkFocus();
				mDataSetObserver = new android.widget.AbsListView.AdapterDataSetObserver(this);
				mAdapter.registerDataSetObserver(mDataSetObserver);
				mRecycler.setViewTypeCount(mAdapter.getViewTypeCount());
				int position;
				if (mStackFromBottom)
				{
					position = lookForSelectablePosition(mItemCount - 1, false);
				}
				else
				{
					position = lookForSelectablePosition(0, true);
				}
				setSelectedPositionInt(position);
				setNextSelectedPositionInt(position);
				checkSelectionChanged();
			}
			else
			{
				checkFocus();
				// Nothing selected
				checkSelectionChanged();
			}
			requestLayout();
		}