H
- The Header RecyclerView.ViewHolder
C
- The Child or content RecyclerView.ViewHolder
public abstract class RecyclerHeaderCursorAdapter<H extends android.support.v7.widget.RecyclerView.ViewHolder,C extends android.support.v7.widget.RecyclerView.ViewHolder> extends RecyclerCursorAdapter<android.support.v7.widget.RecyclerView.ViewHolder> implements HeaderApi<H,C>
Modifier and Type | Field and Description |
---|---|
protected HeaderCore |
core
Contains the base processing for the header adapters
|
cursor, cursorFilter, DEFAULT_ID_COLUMN_NAME, filterQueryProvider, idColumn, internalChangeObserver, internalDataSetObserver, isValidData
HEADER_VIEW_TYPE_MASK
Constructor and Description |
---|
RecyclerHeaderCursorAdapter(Cursor cursor) |
RecyclerHeaderCursorAdapter(Cursor cursor,
java.lang.String idColumnName) |
Modifier and Type | Method and Description |
---|---|
int |
determineChildPosition(int viewPosition)
Determines the child position given the position in the RecyclerView
|
int |
getChildCount()
Returns the total number of children in the data set held by the adapter.
|
int |
getChildCount(long headerId)
Returns the total number of views that are associated with the specified
header id.
|
int |
getChildViewType(int childPosition)
Retrieves the view type for the child view at the specified
childPosition . |
int |
getCustomStickyHeaderViewId()
Retrieves the resource id for the view in the header
view holder to make sticky.
|
long |
getHeaderId(int childPosition)
Return the stable ID for the header at
childPosition . |
int |
getHeaderPosition(long headerId)
Determines the position for the header associated with
the
headerId |
int |
getHeaderViewType(int childPosition)
Retrieves the view type for the header whos first child view
has the
childPosition . |
int |
getItemCount()
Returns the total number of items in the data set hold by the adapter, this includes
both the Headers and the Children views
|
int |
getItemViewType(int position)
Retrieves the view type for the specified position.
|
protected void |
init()
Initializes the non-super components for the Adapter
|
void |
onAttachedToRecyclerView(android.support.v7.widget.RecyclerView recyclerView)
When the RecyclerView is attached a data observer is registered
in order to determine when to re-calculate the headers
|
abstract void |
onBindChildViewHolder(C holder,
Cursor cursor,
int childPosition)
Called to display the child information with the
childPosition being the
position of the child, excluding headers. |
abstract void |
onBindHeaderViewHolder(H holder,
Cursor cursor,
int firstChildPosition)
Called to display the header information with the
firstChildPosition being the
position of the first child after this header. |
void |
onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder holder,
Cursor cursor,
int position)
This method shouldn't be used directly, instead use
#onBindHeaderViewHolder(ViewHolder, Cursor, int) and
#onBindChildViewHolder(ViewHolder, Cursor, int) |
android.support.v7.widget.RecyclerView.ViewHolder |
onCreateViewHolder(ViewGroup parent,
int viewType)
This method shouldn't be used directly, instead use
HeaderApi.onCreateHeaderViewHolder(ViewGroup, int) and
HeaderApi.onCreateChildViewHolder(ViewGroup, int) |
void |
onDetachedFromRecyclerView(android.support.v7.widget.RecyclerView recyclerView)
When the RecyclerView is detached the registered data observer
will be unregistered.
|
void |
showHeaderAsChild(boolean enabled)
When enabled the headers will not be counted separately
from the children.
|
changeCursor, convertToString, getCursor, getCursor, getFilter, getFilterQueryProvider, getItemId, onBindViewHolder, onContentChanged, runQueryOnBackgroundThread, setFilterQueryProvider, swapCursor
bindViewHolder, createViewHolder, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onBindViewHolder, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onCreateChildViewHolder, onCreateHeaderViewHolder
protected HeaderCore core
public RecyclerHeaderCursorAdapter(Cursor cursor)
cursor
- The cursor from which to get the data.public RecyclerHeaderCursorAdapter(Cursor cursor, java.lang.String idColumnName)
cursor
- The cursor from which to get the data.idColumnName
- The name for the id column to use when calling RecyclerCursorAdapter.getItemId(int)
[default: ]public abstract void onBindHeaderViewHolder(H holder, Cursor cursor, int firstChildPosition)
firstChildPosition
being the
position of the first child after this header.holder
- The ViewHolder which should be updatedcursor
- The cursor representing the first child for the headerfirstChildPosition
- The position of the child immediately after this headerpublic abstract void onBindChildViewHolder(C holder, Cursor cursor, int childPosition)
childPosition
being the
position of the child, excluding headers.holder
- The ViewHolder which should be updatedcursor
- The cursor representing child to bindchildPosition
- The position of the childpublic android.support.v7.widget.RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
HeaderApi.onCreateHeaderViewHolder(ViewGroup, int)
and
HeaderApi.onCreateChildViewHolder(ViewGroup, int)
onCreateViewHolder
in class android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder>
parent
- The parent ViewGroup for the ViewHolderviewType
- The type for the ViewHolderpublic void onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder holder, Cursor cursor, int position)
#onBindHeaderViewHolder(ViewHolder, Cursor, int)
and
#onBindChildViewHolder(ViewHolder, Cursor, int)
onBindViewHolder
in class RecyclerCursorAdapter<android.support.v7.widget.RecyclerView.ViewHolder>
holder
- The ViewHolder to updatecursor
- The cursor representing the item at position
position
- The position of the item to bind the holder
forpublic int getItemViewType(int position)
getItemViewType
in class android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder>
position
- The position to determine the view type forposition
public void onAttachedToRecyclerView(android.support.v7.widget.RecyclerView recyclerView)
onAttachedToRecyclerView
in class android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder>
recyclerView
- The RecyclerView that was attachedpublic void onDetachedFromRecyclerView(android.support.v7.widget.RecyclerView recyclerView)
onAttachedToRecyclerView(RecyclerView)
for more informationonDetachedFromRecyclerView
in class android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder>
recyclerView
- The RecyclerView that has been detachedpublic int getItemCount()
NOTE: getChildCount()
should be overridden instead of this method
getItemCount
in class RecyclerCursorAdapter<android.support.v7.widget.RecyclerView.ViewHolder>
public int getHeaderViewType(int childPosition)
HeaderApi
childPosition
. This value will be |'d with
the HeaderApi.HEADER_VIEW_TYPE_MASK
to make sure the header and child
view types don't overlapgetHeaderViewType
in interface HeaderApi<H extends android.support.v7.widget.RecyclerView.ViewHolder,C extends android.support.v7.widget.RecyclerView.ViewHolder>
childPosition
- The position for the fist child underneath the headerpublic int getChildViewType(int childPosition)
HeaderApi
childPosition
. This value will be &'ed with the
inverse of HeaderApi.HEADER_VIEW_TYPE_MASK
to make sure the header
and child view types don't overlap.getChildViewType
in interface HeaderApi<H extends android.support.v7.widget.RecyclerView.ViewHolder,C extends android.support.v7.widget.RecyclerView.ViewHolder>
childPosition
- The position of the child to get the type forpublic int getChildCount(long headerId)
HeaderApi
getChildCount
in interface HeaderApi<H extends android.support.v7.widget.RecyclerView.ViewHolder,C extends android.support.v7.widget.RecyclerView.ViewHolder>
headerId
- The headerId to find the number of children forheaderId
public long getHeaderId(int childPosition)
HeaderApi
childPosition
. The default implementation
of this method returns RecyclerView.NO_ID
getHeaderId
in interface HeaderApi<H extends android.support.v7.widget.RecyclerView.ViewHolder,C extends android.support.v7.widget.RecyclerView.ViewHolder>
childPosition
- The Adapters child positionpublic int getChildCount()
HeaderApi
getChildCount
in interface HeaderApi<H extends android.support.v7.widget.RecyclerView.ViewHolder,C extends android.support.v7.widget.RecyclerView.ViewHolder>
public int determineChildPosition(int viewPosition)
HeaderApi
determineChildPosition
in interface HeaderApi<H extends android.support.v7.widget.RecyclerView.ViewHolder,C extends android.support.v7.widget.RecyclerView.ViewHolder>
viewPosition
- The position in the RecyclerView (includes Headers and Children)public int getHeaderPosition(long headerId)
HeaderApi
headerId
getHeaderPosition
in interface HeaderApi<H extends android.support.v7.widget.RecyclerView.ViewHolder,C extends android.support.v7.widget.RecyclerView.ViewHolder>
headerId
- The id to find the header forRecyclerView.NO_POSITION
public void showHeaderAsChild(boolean enabled)
HeaderApi
showHeaderAsChild
in interface HeaderApi<H extends android.support.v7.widget.RecyclerView.ViewHolder,C extends android.support.v7.widget.RecyclerView.ViewHolder>
enabled
- True if the header should be treated as a childpublic int getCustomStickyHeaderViewId()
HeaderApi
NOTE: This will only be used when a
StickyHeaderDecoration
has been specified
getCustomStickyHeaderViewId
in interface HeaderApi<H extends android.support.v7.widget.RecyclerView.ViewHolder,C extends android.support.v7.widget.RecyclerView.ViewHolder>
protected void init()