public abstract class CursorAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> implements Filterable
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
FLAG_REGISTER_CONTENT_OBSERVER
If set the adapter will register a content observer on the cursor and will call
onContentChanged() when a notification comes in. |
protected com.cocosw.adapter.recyclerview.CursorAdapter.ChangeObserver |
mChangeObserver
This field should be made private, so it is hidden from the SDK.
|
protected Context |
mContext
This field should be made private, so it is hidden from the SDK.
|
protected Cursor |
mCursor
The current cursor
|
protected com.cocosw.adapter.recyclerview.CursorFilter |
mCursorFilter
This field should be made private, so it is hidden from the SDK.
|
protected DataSetObserver |
mDataSetObserver
This field should be made private, so it is hidden from the SDK.
|
protected boolean |
mDataValid
This field should be made private, so it is hidden from the SDK.
|
protected FilterQueryProvider |
mFilterQueryProvider
This field should be made private, so it is hidden from the SDK.
|
protected int |
mRowIDColumn
The row id column
|
protected ViewUpdater |
updater
Updater for current view
|
| 构造器和说明 |
|---|
CursorAdapter(Context context,
Cursor c,
int flags)
Recommended constructor.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
changeCursor(Cursor cursor)
Change the underlying cursor to a new cursor.
|
CharSequence |
convertToString(Cursor cursor)
Converts the cursor into a CharSequence.
|
Cursor |
getCursor()
Returns the cursor.
|
Filter |
getFilter() |
FilterQueryProvider |
getFilterQueryProvider()
Returns the query filter provider used for filtering.
|
int |
getItemCount() |
long |
getItemId(int position) |
abstract void |
onBindViewHolder(VH holder,
Cursor cursor)
Call when bind view with the cursor
|
void |
onBindViewHolder(VH holder,
int position) |
protected abstract void |
onContentChanged()
Called when the
ContentObserver on the cursor receives a change notification. |
Cursor |
runQueryOnBackgroundThread(CharSequence constraint)
Runs a query with the specified constraint.
|
void |
setFilterQueryProvider(FilterQueryProvider filterQueryProvider)
Sets the query filter provider used to filter the current Cursor.
|
Cursor |
swapCursor(Cursor newCursor)
Swap in a new Cursor, returning the old Cursor.
|
bindViewHolder, createViewHolder, getItemViewType, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onCreateViewHolder, onDetachedFromRecyclerView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserverprotected boolean mDataValid
protected Cursor mCursor
protected Context mContext
protected int mRowIDColumn
protected com.cocosw.adapter.recyclerview.CursorAdapter.ChangeObserver mChangeObserver
protected DataSetObserver mDataSetObserver
protected com.cocosw.adapter.recyclerview.CursorFilter mCursorFilter
protected FilterQueryProvider mFilterQueryProvider
protected final ViewUpdater updater
public static final int FLAG_REGISTER_CONTENT_OBSERVER
onContentChanged() when a notification comes in. Be careful when
using this flag: you will need to unset the current Cursor from the adapter
to avoid leaks due to its registered observers. This flag is not needed
when using a CursorAdapter with a
CursorLoader.public CursorAdapter(Context context, Cursor c, int flags)
c - The cursor from which to get the data.context - The contextflags - Flags used to determine the behavior of the adapter;
Currently it accept FLAG_REGISTER_CONTENT_OBSERVER.public abstract void onBindViewHolder(VH holder, Cursor cursor)
holder - cursor - public Cursor getCursor()
public int getItemCount()
getItemCount 在类中 RecyclerView.Adapter<VH extends RecyclerView.ViewHolder>RecyclerView.Adapter.getItemCount()public long getItemId(int position)
getItemId 在类中 RecyclerView.Adapter<VH extends RecyclerView.ViewHolder>position - Adapter position to queryRecyclerView.Adapter.getItemId(int)public void onBindViewHolder(VH holder, int position)
onBindViewHolder 在类中 RecyclerView.Adapter<VH extends RecyclerView.ViewHolder>public void changeCursor(Cursor cursor)
cursor - The new cursor to be usedpublic Cursor swapCursor(Cursor newCursor)
changeCursor(Cursor), the returned old Cursor is not
closed.newCursor - The new cursor to be used.public CharSequence convertToString(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.
cursor - the cursor to convert to a CharSequencepublic Cursor runQueryOnBackgroundThread(CharSequence constraint)
FilterQueryProvider.
If no provider is specified, the current cursor is not filtered and returned.
After this method returns the resulting cursor is passed to 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.constraint - the constraint with which the query must be filteredgetFilter(),
getFilterQueryProvider(),
setFilterQueryProvider(android.widget.FilterQueryProvider)public Filter getFilter()
getFilter 在接口中 Filterablepublic FilterQueryProvider getFilterQueryProvider()
setFilterQueryProvider(android.widget.FilterQueryProvider),
runQueryOnBackgroundThread(CharSequence)public void setFilterQueryProvider(FilterQueryProvider filterQueryProvider)
FilterQueryProvider.runQuery(CharSequence)
method is invoked when filtering is requested by a client of
this adapter.filterQueryProvider - the filter query provider or null to remove itgetFilterQueryProvider(),
runQueryOnBackgroundThread(CharSequence)protected abstract void onContentChanged()
ContentObserver on the cursor receives a change notification.
The default implementation provides the auto-requery logic, but may be overridden by
sub classes.