-
public interface IFlexible<VH extends RecyclerView.ViewHolder>Basic interface to manage operations like enabling, selecting, hiding, filtering on items.
Implements this interface or use AbstractFlexibleItem.
-
-
Method Summary
Modifier and Type Method Description abstract booleanisEnabled()Returns if the Item is enabled. abstract voidsetEnabled(boolean enabled)Setter to change enabled behaviour. abstract booleanisHidden()(Internal usage).When and item has been deleted (with Undo) or has been filtered out by theadapter, then, it has hidden status. abstract voidsetHidden(boolean hidden)Setter to change hidden behaviour. abstract intgetSpanSize(int spanCount, int position)Individual item's span size to use only with {@code GridLayoutManager}.abstract booleanshouldNotifyChange(IFlexible newItem)Called by the FlexibleAdapter when it wants to check if this item should be boundagain with new content. abstract booleanisSelectable()Checks if the item can be selected. abstract voidsetSelectable(boolean selectable)Setter to change selectable behaviour. abstract StringgetBubbleText(int position)Custom bubble text for FastScroller. abstract booleanisDraggable()abstract voidsetDraggable(boolean draggable)abstract booleanisSwipeable()abstract voidsetSwipeable(boolean swipeable)abstract intgetItemViewType()Identifies a specific view type for this item, used by FlexibleAdapter to auto-mapthe ViewTypes. abstract intgetLayoutRes()Returns the layout resource ID to auto-inflate the View for this item. abstract VHcreateViewHolder(View view, FlexibleAdapter<IFlexible> adapter)Delegates the creation of the ViewHolder to the user (AutoMap). abstract voidbindViewHolder(FlexibleAdapter<IFlexible> adapter, VH holder, int position, List<Object> payloads)Delegates the binding of this item's data to the given Layout. abstract voidunbindViewHolder(FlexibleAdapter<IFlexible> adapter, VH holder, int position)Called when a view created by this adapter has been recycled. abstract voidonViewAttached(FlexibleAdapter<IFlexible> adapter, VH holder, int position)Called when a view created by this adapter has been attached to a window. abstract voidonViewDetached(FlexibleAdapter<IFlexible> adapter, VH holder, int position)Called when a view created by this adapter has been detached from its window. -
-
Method Detail
-
isEnabled
abstract boolean isEnabled()
Returns if the Item is enabled.
-
setEnabled
abstract void setEnabled(boolean enabled)
Setter to change enabled behaviour.
- Parameters:
enabled- false to disable all operations on this item
-
isHidden
abstract boolean isHidden()
(Internal usage).When and item has been deleted (with Undo) or has been filtered out by theadapter, then, it has hidden status.
-
setHidden
abstract void setHidden(boolean hidden)
Setter to change hidden behaviour. Useful while filtering this item.Default value is false.
- Parameters:
hidden- true if this item should remain hidden, false otherwise
-
getSpanSize
abstract int getSpanSize(int spanCount, int position)
Individual item's span size to use only with
{@code GridLayoutManager}.Note:
- Default implementation in AbstractFlexibleItem already returns 1.
- Not used when
{@code StaggeredGridLayoutManager}is set. With such layout use setFullSpan.
- Parameters:
spanCount- current column countposition- the adapter position of the item
-
shouldNotifyChange
abstract boolean shouldNotifyChange(IFlexible newItem)
Called by the FlexibleAdapter when it wants to check if this item should be boundagain with new content.
You should return
Note: This method won't be called if setNotifyChangeOfUnfilteredItems is disabled.{@code true}whether you want this item will be updated becauseits visual representations will change.Default value is
{@code true}.- Parameters:
newItem- The new item object with the new content
-
isSelectable
abstract boolean isSelectable()
Checks if the item can be selected.
-
setSelectable
abstract void setSelectable(boolean selectable)
Setter to change selectable behaviour.
- Parameters:
selectable- false to disable selection on this item
-
getBubbleText
abstract String getBubbleText(int position)
Custom bubble text for FastScroller.
To be called from the implementation of
{@code onCreateBubbleText()}. Example:public String onCreateBubbleText(int position) { return getItem(position).getBubbleText(position); }- Parameters:
position- the current mapped position
-
isDraggable
abstract boolean isDraggable()
-
setDraggable
abstract void setDraggable(boolean draggable)
-
isSwipeable
abstract boolean isSwipeable()
-
setSwipeable
abstract void setSwipeable(boolean swipeable)
-
getItemViewType
abstract int getItemViewType()
Identifies a specific view type for this item, used by FlexibleAdapter to auto-mapthe ViewTypes.
HELP: To know how to implement AutoMap for ViewTypes please refer to theFlexibleAdapter Wiki Pageon GitHub.
-
getLayoutRes
@LayoutRes() abstract int getLayoutRes()
Returns the layout resource ID to auto-inflate the View for this item. Optionally, youcan assign same layout for multiple item types, but getItemViewType mustreturn unique values!
NOTE: Should identify a resource Layout reference android.R.layout.
-
createViewHolder
abstract VH createViewHolder(View view, FlexibleAdapter<IFlexible> adapter)
Delegates the creation of the ViewHolder to the user (AutoMap).
HELP: To know how to implement AutoMap for ViewTypes please refer to theFlexibleAdapter Wiki Pageon GitHub.
- Parameters:
view- the already inflated viewadapter- the Adapter instance extending FlexibleAdapter
-
bindViewHolder
abstract void bindViewHolder(FlexibleAdapter<IFlexible> adapter, VH holder, int position, List<Object> payloads)
Delegates the binding of this item's data to the given Layout.
HELP: To know how to implement AutoMap for ViewTypes please refer to theFlexibleAdapter Wiki Pageon GitHub.
How to use Payload, please refer to onBindViewHolder.- Parameters:
adapter- the FlexibleAdapter instanceholder- the ViewHolder instanceposition- the current positionpayloads- a non-null list of merged payloads.
-
unbindViewHolder
abstract void unbindViewHolder(FlexibleAdapter<IFlexible> adapter, VH holder, int position)
Called when a view created by this adapter has been recycled.
A view is recycled when a
If an item view has large or expensive data bound to it such as large bitmaps, this may bea good place to release those resources.{@code RecyclerView.LayoutManager}decides that it no longerneeds to be attached to its parent RecyclerView. This can be because it has fallen outof visibility or a set of cached views represented by views still attached to the parentRecyclerView.- Parameters:
adapter- the FlexibleAdapter instanceholder- the ViewHolder instance being recycledposition- the current position
-
onViewAttached
abstract void onViewAttached(FlexibleAdapter<IFlexible> adapter, VH holder, int position)
Called when a view created by this adapter has been attached to a window.
This can be used as a reasonable signal that the view is about to be seen by the user.
- Parameters:
adapter- the FlexibleAdapter instanceholder- the ViewHolder instance being recycledposition- the current position
-
onViewDetached
abstract void onViewDetached(FlexibleAdapter<IFlexible> adapter, VH holder, int position)
Called when a view created by this adapter has been detached from its window.
Becoming detached from the window is not necessarily a permanent condition; the consumer of anAdapter's views may choose to cache views offscreen while they are not visible, attaching anddetaching them as appropriate.
- Parameters:
adapter- the FlexibleAdapter instanceholder- the ViewHolder instance being recycledposition- the current position
-
-
-
-