-
Notifications
You must be signed in to change notification settings - Fork 554
5.x | Callbacks
Davide Steduto edited this page May 25, 2017
·
14 revisions
-
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 listener. Optionally a listener can be an object of your preference. All you need to do is to pass the listeners object to the Constructor of the FlexibleAdapter OR to call the same function addListener(listener)
for all main types of listeners.
To be continued...
To be continued...
To be continued...
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
- OnActionListener
- OnUndoListener
To be continued...
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!