Class DynamicBinderAdapter<VB extends DynamicRecyclerViewBinder>
java.lang.Object
androidx.recyclerview.widget.RecyclerView.Adapter<VH>
com.pranavpandey.android.dynamic.support.recyclerview.adapter.DynamicRecyclerViewAdapter<RecyclerView.ViewHolder>
com.pranavpandey.android.dynamic.support.recyclerview.adapter.DynamicBinderAdapter<VB>
- Type Parameters:
VB
- The type of the dynamic recycler view binder.
- Direct Known Subclasses:
DynamicSimpleBinderAdapter
,DynamicTypeBinderAdapter
public abstract class DynamicBinderAdapter<VB extends DynamicRecyclerViewBinder>
extends DynamicRecyclerViewAdapter<RecyclerView.ViewHolder>
A
RecyclerView.Adapter
to display different types of items or views in a recycler view.
Each section can have a header or a completely different item.
Extend this adapter and use DynamicRecyclerViewBinder
to create binding logic
for the each type of views.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.pranavpandey.android.dynamic.support.recyclerview.adapter.DynamicRecyclerViewAdapter
DynamicRecyclerViewAdapter.DynamicRecyclerViewItem, DynamicRecyclerViewAdapter.ItemType
-
Field Summary
Fields inherited from class com.pranavpandey.android.dynamic.support.recyclerview.adapter.DynamicRecyclerViewAdapter
TYPE_EMPTY_VIEW, TYPE_ITEM, TYPE_SECTION_DIVIDER, TYPE_SECTION_HEADER, TYPE_SETTING, TYPE_UNKNOWN
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract int
getBinderPosition
(int position) Get the position of a data binder inside the recycler view.abstract VB
getDataBinder
(int viewType) Get data binder according to the view type.abstract int
abstract int
getItemViewType
(int position) abstract int
getPosition
(VB binder, int position) Get the position of a data binder item inside the recycler view.void
This method will be called when the data has been changed.void
notifyBinderItemChanged
(VB binder, int position) This method will be called when an item has been changed in the data binder.void
notifyBinderItemInserted
(VB binder, int position) This method will be called when an item has been inserted in the data binder.void
notifyBinderItemMoved
(VB binder, int fromPosition, int toPosition) This method will be called when an item has been moved in the data binder.abstract void
notifyBinderItemRangeChanged
(VB binder, int position, int itemCount) This method will be called when the item range of a data binder has been changed.abstract void
notifyBinderItemRangeInserted
(VB binder, int position, int itemCount) This method will be called when a set of items have been inserted in a data binder.abstract void
notifyBinderItemRangeRemoved
(VB binder, int position, int itemCount) This method will be called when a set of items have been removed in a data binder.void
notifyBinderItemRemoved
(VB binder, int position) This method will be called when an item has been removed in the data binder.void
onBindViewHolder
(RecyclerView.ViewHolder holder, int position) onCreateViewHolder
(ViewGroup parent, int viewType) Methods inherited from class com.pranavpandey.android.dynamic.support.recyclerview.adapter.DynamicRecyclerViewAdapter
getContext, getLayoutManager, getRecyclerView, isComputingLayout, onAttachedToRecyclerView
Methods inherited from class androidx.recyclerview.widget.RecyclerView.Adapter
bindViewHolder, createViewHolder, getItemId, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver
-
Constructor Details
-
DynamicBinderAdapter
public DynamicBinderAdapter()
-
-
Method Details
-
onCreateViewHolder
- Specified by:
onCreateViewHolder
in classRecyclerView.Adapter<RecyclerView.ViewHolder>
-
onBindViewHolder
- Specified by:
onBindViewHolder
in classRecyclerView.Adapter<RecyclerView.ViewHolder>
-
getItemCount
public abstract int getItemCount()- Specified by:
getItemCount
in classRecyclerView.Adapter<RecyclerView.ViewHolder>
-
getItemViewType
public abstract int getItemViewType(int position) - Overrides:
getItemViewType
in classRecyclerView.Adapter<RecyclerView.ViewHolder>
-
getDataBinder
Get data binder according to the view type.- Parameters:
viewType
- The view type constant to get the data binder.- Returns:
- The data binder associated with this view type.
- See Also:
-
getPosition
Get the position of a data binder item inside the recycler view.- Parameters:
binder
- The data binder inside the recycler view.position
- The position of the data binder item.- Returns:
- The position of the data binder item inside the recycler view.
-
getBinderPosition
public abstract int getBinderPosition(int position) Get the position of a data binder inside the recycler view.- Parameters:
position
- The position of the data binder.- Returns:
- The position of the data binder inside the recycler view.
-
notifyBinderDataSetChanged
public void notifyBinderDataSetChanged()This method will be called when the data has been changed. -
notifyBinderItemChanged
This method will be called when an item has been changed in the data binder.- Parameters:
binder
- The data binder inside the recycler view.position
- The position at which the item has been changed.
-
notifyBinderItemInserted
This method will be called when an item has been inserted in the data binder.- Parameters:
binder
- The data binder inside the recycler view.position
- The position at which the item is inserted.
-
notifyBinderItemRemoved
This method will be called when an item has been removed in the data binder.- Parameters:
binder
- The data binder inside the recycler view.position
- The position at which the item has been removed.
-
notifyBinderItemMoved
This method will be called when an item has been moved in the data binder.- Parameters:
binder
- The data binder inside the recycler view.fromPosition
- Initial position of the moved item.toPosition
- Final position of the moved item.
-
notifyBinderItemRangeChanged
This method will be called when the item range of a data binder has been changed.- Parameters:
binder
- The data binder inside the recycler view.position
- The position at which the first item has been changed.itemCount
- Total no. of items have been changed.
-
notifyBinderItemRangeInserted
This method will be called when a set of items have been inserted in a data binder.- Parameters:
binder
- The data binder inside the recycler view.position
- The position at which the first item has been inserted.itemCount
- Total no. of items have been inserted.
-
notifyBinderItemRangeRemoved
This method will be called when a set of items have been removed in a data binder.- Parameters:
binder
- The data binder inside the recycler view.position
- The position at which the first item has been removed.itemCount
- Total no. of items have been removed.
-