-
- All Implemented Interfaces:
public abstract class BaseRecyclerViewAdapter<T extends Object> extends RecyclerView.Adapter<BaseRecyclerViewHolder<T>>
Base RecyclerViewAdapter that uses BaseRecyclerViewHolder for click and long click support.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
BaseRecyclerViewAdapter.Companion
-
Constructor Summary
Constructors Constructor Description BaseRecyclerViewAdapter(List<T> items, Function1<T, Unit> onItemClick, Function1<T, Unit> onItemLongClick, DiffCallback<T> diffCallback)
-
Method Summary
Modifier and Type Method Description BaseRecyclerViewHolder<T>
onCreateViewHolder(ViewGroup parent, Integer viewType)
Unit
onBindViewHolder(BaseRecyclerViewHolder<T> viewHolder, Integer position)
Integer
getItemCount()
final ArrayList<T>
getItems()
Returns the items in the data set held by this adapter. final List<T>
getItems(Function1<T, Boolean> predicate)
Returns the items that are filtered by class in the data set held by this adapter. Unit
setItems(List<T> items)
Sets new items to display in this adapter. final Unit
addItems(List<T> items)
Add new items to display in this adapter. final Unit
clearItems()
Clear all items in this adapter. final T
getItem(Integer position)
Returns the item at the specified position in this adapter. final T
first()
Returns the non null first item in this adapter. final T
firstOrNull()
Returns the first item (null or not) in this adapter. final Unit
addItem(T item, Integer position)
Add a new item to display in this adapter. final Unit
updateItem(T item)
Update an item to display in this adapter. final Unit
updateItem(T item, Integer position)
Update the item at position in this adapter. final Unit
removeItem(Integer position)
Remove the item at position from this adapter. final Unit
removeItem(T item)
Remove an item displaying in this adapter. final Integer
indexOf(T item)
final Boolean
isEmpty()
Returns true if the items in this adapter is empty. final Unit
setItemClickListener(Function1<T, Unit> onItemClick)
Register a callback to be invoked when an item is clicked. final Unit
setItemLongClickListener(Function1<T, Unit> onItemLongClick)
Register a callback to be invoked when an item is clicked and held. -
Methods inherited from class com.pointrlabs.core.map.views.helper_views.BaseRecyclerViewAdapter
bindViewHolder, createViewHolder, getItemId, getItemViewType, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
onCreateViewHolder
BaseRecyclerViewHolder<T> onCreateViewHolder(ViewGroup parent, Integer viewType)
-
onBindViewHolder
Unit onBindViewHolder(BaseRecyclerViewHolder<T> viewHolder, Integer position)
-
getItemCount
Integer getItemCount()
-
getItems
final List<T> getItems(Function1<T, Boolean> predicate)
Returns the items that are filtered by class in the data set held by this adapter.
-
setItems
Unit setItems(List<T> items)
Sets new items to display in this adapter.
- Parameters:
items
- The items to display in this adapter.
-
addItems
final Unit addItems(List<T> items)
Add new items to display in this adapter.
- Parameters:
items
- The items to display in this adapter.
-
clearItems
final Unit clearItems()
Clear all items in this adapter.
-
getItem
final T getItem(Integer position)
Returns the item at the specified position in this adapter.
- Parameters:
position
- position of the item to return
-
firstOrNull
final T firstOrNull()
Returns the first item (null or not) in this adapter.
-
addItem
final Unit addItem(T item, Integer position)
Add a new item to display in this adapter.
- Parameters:
item
- The item to add.
-
updateItem
final Unit updateItem(T item)
Update an item to display in this adapter.
- Parameters:
item
- The item to be updated.
-
updateItem
final Unit updateItem(T item, Integer position)
Update the item at position in this adapter.
- Parameters:
item
- The item to be updated.position
- Position of the item to be updated
-
removeItem
final Unit removeItem(Integer position)
Remove the item at position from this adapter.
- Parameters:
position
- The position at which the item to remove.
-
removeItem
final Unit removeItem(T item)
Remove an item displaying in this adapter.
- Parameters:
item
- The item to remove.
-
setItemClickListener
final Unit setItemClickListener(Function1<T, Unit> onItemClick)
Register a callback to be invoked when an item is clicked.
- Parameters:
onItemClick
- callback
-
setItemLongClickListener
final Unit setItemLongClickListener(Function1<T, Unit> onItemLongClick)
Register a callback to be invoked when an item is clicked and held.
- Parameters:
onItemLongClick
- callback
-
-
-
-