public class ModelAdapter<Model,Item extends IItem> extends AbstractAdapter<Item> implements IItemAdapter<Model,Item>
IItemAdapter.Predicate<Item extends IItem>mFastAdapter, mOrder| Constructor and Description |
|---|
ModelAdapter(IInterceptor<Model,Item> interceptor) |
ModelAdapter(IItemList<Item> itemList,
IInterceptor<Model,Item> interceptor) |
| Modifier and Type | Method and Description |
|---|---|
ModelAdapter<Model,Item> |
add(int position,
java.util.List<Model> list)
add a list of items at the given position within the existing items
|
ModelAdapter<Model,Item> |
add(int position,
Model... items)
add an array of items at the given position within the existing items
|
ModelAdapter<Model,Item> |
add(java.util.List<Model> list)
add a list of items to the end of the existing items
|
ModelAdapter<Model,Item> |
add(Model... items)
add an array of items to the end of the existing items
|
ModelAdapter<Model,Item> |
addInternal(int position,
java.util.List<Item> items)
add a list of items at the given position within the existing items
|
ModelAdapter<Model,Item> |
addInternal(java.util.List<Item> items)
add a list of items to the end of the existing items
|
ModelAdapter<Model,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
|
int |
getGlobalPosition(int position)
returns the global position if the relative position within this adapter was given
|
IIdDistributor<Item> |
getIdDistributor() |
IInterceptor<Model,Item> |
getInterceptor() |
ItemFilter<Model,Item> |
getItemFilter() |
IItemList<Item> |
getItemList() |
java.util.List<Model> |
getModels()
the ModelAdapter does not keep a list of input model's to get retrieve them a `reverseInterceptor` is required
usually it is used to get the `Model` from a `IModelItem`
|
IInterceptor<Item,Model> |
getReverseInterceptor() |
java.util.List<Item> |
intercept(java.util.List<Model> models)
Generates a List of Item based on it's List of Model using the interceptor
|
Item |
intercept(Model model)
Generates a `Item` based on it's `Model` using the interceptor
|
boolean |
isUseIdDistributor() |
static <Model,Item extends IItem> |
models(IInterceptor<Model,Item> interceptor)
static method to retrieve a new `ItemAdapter`
|
ModelAdapter<Model,Item> |
move(int fromPosition,
int toPosition)
moves an item within the list from a position to a position
|
Triple<java.lang.Boolean,Item,java.lang.Integer> |
recursive(AdapterPredicate<Item> predicate,
boolean stopOnMatch)
util function which recursively iterates over all items and subItems of the given adapter.
|
void |
remapMappedTypes()
forces to remap all possible types for the RecyclerView
|
ModelAdapter<Model,Item> |
remove(int position)
removes an item at the given position within the existing icons
|
ModelAdapter<Model,Item> |
removeByIdentifier(long identifier)
remvoes an item by it's identifier
|
ModelAdapter<Model,Item> |
removeRange(int position,
int itemCount)
removes a range of items starting with the given position within the existing icons
|
ModelAdapter<Model,Item> |
set(int position,
Model element)
sets an item at the given position, overwriting the previous item
|
ModelAdapter<Model,Item> |
set(java.util.List<Model> 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
|
protected ModelAdapter<Model,Item> |
set(java.util.List<Model> list,
boolean resetFilter) |
ModelAdapter<Model,Item> |
set(java.util.List<Model> list,
boolean resetFilter,
IAdapterNotifier adapterNotifier)
set a new list of model 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
|
ModelAdapter<Model,Item> |
setInternal(int position,
Item item)
sets an item at the given position, overwriting the previous item
|
ModelAdapter<Model,Item> |
setInternal(java.util.List<Item> items,
boolean resetFilter,
IAdapterNotifier adapterNotifier)
set a new list of model 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
|
ModelAdapter<Model,Item> |
setNewList(java.util.List<Model> items)
sets a complete new list of items onto this adapter, using the new list.
|
ModelAdapter<Model,Item> |
setNewList(java.util.List<Model> list,
boolean retainFilter)
sets a complete new list of items onto this adapter, using the new list.
|
AbstractAdapter<Item> |
withFastAdapter(FastAdapter<Item> fastAdapter)
set the FastAdapter which will handle this AbstractAdapter
|
ModelAdapter<Model,Item> |
withIdDistributor(IIdDistributor<Item> idDistributor)
defines the idDistributor that is used to provide an ID to all added items
|
ModelAdapter<Model,Item> |
withInterceptor(IInterceptor<Model,Item> mInterceptor) |
ModelAdapter<Model,Item> |
withItemFilter(ItemFilter<Model,Item> itemFilter)
allows you to define your own Filter implementation instead of the default `ItemFilter`
|
ModelAdapter<Model,Item> |
withReverseInterceptor(IInterceptor<Item,Model> reverseInterceptor) |
ModelAdapter<Model,Item> |
withUseIdDistributor(boolean useIdDistributor)
defines if the DefaultIdDistributor is used to provide an ID to all added items which do not yet define an id
|
getFastAdapter, getOrder, mapPossibleTypes, setOrderclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetFastAdapter, getOrder, mapPossibleTypes, setOrderpublic ModelAdapter(IInterceptor<Model,Item> interceptor)
public ModelAdapter(IItemList<Item> itemList, IInterceptor<Model,Item> interceptor)
public AbstractAdapter<Item> withFastAdapter(FastAdapter<Item> fastAdapter)
AbstractAdapterwithFastAdapter in interface IAdapter<Item extends IItem>withFastAdapter in class AbstractAdapter<Item extends IItem>public IItemList<Item> getItemList()
public static <Model,Item extends IItem> ModelAdapter<Model,Item> models(IInterceptor<Model,Item> interceptor)
public IInterceptor<Model,Item> getInterceptor()
public ModelAdapter<Model,Item> withInterceptor(IInterceptor<Model,Item> mInterceptor)
public IInterceptor<Item,Model> getReverseInterceptor()
public ModelAdapter<Model,Item> withReverseInterceptor(IInterceptor<Item,Model> reverseInterceptor)
public Item intercept(Model model)
model - the `Model` which will be used to create the `Item`public java.util.List<Item> intercept(java.util.List<Model> models)
models - the List of Model which will be used to create the List of Itempublic ModelAdapter<Model,Item> withIdDistributor(IIdDistributor<Item> idDistributor)
idDistributor - the idDistributor to usepublic IIdDistributor<Item> getIdDistributor()
public ModelAdapter<Model,Item> withUseIdDistributor(boolean useIdDistributor)
useIdDistributor - false if the DefaultIdDistributor shouldn't be usedpublic boolean isUseIdDistributor()
public ModelAdapter<Model,Item> withItemFilter(ItemFilter<Model,Item> itemFilter)
itemFilter - the filter to usepublic ItemFilter<Model,Item> getItemFilter()
public void filter(java.lang.CharSequence constraint)
constraint - the string used to filter the listpublic java.util.List<Model> getModels()
public 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 ModelAdapter<Model,Item> set(java.util.List<Model> items)
set in interface IItemAdapter<Model,Item extends IItem>items - the items to setprotected ModelAdapter<Model,Item> set(java.util.List<Model> list, boolean resetFilter)
public ModelAdapter<Model,Item> set(java.util.List<Model> list, boolean resetFilter, IAdapterNotifier adapterNotifier)
list - the items to setresetFilter - `true` if the filter should get resetadapterNotifier - a `IAdapterNotifier` allowing to modify the notify logic for the adapter (keep null for default)public ModelAdapter<Model,Item> setInternal(java.util.List<Item> items, boolean resetFilter, IAdapterNotifier adapterNotifier)
items - the items to setresetFilter - `true` if the filter should get resetadapterNotifier - a `IAdapterNotifier` allowing to modify the notify logic for the adapter (keep null for default)public ModelAdapter<Model,Item> setNewList(java.util.List<Model> items)
setNewList in interface IItemAdapter<Model,Item extends IItem>items - the new items to setpublic ModelAdapter<Model,Item> setNewList(java.util.List<Model> list, boolean retainFilter)
list - the new items to setretainFilter - set to true if you want to keep the filter appliedpublic void remapMappedTypes()
@SafeVarargs public final ModelAdapter<Model,Item> add(Model... items)
add in interface IItemAdapter<Model,Item extends IItem>items - the items to addpublic ModelAdapter<Model,Item> add(java.util.List<Model> list)
add in interface IItemAdapter<Model,Item extends IItem>list - the items to addpublic ModelAdapter<Model,Item> addInternal(java.util.List<Item> items)
IItemAdapteraddInternal in interface IItemAdapter<Model,Item extends IItem>@SafeVarargs public final ModelAdapter<Model,Item> add(int position, Model... items)
add in interface IItemAdapter<Model,Item extends IItem>position - the global positionitems - the items to addpublic ModelAdapter<Model,Item> add(int position, java.util.List<Model> list)
add in interface IItemAdapter<Model,Item extends IItem>position - the global positionlist - the items to addpublic ModelAdapter<Model,Item> addInternal(int position, java.util.List<Item> items)
IItemAdapteraddInternal in interface IItemAdapter<Model,Item extends IItem>position - the global positionpublic ModelAdapter<Model,Item> set(int position, Model element)
set in interface IItemAdapter<Model,Item extends IItem>position - the global positionelement - the item to setpublic ModelAdapter<Model,Item> setInternal(int position, Item item)
IItemAdaptersetInternal in interface IItemAdapter<Model,Item extends IItem>position - the global positionpublic ModelAdapter<Model,Item> move(int fromPosition, int toPosition)
fromPosition - the position global from which we want to movetoPosition - the global position to which to movepublic ModelAdapter<Model,Item> remove(int position)
remove in interface IItemAdapter<Model,Item extends IItem>position - the global positionpublic ModelAdapter<Model,Item> removeRange(int position, int itemCount)
removeRange in interface IItemAdapter<Model,Item extends IItem>position - the global positionitemCount - the count of items which were removedpublic ModelAdapter<Model,Item> clear()
clear in interface IItemAdapter<Model,Item extends IItem>public ModelAdapter<Model,Item> removeByIdentifier(long identifier)
identifier - the identifier to search forpublic Triple<java.lang.Boolean,Item,java.lang.Integer> recursive(AdapterPredicate<Item> predicate, boolean stopOnMatch)
predicate - the predicate to run on every item, to check for a match or do some changes (e.g. select)stopOnMatch - defines if we should stop iterating after the first match