public class ListSection<M> extends Section
DiffUtil
to calculate the diff and calls the correct notify
method.Constructor and Description |
---|
ListSection()
No arg constructor for ListSection.
|
ListSection(PayloadProvider<M> payloadProvider)
Constructor which initializes the ListSection with give PayloadProvider.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
M item)
Inserts the specified element at the specified position in this data manger
(optional operation).
|
void |
add(M item)
Appends the specified element to the end of
ListSection . |
boolean |
addAll(java.util.Collection<? extends M> items)
Appends all of the elements in the specified collection to the end of this
ListSection ,
in the order that they are returned by the specified collection's iterator (optional
operation). |
boolean |
addAll(int index,
java.util.Collection<? extends M> items)
Inserts all of the elements in the specified collection into this
data manager at the specified position (optional operation).
|
void |
clear()
Removes all of the elements from this data manager (optional operation).
|
void |
clearSelections()
This method is used to clear the selected items in a
ListSection |
M |
get(int index)
Returns the element at the specified position in this list section.
|
java.util.List<M> |
getData()
Returns the data added to this section
|
java.util.List<M> |
getSelectedItems()
Returns the list of selected items
|
void |
remove(int index)
Removes the element at the specified position in this list (optional operation).
|
void |
set(int index,
M item)
Replaces the element at the specified position in this data manager with the
specified element (optional operation).
|
void |
set(java.util.List<M> items)
Replaces the data list in this data manager with the new list.
|
void |
setDiffUtil(MvaDiffUtil<M> diffUtil)
Sets the diffutil for this section.
|
void |
setOnItemClickListener(OnItemClickListener<M> itemClickListener)
Set the listener to get callback when an item is clicked inside the section.
|
void |
setOnSelectionChangedListener(OnSelectionChangedListener<M> selectionChangedListener)
Set listener to get callback when an item is selected or unselected
|
void |
setPayloadProvider(PayloadProvider<M> payloadProvider)
Set your own payload provider.
|
void |
setSwipeToDismissListener(SwipeToDismissListener<M> swipeToDismissListener)
Sets the SwipeToDismissListener
|
int |
size()
Removes all of the elements from this data manager (optional operation).
|
addDecorator, addDecorator, hideSection, isSectionHidden, onChanged, onInserted, onMoved, onRemoved, removeAllDecorators, removeDecorator, removeDecorator, setExpansionMode, setSectionExpansionMode, setSelectionMode, setSpanCount, showSection
public ListSection()
PayloadProvider
which checks the equality using Object.equals(object)
public ListSection(PayloadProvider<M> payloadProvider)
payloadProvider
- PayloadProvider to be used by the list section.public void add(M item)
ListSection
. Also calls RecyclerView.ItemAnimator
's add animation.item
- element to be appended to this listjava.lang.UnsupportedOperationException
- if the add operation is not supported by this
ListSection
public void add(int index, M item)
RecyclerView.ItemAnimator
's add animation.index
- index at which the specified element is to be inserteditem
- element to be insertedjava.lang.UnsupportedOperationException
- if the add operation
is not supported by this data mangerjava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size())public boolean addAll(java.util.Collection<? extends M> items)
ListSection
,
in the order that they are returned by the specified collection's iterator (optional
operation). The behavior of this operation is undefined if the specified collection is
modified while the operation is in progress. (Note that this will occur if the specified
collection is this list, and it's nonempty) Also calls RecyclerView.ItemAnimator
's add
animation.items
- collection containing elements to be added to this listjava.lang.UnsupportedOperationException
- if the addAll operation
is not supported by this ListSection
add(Object)
public boolean addAll(int index, java.util.Collection<? extends M> items)
RecyclerView.ItemAnimator
's add animation.index
- index at which to insert the first element from the
specified collectionitems
- collection containing elements to be added to this listjava.lang.UnsupportedOperationException
- if the addAll operation
is not supported by this data managerpublic void clear()
RecyclerView.ItemAnimator
's remove animation will be called.public void clearSelections()
ListSection
public M get(int index)
index
- index of the element to returnjava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())public java.util.List<M> getData()
public java.util.List<M> getSelectedItems()
public void remove(int index)
RecyclerView.ItemAnimator
's remove animation will be called.index
- the index of the element to be removedjava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())public void set(java.util.List<M> items)
RecyclerView.ItemAnimator
's animation with payload.items
- list to be stored in the data managerpublic void set(int index, M item)
RecyclerView.ItemAnimator
's animation with payload.index
- index of the element to replaceitem
- element to be stored at the specified positionjava.lang.UnsupportedOperationException
- if the set operation
is not supported by this data managerjava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())public void setDiffUtil(MvaDiffUtil<M> diffUtil)
MvaDiffUtil
and set it herediffUtil
- DiffUtil to be used by the sectionpublic void setOnItemClickListener(OnItemClickListener<M> itemClickListener)
ItemViewHolder.onClick()
itemClickListener
- Listener to be setpublic void setOnSelectionChangedListener(OnSelectionChangedListener<M> selectionChangedListener)
selectionChangedListener
- Listener to be setpublic void setPayloadProvider(PayloadProvider<M> payloadProvider)
PayloadProvider
and set it here.payloadProvider
- PayloadProvider to be setpublic void setSwipeToDismissListener(SwipeToDismissListener<M> swipeToDismissListener)
swipeToDismissListener
- Listener to be setSwipeToDismissListener
public int size()
RecyclerView.ItemAnimator
's remove animation will be called.