public class ItemAdapter<Item extends IItem> extends AbstractAdapter<Item> implements IItemAdapter<Item>
IItemAdapter.Predicate<Item extends IItem>| Modifier and Type | Field and Description |
|---|---|
protected java.util.Comparator<Item> |
mComparator |
| Constructor and Description |
|---|
ItemAdapter() |
| Modifier and Type | Method and Description |
|---|---|
ItemAdapter<Item> |
add(int position,
Item... items)
add an array of items at the given position within the existing items
|
ItemAdapter<Item> |
add(int position,
java.util.List<Item> items)
add a list of items at the given position within the existing items
|
ItemAdapter<Item> |
add(Item... items)
add an array of items to the end of the existing items
|
ItemAdapter<Item> |
add(java.util.List<Item> items)
add a list of items to the end of the existing items
|
ItemAdapter<Item> |
clear()
removes all items of this adapter
|
void |
filter(java.lang.CharSequence constraint)
filters the items with the constraint using the provided Predicate
|
Item |
getAdapterItem(int position) |
int |
getAdapterItemCount()
defines the count of items of THIS adapter
|
java.util.List<Item> |
getAdapterItems() |
int |
getAdapterPosition(Item item)
Searches for the given item and calculates its relative position
|
int |
getAdapterPosition(long identifier)
Searches for the given identifier and calculates its relative position
|
java.util.Comparator<Item> |
getComparator() |
int |
getGlobalPosition(int position)
returns the global position if the relative position within this adapter was given
|
ItemFilter<Item> |
getItemFilter() |
int |
getOrder()
defines in which order this adapter should be hooked into the FastAdapter
|
boolean |
isUseIdDistributor() |
ItemAdapter<Item> |
move(int fromPosition,
int toPosition)
moves an item within the list from a position to a position
|
void |
remapMappedTypes()
forces to remap all possible types for the RecyclerView
|
ItemAdapter<Item> |
remove(int position)
removes an item at the given position within the existing icons
|
ItemAdapter<Item> |
removeRange(int position,
int itemCount)
removes a range of items starting with the given position within the existing icons
|
ItemAdapter<Item> |
set(int position,
Item item)
sets an item at the given position, overwriting the previous item
|
ItemAdapter<Item> |
set(java.util.List<Item> items)
set a new list of items and apply it to the existing list (clear - add) for this adapter
NOTE may consider using setNewList if the items list is a reference to the list which is used inside the adapter
NOTE this will not sort
|
protected ItemAdapter<Item> |
set(java.util.List<Item> items,
boolean resetFilter) |
ItemAdapter<Item> |
setNewList(java.util.List<Item> items)
sets a complete new list of items onto this adapter, using the new list.
|
ItemAdapter<Item> |
setNewList(java.util.List<Item> items,
boolean retainFilter)
sets a complete new list of items onto this adapter, using the new list.
|
<T extends IItem & IExpandable<T,S>,S extends IItem & ISubItem<Item,T>> |
setSubItems(T collapsible,
java.util.List<S> subItems)
sets the subItems of the given collapsible
This method also makes sure identifiers are set if we use the IdDistributor
|
ItemAdapter<Item> |
withComparator(java.util.Comparator<Item> comparator)
define a comparator which will be used to sort the list "everytime" it is altered
NOTE this will only sort if you "set" a new list or "add" new items (not if you provide a position for the add function)
|
ItemAdapter<Item> |
withComparator(java.util.Comparator<Item> comparator,
boolean sortNow)
define a comparator which will be used to sort the list "everytime" it is altered
NOTE this will only sort if you "set" a new list or "add" new items (not if you provide a position for the add function)
|
ItemAdapter<Item> |
withItemFilter(ItemFilter<Item> itemFilter)
allows you to define your own Filter implementation instead of the default `ItemFilter`
|
ItemAdapter |
withUseIdDistributor(boolean useIdDistributor)
defines if the IdDistributor is used to provide an ID to all added items which do not yet define an id
|
clearMappedTypes, getFastAdapter, getItem, getItemCount, getItemId, getItemViewType, mapPossibleType, mapPossibleTypes, onAttachedToRecyclerView, onBindViewHolder, onBindViewHolder, onCreateViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver, wrap, wrapbindViewHolder, createViewHolder, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemovedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetFastAdapter, getItem, getItemCountpublic ItemAdapter withUseIdDistributor(boolean useIdDistributor)
useIdDistributor - false if the IdDistributor shouldn't be usedpublic boolean isUseIdDistributor()
public ItemAdapter<Item> withItemFilter(@NonNull ItemFilter<Item> itemFilter)
itemFilter - the filter to use@NonNull public ItemFilter<Item> getItemFilter()
public void filter(@Nullable
java.lang.CharSequence constraint)
constraint - the string used to filter the listpublic ItemAdapter<Item> withComparator(java.util.Comparator<Item> comparator)
comparator - used to sort the listpublic ItemAdapter<Item> withComparator(java.util.Comparator<Item> comparator, boolean sortNow)
comparator - used to sort the listsortNow - specifies if we use the provided comparator to sort nowpublic java.util.Comparator<Item> getComparator()
public int getOrder()
IAdapterpublic int getAdapterItemCount()
IAdaptergetAdapterItemCount in interface IAdapter<Item extends IItem>public java.util.List<Item> getAdapterItems()
getAdapterItems in interface IAdapter<Item extends IItem>public int getAdapterPosition(Item item)
getAdapterPosition in interface IAdapter<Item extends IItem>item - the item which is searched forpublic int getAdapterPosition(long identifier)
getAdapterPosition in interface IAdapter<Item extends IItem>identifier - the identifier of an item which is searched forpublic int getGlobalPosition(int position)
getGlobalPosition in interface IAdapter<Item extends IItem>position - the relative positionpublic Item getAdapterItem(int position)
getAdapterItem in interface IAdapter<Item extends IItem>position - the relative positionpublic <T extends IItem & IExpandable<T,S>,S extends IItem & ISubItem<Item,T>> T setSubItems(T collapsible, java.util.List<S> subItems)
setSubItems in interface IItemAdapter<Item extends IItem>collapsible - the collapsible which gets the subItems setsubItems - the subItems for this collapsible itempublic ItemAdapter<Item> set(java.util.List<Item> items)
set in interface IItemAdapter<Item extends IItem>items - the items to setprotected ItemAdapter<Item> set(java.util.List<Item> items, boolean resetFilter)
public ItemAdapter<Item> setNewList(java.util.List<Item> items)
setNewList in interface IItemAdapter<Item extends IItem>items - the new items to setpublic ItemAdapter<Item> setNewList(java.util.List<Item> items, boolean retainFilter)
items - the new items to setretainFilter - set to true if you want to keep the filter appliedpublic void remapMappedTypes()
@SafeVarargs public final ItemAdapter<Item> add(Item... items)
add in interface IItemAdapter<Item extends IItem>items - the items to addpublic ItemAdapter<Item> add(java.util.List<Item> items)
add in interface IItemAdapter<Item extends IItem>items - the items to add@SafeVarargs public final ItemAdapter<Item> add(int position, Item... items)
add in interface IItemAdapter<Item extends IItem>position - the global positionitems - the items to addpublic ItemAdapter<Item> add(int position, java.util.List<Item> items)
add in interface IItemAdapter<Item extends IItem>position - the global positionitems - the items to addpublic ItemAdapter<Item> set(int position, Item item)
set in interface IItemAdapter<Item extends IItem>position - the global positionitem - the item to setpublic ItemAdapter<Item> move(int fromPosition, int toPosition)
fromPosition - the position global from which we want to movetoPosition - the global position to which to movepublic ItemAdapter<Item> remove(int position)
remove in interface IItemAdapter<Item extends IItem>position - the global positionpublic ItemAdapter<Item> removeRange(int position, int itemCount)
removeRange in interface IItemAdapter<Item extends IItem>position - the global positionitemCount - the count of items which were removedpublic ItemAdapter<Item> clear()
clear in interface IItemAdapter<Item extends IItem>