VH - RecyclerView.ViewHolderpublic abstract class AbstractFlexibleItem<VH extends RecyclerView.ViewHolder> extends java.lang.Object implements IFlexible<VH>
IFlexible interface with most useful methods to manage
selection and view holder methods.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
mDraggable |
protected boolean |
mEnabled |
protected boolean |
mHidden |
protected boolean |
mSelectable |
protected boolean |
mSwipeable |
| Constructor and Description |
|---|
AbstractFlexibleItem() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
bindViewHolder(FlexibleAdapter<IFlexible> adapter,
VH holder,
int position,
java.util.List<java.lang.Object> payloads)
Delegates the binding of this item's data to the given Layout.
|
abstract VH |
createViewHolder(android.view.View view,
FlexibleAdapter<IFlexible> adapter)
Delegates the creation of the ViewHolder to the user (AutoMap).
|
abstract boolean |
equals(java.lang.Object o)
You MUST implement this method to compare items unique identifiers.
|
java.lang.String |
getBubbleText(int position)
Custom bubble text for FastScroller.
|
int |
getItemViewType()
Identifies a specific view type for this item, used by FlexibleAdapter to auto-map
the ViewTypes.
|
abstract int |
getLayoutRes()
Returns the layout resource ID to auto-inflate the View for this item.
|
int |
getSpanSize(int spanCount,
int position)
Individual item's span size to use only with
GridLayoutManager. |
boolean |
isDraggable() |
boolean |
isEnabled()
Returns if the Item is enabled.
|
boolean |
isHidden()
(Internal usage).
|
boolean |
isSelectable()
Checks if the item can be selected.
|
boolean |
isSwipeable() |
void |
onViewAttached(FlexibleAdapter<IFlexible> adapter,
VH holder,
int position)
Called when a view created by this adapter has been attached to a window.
|
void |
onViewDetached(FlexibleAdapter<IFlexible> adapter,
VH holder,
int position)
Called when a view created by this adapter has been detached from its window.
|
void |
setDraggable(boolean draggable) |
void |
setEnabled(boolean enabled)
Setter to change enabled behaviour.
|
void |
setHidden(boolean hidden)
Setter to change hidden behaviour.
|
void |
setSelectable(boolean selectable)
Setter to change selectable behaviour.
|
void |
setSwipeable(boolean swipeable) |
boolean |
shouldNotifyChange(IFlexible newItem)
Called by the FlexibleAdapter when it wants to check if this item should be bound
again with new content.
|
void |
unbindViewHolder(FlexibleAdapter<IFlexible> adapter,
VH holder,
int position)
Called when a view created by this adapter has been recycled.
|
protected boolean mEnabled
protected boolean mHidden
protected boolean mSelectable
protected boolean mDraggable
protected boolean mSwipeable
public abstract boolean equals(java.lang.Object o)
Adapter needs this method to distinguish them and pick up correct items.
See Writing a correctequals method to implement your own equals method.
Hint: If you don't use unique IDs, reimplement with Basic Java implementation:
public boolean equals(Object o) {
return this == o;
}
Important Note: When used with Hash[Map,Set], the general contract for the
equals and Object.hashCode() methods is that if equals returns true
for any two objects, then hashCode() must return the same value for these objects.
This means that subclasses of Object usually override either both methods or neither
of them.
equals in class java.lang.Objecto - instance to comparepublic boolean isEnabled()
IFlexiblepublic void setEnabled(boolean enabled)
IFlexiblesetEnabled in interface IFlexible<VH extends RecyclerView.ViewHolder>enabled - false to disable all operations on this itempublic boolean isHidden()
IFlexiblepublic void setHidden(boolean hidden)
IFlexiblepublic int getSpanSize(int spanCount,
int position)
IFlexibleGridLayoutManager.
Note:
AbstractFlexibleItem already returns 1.StaggeredGridLayoutManager is set. With such layout use
FlexibleViewHolder.setFullSpan(boolean).getSpanSize in interface IFlexible<VH extends RecyclerView.ViewHolder>spanCount - current column countposition - the adapter position of the itempublic boolean shouldNotifyChange(IFlexible newItem)
IFlexibleYou should return true whether you want this item will be updated because
its visual representations will change.
FlexibleAdapter.setNotifyChangeOfUnfilteredItems(boolean) is disabled.
Default value is true.
shouldNotifyChange in interface IFlexible<VH extends RecyclerView.ViewHolder>newItem - The new item object with the new contentpublic boolean isSelectable()
IFlexibleisSelectable in interface IFlexible<VH extends RecyclerView.ViewHolder>public void setSelectable(boolean selectable)
IFlexiblesetSelectable in interface IFlexible<VH extends RecyclerView.ViewHolder>selectable - false to disable selection on this itempublic java.lang.String getBubbleText(int position)
IFlexibleTo be called from the implementation of onCreateBubbleText(). Example:
public String onCreateBubbleText(int position) {
return getItem(position).getBubbleText(position);
}getBubbleText in interface IFlexible<VH extends RecyclerView.ViewHolder>position - the current mapped positionpublic boolean isDraggable()
isDraggable in interface IFlexible<VH extends RecyclerView.ViewHolder>public void setDraggable(boolean draggable)
setDraggable in interface IFlexible<VH extends RecyclerView.ViewHolder>public boolean isSwipeable()
isSwipeable in interface IFlexible<VH extends RecyclerView.ViewHolder>public void setSwipeable(boolean swipeable)
setSwipeable in interface IFlexible<VH extends RecyclerView.ViewHolder>public int getItemViewType()
HELP: To know how to implement AutoMap for ViewTypes please refer to the FlexibleAdapter Wiki Page on GitHub.
If not overridden return value is the same of getLayoutRes().
getItemViewType in interface IFlexible<VH extends RecyclerView.ViewHolder>public abstract int getLayoutRes()
IFlexible.getItemViewType() must
return unique values!
NOTE: Should identify a resource Layout reference R.layout.
getLayoutRes in interface IFlexible<VH extends RecyclerView.ViewHolder>public abstract VH createViewHolder(android.view.View view, FlexibleAdapter<IFlexible> adapter)
HELP: To know how to implement AutoMap for ViewTypes please refer to the FlexibleAdapter Wiki Page on GitHub.
createViewHolder in interface IFlexible<VH extends RecyclerView.ViewHolder>view - the already inflated viewadapter - the Adapter instance extending FlexibleAdapterpublic abstract void bindViewHolder(FlexibleAdapter<IFlexible> adapter, VH holder, int position, java.util.List<java.lang.Object> payloads)
HELP: To know how to implement AutoMap for ViewTypes please refer to the FlexibleAdapter Wiki Page on GitHub.
How to use Payload, please refer toRecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int, List).bindViewHolder in interface IFlexible<VH extends RecyclerView.ViewHolder>adapter - the FlexibleAdapter instanceholder - the ViewHolder instanceposition - the current positionpayloads - a non-null list of merged payloads. Can be empty list if requires full updatepublic void unbindViewHolder(FlexibleAdapter<IFlexible> adapter, VH holder, int position)
A view is recycled when a RecyclerView.LayoutManager decides that it no longer
needs to be attached to its parent RecyclerView. This can be because it has fallen out
of visibility or a set of cached views represented by views still attached to the parent
RecyclerView.
unbindViewHolder in interface IFlexible<VH extends RecyclerView.ViewHolder>adapter - the FlexibleAdapter instanceholder - the ViewHolder instance being recycledposition - the current positionpublic void onViewAttached(FlexibleAdapter<IFlexible> adapter, VH holder, int position)
This can be used as a reasonable signal that the view is about to be seen by the user.
onViewAttached in interface IFlexible<VH extends RecyclerView.ViewHolder>adapter - the FlexibleAdapter instanceholder - the ViewHolder instance being recycledposition - the current positionpublic void onViewDetached(FlexibleAdapter<IFlexible> adapter, VH holder, int position)
Becoming detached from the window is not necessarily a permanent condition; the consumer of an Adapter's views may choose to cache views offscreen while they are not visible, attaching and detaching them as appropriate.
onViewDetached in interface IFlexible<VH extends RecyclerView.ViewHolder>adapter - the FlexibleAdapter instanceholder - the ViewHolder instance being recycledposition - the current position