public abstract class CheckableChildRecyclerViewAdapter<GVH extends GroupViewHolder,CCVH extends CheckableChildViewHolder> extends <any> implements OnChildCheckChangedListener, OnChildrenCheckStateChangedListener
| Constructor and Description |
|---|
CheckableChildRecyclerViewAdapter(java.util.List<? extends CheckedExpandableGroup> groups) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkChild(boolean checked,
int groupIndex,
int childIndex)
Manually (programmatically) update the check state of a child
|
void |
clearChoices()
Clear any choices previously checked
|
abstract void |
onBindCheckChildViewHolder(CCVH holder,
int flatPosition,
CheckedExpandableGroup group,
int childIndex)
Called from onBindViewHolder(RecyclerView.ViewHolder, int) when the list item
bound to is a child.
|
void |
onBindChildViewHolder(CCVH holder,
int flatPosition,
ExpandableGroup group,
int childIndex) |
void |
onChildCheckChanged(android.view.View view,
boolean checked,
int flatPos) |
abstract CCVH |
onCreateCheckChildViewHolder(android.view.ViewGroup parent,
int viewType)
Called from #onCreateViewHolder(ViewGroup, int) when the list item created is a child
|
CCVH |
onCreateChildViewHolder(android.view.ViewGroup parent,
int viewType) |
void |
onRestoreInstanceState(android.os.Bundle savedInstanceState)
Fetches the checked state map from the saved instance state
Bundle
and restores the checked states of all of the child list items. |
void |
onSaveInstanceState(android.os.Bundle outState)
Stores the checked state map across state loss.
|
void |
setChildClickListener(OnCheckChildClickListener listener) |
void |
updateChildrenCheckState(int firstChildFlattenedIndex,
int numChildren) |
public CheckableChildRecyclerViewAdapter(java.util.List<? extends CheckedExpandableGroup> groups)
public CCVH onCreateChildViewHolder(android.view.ViewGroup parent, int viewType)
public void onBindChildViewHolder(CCVH holder, int flatPosition, ExpandableGroup group, int childIndex)
public void onChildCheckChanged(android.view.View view,
boolean checked,
int flatPos)
onChildCheckChanged in interface OnChildCheckChangedListenerchecked - The current checked state of the viewflatPos - The flat position (raw index) of the the child within the RecyclerViewpublic void updateChildrenCheckState(int firstChildFlattenedIndex,
int numChildren)
updateChildrenCheckState in interface OnChildrenCheckStateChangedListenerfirstChildFlattenedIndex - the flat position of the first child in the CheckedExpandableGroupnumChildren - the total number of children in the CheckedExpandableGrouppublic void setChildClickListener(OnCheckChildClickListener listener)
public void onSaveInstanceState(android.os.Bundle outState)
Should be called from whatever Activity that hosts the RecyclerView that CheckableChildRecyclerViewAdapter is attached to.
This will make sure to add the checked state map as an extra to the
instance state bundle to be used in onRestoreInstanceState(Bundle).
outState - The Bundle into which to store the
chekced state mappublic void onRestoreInstanceState(android.os.Bundle savedInstanceState)
Bundle
and restores the checked states of all of the child list items.
Should be called from Activity.onRestoreInstanceState(Bundle) in
the Activity that hosts the RecyclerView that this
CheckableChildRecyclerViewAdapter is attached to.
savedInstanceState - The Bundle from which the expanded
state map is loadedpublic void checkChild(boolean checked,
int groupIndex,
int childIndex)
checked - the desired check state, true will check the item, false will uncheck it if
possiblegroupIndex - the index of the ExpandableGroup within getGroups()childIndex - the index of the child within it's grouppublic void clearChoices()
public abstract CCVH onCreateCheckChildViewHolder(android.view.ViewGroup parent, int viewType)
parent - the ViewGroup in the list for which a CCVH is being createdCCVH corresponding to child list item with the ViewGroup parentpublic abstract void onBindCheckChildViewHolder(CCVH holder, int flatPosition, CheckedExpandableGroup group, int childIndex)
Bind data to the CCVH here.
holder - The CCVH to bind data toflatPosition - the flat position (raw index) in the list at which to bind the childgroup - The CheckedExpandableGroup that the the child list item belongs tochildIndex - the index of this child within it's CheckedExpandableGroup