Fields Summary |
---|
protected boolean | mDataValidThis field should be made private, so it is hidden from the SDK.
{@hide} |
protected boolean | mAutoRequeryThis field should be made private, so it is hidden from the SDK.
{@hide} |
protected android.database.Cursor | mCursorThis field should be made private, so it is hidden from the SDK.
{@hide} |
protected android.content.Context | mContextThis field should be made private, so it is hidden from the SDK.
{@hide} |
protected int | mRowIDColumnThis field should be made private, so it is hidden from the SDK.
{@hide} |
protected ChangeObserver | mChangeObserverThis field should be made private, so it is hidden from the SDK.
{@hide} |
protected android.database.DataSetObserver | mDataSetObserverThis field should be made private, so it is hidden from the SDK.
{@hide} |
protected CursorFilter | mCursorFilterThis field should be made private, so it is hidden from the SDK.
{@hide} |
protected FilterQueryProvider | mFilterQueryProviderThis field should be made private, so it is hidden from the SDK.
{@hide} |
Methods Summary |
---|
public abstract void | bindView(android.view.View view, android.content.Context context, android.database.Cursor cursor)Bind an existing view to the data pointed to by cursor
|
public void | changeCursor(android.database.Cursor cursor)Change the underlying cursor to a new cursor. If there is an existing cursor it will be
closed.
if (cursor == mCursor) {
return;
}
if (mCursor != null) {
mCursor.unregisterContentObserver(mChangeObserver);
mCursor.unregisterDataSetObserver(mDataSetObserver);
mCursor.close();
}
mCursor = cursor;
if (cursor != null) {
cursor.registerContentObserver(mChangeObserver);
cursor.registerDataSetObserver(mDataSetObserver);
mRowIDColumn = cursor.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();
}
|
public java.lang.CharSequence | convertToString(android.database.Cursor cursor)Converts the cursor into a CharSequence. Subclasses should override this
method to convert their results. The default implementation returns an
empty String for null values or the default String representation of
the value.
return cursor == null ? "" : cursor.toString();
|
public int | getCount()
if (mDataValid && mCursor != null) {
return mCursor.getCount();
} else {
return 0;
}
|
public android.database.Cursor | getCursor()Returns the cursor.
return mCursor;
|
public android.view.View | getDropDownView(int position, android.view.View convertView, android.view.ViewGroup parent)
if (mDataValid) {
mCursor.moveToPosition(position);
View v;
if (convertView == null) {
v = newDropDownView(mContext, mCursor, parent);
} else {
v = convertView;
}
bindView(v, mContext, mCursor);
return v;
} else {
return null;
}
|
public Filter | getFilter()
if (mCursorFilter == null) {
mCursorFilter = new CursorFilter(this);
}
return mCursorFilter;
|
public FilterQueryProvider | getFilterQueryProvider()Returns the query filter provider used for filtering. When the
provider is null, no filtering occurs.
return mFilterQueryProvider;
|
public java.lang.Object | getItem(int position)
if (mDataValid && mCursor != null) {
mCursor.moveToPosition(position);
return mCursor;
} else {
return null;
}
|
public long | getItemId(int position)
if (mDataValid && mCursor != null) {
if (mCursor.moveToPosition(position)) {
return mCursor.getLong(mRowIDColumn);
} else {
return 0;
}
} else {
return 0;
}
|
public android.view.View | getView(int position, android.view.View convertView, android.view.ViewGroup parent)
if (!mDataValid) {
throw new IllegalStateException("this should only be called when the cursor is valid");
}
if (!mCursor.moveToPosition(position)) {
throw new IllegalStateException("couldn't move cursor to position " + position);
}
View v;
if (convertView == null) {
v = newView(mContext, mCursor, parent);
} else {
v = convertView;
}
bindView(v, mContext, mCursor);
return v;
|
public boolean | hasStableIds()
return true;
|
protected void | init(android.content.Context context, android.database.Cursor c, boolean autoRequery)
boolean cursorPresent = c != null;
mAutoRequery = autoRequery;
mCursor = c;
mDataValid = cursorPresent;
mContext = context;
mRowIDColumn = cursorPresent ? c.getColumnIndexOrThrow("_id") : -1;
mChangeObserver = new ChangeObserver();
if (cursorPresent) {
c.registerContentObserver(mChangeObserver);
c.registerDataSetObserver(mDataSetObserver);
}
|
public android.view.View | newDropDownView(android.content.Context context, android.database.Cursor cursor, android.view.ViewGroup parent)Makes a new drop down view to hold the data pointed to by cursor.
return newView(context, cursor, parent);
|
public abstract android.view.View | newView(android.content.Context context, android.database.Cursor cursor, android.view.ViewGroup parent)Makes a new view to hold the data pointed to by cursor.
|
protected void | onContentChanged()Called when the {@link ContentObserver} on the cursor receives a change notification.
The default implementation provides the auto-requery logic, but may be overridden by
sub classes.
if (mAutoRequery && mCursor != null && !mCursor.isClosed()) {
if (Config.LOGV) Log.v("Cursor", "Auto requerying " + mCursor + " due to update");
mDataValid = mCursor.requery();
}
|
public android.database.Cursor | runQueryOnBackgroundThread(java.lang.CharSequence constraint)Runs a query with the specified constraint. This query is requested
by the filter attached to this adapter.
The query is provided by a
{@link android.widget.FilterQueryProvider}.
If no provider is specified, the current cursor is not filtered and returned.
After this method returns the resulting cursor is passed to {@link #changeCursor(Cursor)}
and the previous cursor is closed.
This method is always executed on a background thread, not on the
application's main thread (or UI thread.)
Contract: when constraint is null or empty, the original results,
prior to any filtering, must be returned.
if (mFilterQueryProvider != null) {
return mFilterQueryProvider.runQuery(constraint);
}
return mCursor;
|
public void | setFilterQueryProvider(FilterQueryProvider filterQueryProvider)Sets the query filter provider used to filter the current Cursor.
The provider's
{@link android.widget.FilterQueryProvider#runQuery(CharSequence)}
method is invoked when filtering is requested by a client of
this adapter.
mFilterQueryProvider = filterQueryProvider;
|