-
- All Implemented Interfaces:
public class ArrayAnyAdapter extends AnyAdapter
An AnyAdapter implemented with an ArrayList.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classArrayAnyAdapter.Companion
-
Constructor Summary
Constructors Constructor Description ArrayAnyAdapter(PresenterSelector presenterSelector)Constructs an adapter with the given PresenterSelector. ArrayAnyAdapter(Presenter presenter)Constructs an adapter that uses the given Presenter for all items. ArrayAnyAdapter()Constructs an adapter.
-
Method Summary
Modifier and Type Method Description Integersize()Returns the number of items in the adapter. Objectget(Integer position)final IntegerindexOf(Object item)Returns the index for the first occurrence of item in the adapter, or -1 if not found. final UnitnotifyArrayItemRangeChanged(Integer positionStart, Integer itemCount)Notify that the content of a range of items changed. final Unitadd(Object item)Adds an item to the end of the adapter. final Unitadd(Integer index, Object item)Inserts an item into this adapter at the specified index. final UnitaddAll(Integer index, Collection<Object> items)Adds the objects in the given collection to the adapter, starting at the given index. final Booleanremove(Object item)Removes the first occurrence of the given item from the adapter. final Unitmove(Integer fromPosition, Integer toPosition)Moved the item at fromPosition to toPosition. final Unitreplace(Integer position, Object item)Replaces item at position with a new item and calls notifyItemRangeChanged() at the given position. final IntegerremoveItems(Integer position, Integer count)Removes a range of items from the adapter. final Unitclear()Removes all items from this adapter, leaving it empty. final UnitsetItems(List<Object> itemList, DiffCallback<Object> callback)Set a new item list to adapter. -
Methods inherited from class de.pfaffenrodt.adapter.ArrayAnyAdapter
getItemCount, getItemViewType, getPresenter, onBindViewHolder, onCreateViewHolder, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled -
Methods inherited from class de.pfaffenrodt.adapter.AnyAdapter
bindViewHolder, canRestoreState, createViewHolder, findRelativeAdapterPositionIn, getItemId, getStateRestorationPolicy, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, registerAdapterDataObserver, setHasStableIds, setStateRestorationPolicy, unregisterAdapterDataObserver -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ArrayAnyAdapter
ArrayAnyAdapter(PresenterSelector presenterSelector)
Constructs an adapter with the given PresenterSelector.
-
ArrayAnyAdapter
ArrayAnyAdapter(Presenter presenter)
Constructs an adapter that uses the given Presenter for all items.
-
ArrayAnyAdapter
ArrayAnyAdapter()
Constructs an adapter.
-
-
Method Detail
-
indexOf
final Integer indexOf(Object item)
Returns the index for the first occurrence of item in the adapter, or -1 if not found.
- Parameters:
item- The item to find in the list.
-
notifyArrayItemRangeChanged
final Unit notifyArrayItemRangeChanged(Integer positionStart, Integer itemCount)
Notify that the content of a range of items changed. Note that this is not same as items being added or removed.
- Parameters:
positionStart- The position of first item that has changed.itemCount- The count of how many items have changed.
-
add
final Unit add(Object item)
Adds an item to the end of the adapter.
- Parameters:
item- The item to add to the end of the adapter.
-
add
final Unit add(Integer index, Object item)
Inserts an item into this adapter at the specified index. If the index is .getItemCount an exception will be thrown.
- Parameters:
index- The index at which the item should be inserted.item- The item to insert into the adapter.
-
addAll
final Unit addAll(Integer index, Collection<Object> items)
Adds the objects in the given collection to the adapter, starting at the given index. If the index is >= .getItemCount an exception will be thrown.
- Parameters:
index- The index at which the items should be inserted.items- A Collection of items to insert.
-
remove
final Boolean remove(Object item)
Removes the first occurrence of the given item from the adapter.
- Parameters:
item- The item to remove from the adapter.
-
move
final Unit move(Integer fromPosition, Integer toPosition)
Moved the item at fromPosition to toPosition.
- Parameters:
fromPosition- Previous position of the item.toPosition- New position of the item.
-
replace
final Unit replace(Integer position, Object item)
Replaces item at position with a new item and calls notifyItemRangeChanged() at the given position. Note that this method does not compare new item to existing item.
- Parameters:
position- The index of item to replace.item- The new item to be placed at given position.
-
removeItems
final Integer removeItems(Integer position, Integer count)
Removes a range of items from the adapter. The range is specified by giving the starting position and the number of elements to remove.
- Parameters:
position- The index of the first item to remove.count- The number of items to remove.
-
setItems
final Unit setItems(List<Object> itemList, DiffCallback<Object> callback)
Set a new item list to adapter. The DiffUtil will compute the difference and dispatch it to specified position.
- Parameters:
itemList- List of new Itemscallback- Optional DiffCallback Object to compute the difference between the old data set and new data set.
-
-
-
-