-
Notifications
You must be signed in to change notification settings - Fork 554
5.x | Callbacks
-
Main exposed listeners
- OnUpdateListener
- OnDeleteCompleteListener
- OnItemClickListener
- OnItemLongClickListener
- OnActionStateListener
- OnItemMoveListener
- OnItemSwipeListener
- OnStickyHeaderChangeListener
-
Listener exposed through methods
- EndlessScrollListener
-
Overridden listeners
- BubbleTextCreator
- OnScrollStateChangeListener
- AdapterCallback
- ViewHolderCallback
- Others listeners
- Custom listeners
Usually, an Activity or Fragment can be an instance of multiple listeners. Optionally, a listener can be an object of your preference. All you need to do is to pass the listener object to the Constructor
of the FlexibleAdapter OR to call the function addListener(listener)
for ALL types of listeners.
Callback dedicated, mainly but not only, to update the emptyView of your design.
UndoHelper
will invoke this callback to confirm the items deletion after the timeout foreseen.
Activated when user taps an item, this callback is registered on the itemView
and propagated until the implementation through the Adapter where it resides.
Activated when user long press an item. Same concept of click listener.
Triggered by ItemTouchHelperCallback
, when the view changes state from being dragged, swiped and released by the user (end of a "drop" and "swipe" events).
Triggered by ItemTouchHelperCallback
when an item has been dragged far enough to trigger a move. This is called every time an item is shifted, and not at the end of a "drop" event.
Triggered by ItemTouchHelperCallback
when an item has been dismissed by a swipe.
Called by StickyHeaderHelper
when a sticky header has been swapped or cleared out.
This callback is registered through the method setEndlessScrollListener()
instead of via addListener()
, because the endless scroll works also without this callback, for instance, when the loading more is asked to the user which confirm it through a button, in this case should not be automatic.
The FlexibleAdapter
and the FlexibleViewHolder
implement some callback in order to provide specific features. You can of course override the exposed methods.
Provides basic implementation to display the current position in the bubble text of the FastScroller.
Provides info to AnimatorAdapter
to stop animating items if FastScroller is currently active.
Internal interface for Adapter to listen for a move or swipe dismissal event from ItemTouchHelperCallback
.
Internal Interface for ViewHolder to notify of relevant callbacks. This listener, is to intend as a further way to display how a ViewHolder will display the middle and final activation state. Generally the final action should be handled by the listeners OnItemMoveListener
and OnItemSwipeListener
.
The list of listeners is not finished :-)
There are more listeners that are covered in the dedicated pages for the ActionModeHelper
and UndoHelper
. However, here we just mention them:
- Android
ActionMode.Callback
- UndoHelper listeners
- onActionCanceled
- onActionConfirmed
Follow these steps:
- Override FlexibleAdapter with your own CustomAdapter and create a public field for the Callback interface that can be used in the ViewHolder. From now on, you will instantiate only CustomAdapter.
- The constructor of the CustomAdapter accepts the implementation of the callback.
- The constructor of the ViewHolder accept your CustomAdapter instead of FlexibleAdapter so when you create the ViewHolder you cast the Adapter to CustomAdapter.
- Inside the click listener of your button/image you can call the callback interface:
mAdapter.MyCallback
, where mAdapter is a private field in the ViewHolder initialized in the constructor. - The implementation of the callback can finally be done in the Activity / Fragment as a field or as implementation of the class itself.
- Update Data Set
- Selection modes
- Headers and Sections
- Scrollable Headers and Footers
- Expandable items
- Drag&Drop and Swipe
- EndlessScroll / On Load More
- Search Filter
- FastScroller
- Adapter Animations
- Third party Layout Managers
- Payload
- Smooth Layout Managers
- Flexible Item Decoration
- Utils
- ActionModeHelper
- AnimatorHelper
- EmptyViewHelper
- UndoHelper
* = Under revision!