M
- Model which is binded by this classVH
- ViewHolder for this ItemBinder classpublic abstract class ItemBinder<M,VH extends ItemViewHolder<M>>
extends java.lang.Object
Constructor and Description |
---|
ItemBinder()
No-arg constructor for ItemBinder.
|
ItemBinder(Decorator decorator)
Initializes the ItemBinder class and adds the decorator to this ItemBinder.
|
Modifier and Type | Method and Description |
---|---|
void |
addDecorator(Decorator decorator)
Used to add
Decorator for the item binder. |
void |
addDecorator(Decorator decorator,
int priority)
Used to add
Decorator for the item binder with priority. |
abstract void |
bindViewHolder(VH holder,
M item) |
void |
bindViewHolder(VH holder,
M item,
java.util.List payloads) |
abstract boolean |
canBindData(java.lang.Object item) |
abstract VH |
createViewHolder(android.view.ViewGroup parent) |
int |
getSpanSize(int maxSpanCount)
Used to determine the span size for the
ItemBinder . |
android.view.View |
inflate(android.view.ViewGroup parent,
int layoutResId)
Utility method to inflate the View
|
void |
initViewHolder(VH holder)
This method is called immediately after
createViewHolder(android.view.ViewGroup) method is called. |
void |
removeAllDecorators()
Removes all decorators added to this ItemBinder
|
boolean |
removeDecorator(Decorator decorator)
Removes the first occurrence of the specified decorator from this ItemBinder.
|
void |
removeDecorator(int index)
Removes the decorator at the specified position from this ItemBinder.
|
public ItemBinder()
public ItemBinder(Decorator decorator)
decorator
- Decorator to be used for this ItemBinderpublic void addDecorator(Decorator decorator)
Decorator
for the item binder. If null value is set the method exits
silently.decorator
- Decorator
that needs to be addedpublic void addDecorator(Decorator decorator, int priority)
Decorator
for the item binder with priority. If null value is set the
method exits
* silently.decorator
- Decorator
to be addedpriority
- Position in the decoration chain to insert this decoration at. If this value
is negative the decoration will be added at the end.public void bindViewHolder(VH holder, M item, java.util.List payloads)
holder
- holder The ItemViewHolder which should be updated to represent the contents of
the
item at the given position in the data set.item
- The object which holds the datapayloads
- A non-null list of merged payloads. Can be empty list if requires full
update.bindViewHolder(ItemViewHolder, Object)
public int getSpanSize(int maxSpanCount)
ItemBinder
.
By default the ItemBinder
has the span size as 1. It can be overridden by the child
ItemBinder to provide the custom span size.
maxSpanCount
- The maximum span count of the GridLayoutManager
used inside the
RecyclerViewpublic android.view.View inflate(android.view.ViewGroup parent, int layoutResId)
parent
- The ViewGroup into which the new View will be added after it is bound to
an adapter position.layoutResId
- Layout to be inflatedpublic void initViewHolder(VH holder)
createViewHolder(android.view.ViewGroup)
method is called.
Use this method for setting click listeners and others similar stuff. For example, all the
initialization code inside the ItemViewHolder.ItemViewHolder(View)
is qualified to be
here.holder
- The ItemViewHolder which should be updated to represent the contents of
the item at the given position in the data set.public void removeAllDecorators()
public boolean removeDecorator(Decorator decorator)
decorator
- Decorator to be removed from this ItemBinder, if presentpublic void removeDecorator(int index)
index
- the index of the Decorator to be removedpublic abstract VH createViewHolder(android.view.ViewGroup parent)
parent
- The ViewGroup into which the new View will be added after it is bound to
an adapter position.ItemBinder
.public abstract void bindViewHolder(VH holder, M item)
holder
- holder The ItemViewHolder which should be updated to represent the contents of
the
item at the given position in the data set.item
- The object which holds the databindViewHolder(ItemViewHolder, Object, List)
public abstract boolean canBindData(java.lang.Object item)
item
- The object from the data setItemBinder
can bindViewHolder the
item to the ItemViewHolder