public class MultiViewAdapter
extends <any>
Section
s and ItemBinder
s. Both are modular and
composable meaning that they can be used in any adapter and you can use as many of them inside a
single adapter.
Apart from this MultiViewAdapter has lot of other features like,
Constructor and Description |
---|
MultiViewAdapter()
No-arg constructor for MultiViewAdapter.
|
Modifier and Type | Method and Description |
---|---|
void |
addSection(Section section)
Add a section to this adapter.
|
void |
clearAllSelections()
Clears all the selected items inside the adapter.
|
void |
collapseAllItems()
Collapses all the items inside the adapter.
|
void |
collapseAllSections()
Collapses all the sections inside the adapter.
|
void |
drawDecoration(android.graphics.Canvas canvas,
RecyclerView parent,
RecyclerView.State state,
android.view.View child,
int adapterPosition) |
void |
getDecorationOffset(android.graphics.Rect outRect,
android.view.View view,
RecyclerView parent,
RecyclerView.State state,
int adapterPosition) |
int |
getItemCount() |
RecyclerView.ItemDecoration |
getItemDecoration()
If you would like to use the decoration feature of the adapter, use this method to get
ItemDecoration and add it to your recyclerview.
|
ItemTouchHelper |
getItemTouchHelper()
Get the
ItemTouchHelper which resolves the swipe and drag gestures for the adapter's
individual ItemBinder. |
int |
getItemViewType(int adapterPosition) |
int |
getPositionType(RecyclerView parent,
int adapterPosition)
Returns the positionType of the item inside the layout manager.
|
SectionPositionType |
getSectionPositionType(int adapterPosition)
Returns the SectionPositionType for the giver adapter position.
|
int |
getSpanSize(int adapterPosition) |
GridLayoutManager.SpanSizeLookup |
getSpanSizeLookup()
Return the span size lookup used by this adapter.
|
void |
onBindViewHolder(ItemViewHolder holder,
int adapterPosition) |
void |
onBindViewHolder(ItemViewHolder holder,
int adapterPosition,
java.util.List<java.lang.Object> payloads) |
ItemViewHolder |
onCreateViewHolder(android.view.ViewGroup parent,
int viewType) |
void |
onItemDismiss(int adapterPosition) |
void |
onMove(int initialPosition,
int targetPosition) |
void |
registerItemBinders(ItemBinder... itemBinders)
Register an ItemBinder to the adapter.
|
void |
removeAllSections()
Remove all the sections added to the adapter
|
void |
setExpansionMode(Mode expansionMode)
Set the expansion mode for this adapter.
|
void |
setInfiniteLoadingHelper(InfiniteLoadingHelper infiniteLoadingHelper)
By setting an infiniteLoadingHelper, you can add infinite scrolling feature to the adapter.
|
void |
setSectionExpansionMode(Mode sectionExpansionMode)
Set the section expansion mode for this adapter.
|
void |
setSelectionMode(Mode selectionMode)
Set the selection mode for this adapter.
|
void |
setSpanCount(int spanCount)
Set the span count for the adapter.
|
void |
startActionMode()
Helper method to set the adapter is in contextual action mode.
|
void |
stopActionMode()
Helper method to set the adapter has exited contextual action mode.
|
void |
unRegisterAllItemBinders()
Removes all the ItemBinders which were registered to this adapter.
|
public MultiViewAdapter()
public void addSection(Section section)
section
- Section to be added to this adapter.java.lang.IllegalStateException
- If the section already has a parent.public void clearAllSelections()
public void collapseAllItems()
public void collapseAllSections()
public RecyclerView.ItemDecoration getItemDecoration()
recyclerView.addItemDecoration(adapter.getItemDecoration());
public ItemTouchHelper getItemTouchHelper()
ItemTouchHelper
which resolves the swipe and drag gestures for the adapter's
individual ItemBinder.public int getPositionType(RecyclerView parent, int adapterPosition)
Decorator.isItemOnLeftEdge(int)
etc.,
By knowing this information you can draw the decorations creatively.parent
- RecyclerView where this adapter is attached.adapterPosition
- Position of the item inside the adapter.public SectionPositionType getSectionPositionType(int adapterPosition)
adapterPosition
- Position of the item inside the adapter.public GridLayoutManager.SpanSizeLookup getSpanSizeLookup()
public void registerItemBinders(ItemBinder... itemBinders)
public void removeAllSections()
public void setExpansionMode(Mode expansionMode)
expansionMode
- Mode to be set as expansion modepublic void setInfiniteLoadingHelper(InfiniteLoadingHelper infiniteLoadingHelper)
InfiniteLoadingHelper helper = new InfiniteLoadingHelper(recyclerView,
R.layout.item_infinite_loader);
adapter.setInfiniteLoadingHelper(helper);
infiniteLoadingHelper
- Helper object to be setInfiniteLoadingHelper
public void setSectionExpansionMode(Mode sectionExpansionMode)
sectionExpansionMode
- Mode to be set as section expansion modepublic void setSelectionMode(Mode selectionMode)
selectionMode
- Mode to be set as selection modepublic void setSpanCount(int spanCount)
spanCount
- Span count to be setpublic void startActionMode()
To get the state of action mode
public void stopActionMode()
To get the state of action mode
public void unRegisterAllItemBinders()
public final int getSpanSize(int adapterPosition)
public final void drawDecoration(android.graphics.Canvas canvas, RecyclerView parent, RecyclerView.State state, android.view.View child, int adapterPosition)
public final void getDecorationOffset(android.graphics.Rect outRect, android.view.View view, RecyclerView parent, RecyclerView.State state, int adapterPosition)
public final void onItemDismiss(int adapterPosition)
public final void onMove(int initialPosition, int targetPosition)
public final ItemViewHolder onCreateViewHolder(android.view.ViewGroup parent, int viewType)
public final void onBindViewHolder(ItemViewHolder holder, int adapterPosition)
public final void onBindViewHolder(ItemViewHolder holder, int adapterPosition, java.util.List<java.lang.Object> payloads)
public final int getItemViewType(int adapterPosition)
public final int getItemCount()