public class SectionedRecyclerViewAdapter
extends androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>
Sections to be added to it.
Sections are displayed in the same order they were added.| Modifier and Type | Field and Description |
|---|---|
static int |
VIEW_TYPE_EMPTY |
static int |
VIEW_TYPE_FAILED |
static int |
VIEW_TYPE_FOOTER |
static int |
VIEW_TYPE_HEADER |
static int |
VIEW_TYPE_ITEM_LOADED |
static int |
VIEW_TYPE_LOADING |
| Constructor and Description |
|---|
SectionedRecyclerViewAdapter() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
addSection(int index,
Section section)
Add a section at the specific position to this adapter with a random tag.
|
void |
addSection(int index,
java.lang.String tag,
Section section)
Add a section to this adapter at the specific index.
|
java.lang.String |
addSection(Section section)
Add a section to this adapter with a random tag.
|
void |
addSection(java.lang.String tag,
Section section)
Add a section to this adapter.
|
SectionAdapter |
getAdapterForSection(Section section) |
SectionAdapter |
getAdapterForSection(java.lang.String tag) |
java.util.Map<java.lang.String,Section> |
getCopyOfSectionsMap()
Return a copy of the map with all sections of this adapter.
|
int |
getItemCount() |
int |
getItemViewType(int position) |
int |
getPositionInSection(int position)
Return the item position relative to the section.
|
Section |
getSection(int index)
Return the Section at the provided index in the adapter.
|
Section |
getSection(java.lang.String tag)
Return the section with the tag provided.
|
int |
getSectionCount()
Return the number of sections of this adapter.
|
Section |
getSectionForPosition(int position)
Returns the Section object for a position in the adapter.
|
int |
getSectionIndex(Section section)
Returns the index of the first occurrence of the specified section in this adapter, or -1 if
this adapter does not contain the section.
|
int |
getSectionItemViewType(int position)
Returns the Section ViewType of an item based on the position in the adapter.
|
static int |
getSectionItemViewTypeForAdapterViewType(int itemViewType)
Calculates the section adapter item view type from a view type from the adapter.
|
android.view.View |
inflate(int layoutResourceId,
android.view.ViewGroup parent) |
void |
onBindViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder holder,
int position) |
void |
onBindViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder holder,
int position,
java.util.List<java.lang.Object> payloads) |
androidx.recyclerview.widget.RecyclerView.ViewHolder |
onCreateViewHolder(android.view.ViewGroup parent,
int viewType) |
void |
removeAllSections()
Remove all sections from this adapter.
|
void |
removeSection(Section section)
Remove section from this adapter.
|
void |
removeSection(java.lang.String tag)
Remove section from this adapter.
|
bindViewHolder, createViewHolder, getItemId, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserverpublic static final int VIEW_TYPE_HEADER
public static final int VIEW_TYPE_FOOTER
public static final int VIEW_TYPE_ITEM_LOADED
public static final int VIEW_TYPE_LOADING
public static final int VIEW_TYPE_FAILED
public static final int VIEW_TYPE_EMPTY
@NonNull
public androidx.recyclerview.widget.RecyclerView.ViewHolder onCreateViewHolder(@NonNull
android.view.ViewGroup parent,
int viewType)
onCreateViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>public java.lang.String addSection(Section section)
section - section to be addedpublic void addSection(java.lang.String tag,
Section section)
tag - unique identifier of the sectionsection - section to be addedpublic void addSection(int index,
java.lang.String tag,
Section section)
index - the index at which the section should be insertedtag - unique identifier of the sectionsection - section should be addedpublic java.lang.String addSection(int index,
Section section)
index - the index at which the section should be insertedsection - section should be addedpublic Section getSection(java.lang.String tag)
tag - unique identifier of the sectionpublic void removeSection(Section section)
section - section to be removedpublic void removeSection(java.lang.String tag)
tag - unique identifier of the sectionpublic void removeAllSections()
public void onBindViewHolder(@NonNull
androidx.recyclerview.widget.RecyclerView.ViewHolder holder,
int position)
onBindViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>public void onBindViewHolder(@NonNull
androidx.recyclerview.widget.RecyclerView.ViewHolder holder,
int position,
@NonNull
java.util.List<java.lang.Object> payloads)
onBindViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>public int getItemCount()
getItemCount in class androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>public int getItemViewType(int position)
getItemViewType in class androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>public static int getSectionItemViewTypeForAdapterViewType(int itemViewType)
itemViewType - adapter view typepublic int getSectionItemViewType(int position)
position - position in the adapterpublic Section getSectionForPosition(int position)
position - position in the adapterpublic int getPositionInSection(int position)
position - position of the item in the adapter@NonNull public java.util.Map<java.lang.String,Section> getCopyOfSectionsMap()
public int getSectionCount()
public Section getSection(int index)
index - index in the adapterpublic int getSectionIndex(Section section)
section - section to search forpublic SectionAdapter getAdapterForSection(java.lang.String tag)
public SectionAdapter getAdapterForSection(Section section)
public android.view.View inflate(@LayoutRes
int layoutResourceId,
android.view.ViewGroup parent)