public abstract class SectionedRecyclerViewAdapter<T extends Sectioned>
extends java.lang.Object
setAdapterToRecyclerView(RecyclerView)
The wrapper is interfaced using the positions of the items list passed as parameter but
internally it uses a list that contains both items and sectionsModifier and Type | Class and Description |
---|---|
class |
SectionedRecyclerViewAdapter.SectionedAdapterTouchHelperCallback
TouchHelper Callback for the adapter that allows to manage swiping and drag&drop on the list
|
static class |
SectionedRecyclerViewAdapter.SectionViewHolder
ViewHolder for the private adapter that describes a section
|
Modifier and Type | Field and Description |
---|---|
static int |
VIEW_TYPE_ITEM |
static int |
VIEW_TYPE_SECTION |
Constructor and Description |
---|
SectionedRecyclerViewAdapter() |
Modifier and Type | Method and Description |
---|---|
void |
addItemsAtTheEndAndNotify(java.util.List<T> newItems)
Adds the given items at the end of the current list and notifies the underlying adapter of the data set change
|
void |
enableMovement(boolean enable)
Allows to enable/disable movement
|
void |
enableSectioning(boolean enable)
Allows to enable/disable the sections
|
T |
get(int position)
Getter
|
int |
getItemCount() |
void |
moveItemAndNotify(int fromPosition,
int toPosition,
Section fromSection,
Section toSection)
Allows to move the item at the given "from position" (section "from section") to the "to position" (section "to section")
NOTE: if fromPosition=toPosition but fromSection!=toSection the item is not moved in the array but its section changes (happens when the
item is the last before a section and it gets moved to the first position of the next section)
|
void |
notifyItemChanged(int position)
Informs the underlying adapter that the item at the given position has changed
|
void |
notifyItemRangeChanged(int positionStart,
int itemCount)
Informs the underlying adapter that "itemCount" items have changed starting from "positionStart"
|
void |
notifyItemRangeInserted(int positionStart,
int itemCount)
Informs the underlying adapter that "itemCount" items have been added starting from "positionStart"
|
void |
removeItemAndNotify(int position)
Allows to remove the item at the given position and notify the underlying adapter of the removal
|
void |
setAdapterToRecyclerView(android.support.v7.widget.RecyclerView recyclerView)
Allows to set the underlying adapter to the RecyclerView
|
void |
setEmptyView(View emptyView)
Setter
|
void |
setItemsAndNotifyDataSetChanged(java.util.List<T> items)
Reloads the whole list of items and notifies the underlying adapter of the data set change
|
public static final int VIEW_TYPE_SECTION
public static final int VIEW_TYPE_ITEM
public void enableSectioning(boolean enable)
enable
- true if sections are to be displayedpublic void enableMovement(boolean enable)
enable
- true if movement is allowedpublic void removeItemAndNotify(int position)
position
- the item position to removepublic void moveItemAndNotify(int fromPosition, int toPosition, Section fromSection, Section toSection)
fromPosition
- the starting positiontoPosition
- the final positionfromSection
- the starting sectiontoSection
- the final sectionpublic void setItemsAndNotifyDataSetChanged(java.util.List<T> items)
items
- the new itemspublic void addItemsAtTheEndAndNotify(java.util.List<T> newItems)
newItems
- the items to be addedpublic void notifyItemChanged(int position)
position
- the changed item positionpublic void notifyItemRangeChanged(int positionStart, int itemCount)
positionStart
- starting positionitemCount
- number of items that have changedpublic void notifyItemRangeInserted(int positionStart, int itemCount)
positionStart
- starting positionitemCount
- number of items that have been insertedpublic T get(int position)
position
- the item positionpublic int getItemCount()
RecyclerView.Adapter#getItemCount()
public void setAdapterToRecyclerView(android.support.v7.widget.RecyclerView recyclerView)
recyclerView
- the RecyclerView that needs the adapterpublic void setEmptyView(View emptyView)
emptyView
- the view to be displayed if the adapter is empty