Skip to content

5.x | Library structure

Davide Steduto edited this page May 1, 2018 · 28 revisions

In this page


Under the hoood

  • At lower level there is SelectableAdapter class. It provides selection features and it's able to maintain the state after the rotation: you just need to call the onSave/onRestore methods from the Activity!
  • At middle level, the AnimatorAdapter class has been added to give some animation at startup and when user scrolls.
  • At front level, the core class FlexibleAdapter. It holds and handles the main list, performs actions on all different types of item paying attention at the adding and removal of the items, as well as the new concept of "selection coherence".
  • New useful extensions and helpers have been added during the time to simplify the development.
  • Item interfaces and predefined ViewHolders complete the whole library giving more actions to the items and configuration options to developers.


FlexibleAdapter diagram


Base package structure

Package / Class / Interface Description
eu.davidea.fastscroller
FastScroller FastScroller imported from the project LollipopContactsRecyclerViewFastScroller and significantly improved for this library: it works in conjunction with AnimatorAdapter; It has features like: Autohide, minimum scroll amount, ignore touches outside handle, etc...
FastScroller.Delegate Allows to handle the FastScroller with existing third adapters (Not FlexibleAdapter).
FastScroller.AdapterInterface Adapter interface to set the FastScroller in existing third adapters.
FastScroller.BubbleTextCreator Detached interface to create bubble content.
FastScroller.OnScrollStateChangeListener Detached interface to handle state changes.
BubbleAnimator Specs for Bubble animator.
ScrollbarAnimator Specs for Scrollbar animator.
eu.davidea.flexibleadapter
FlexibleAdapter Front level of the Adapter. It's the core of the library. Provides all methods to manage the items. Holds the main list and the event interfaces.
Extends AnimatorAdapter.
*AnimatorAdapter Middle level of the Adapter. Provides methods to animate the items at the startup and during scroll action.
Extends SelectableAdapter.
*SelectableAdapter Lowest level of the Adapter. Provides selection functionalities and the FastScroller methods.
Payload Predefinded payload enumeration.
eu.davidea.flexibleadapter.common
FlexibleLayoutManager Internal wrapper class for all conventional LayoutManagers.
IFlexibleLayoutManager Wrapper interface for any non-conventional LayoutManagers. This interface will make any third LayoutManager suitable for FlexibleAdapter.
eu.davidea.flexibleadapter.helpers
ItemTouchHelperCallback Internal helper for Drag&Drop and Swipe functionalities. Holds internal interfaces for the Adapter. It is not completed yet: For swipeable items, it will support a childViewHolder to be displayed below the current ViewHolder during the swipe action. It will provides easy way to add such view.
StickyHeaderHelper Internal helper to make a header sticky. Allows a sticky header to continue to listen the click events implemented in the FlexibleViewHolder.
eu.davidea.flexibleadapter.items
*AbstractFlexibleItem Abstract implementation for basic items. Holds flags and view holder creation.
*AbstractHeaderItem Abstract implementation for header items. Holds flag for sticky behavior. By default the header item is hidden and not selectable!
*AbstractExpandableItem Abstract implementation of expandable items. Holds an internal list for the subItems and the methods to manage it.
Extends AbstractFlexibleItem.
*AbstractExpandableHeaderItem Abstract implementation of expandable items that are also Headers.
*AbstractSectionableItem Abstract implementation of header items. Holds the item reference to which it is attached to.
IExpandable Add expandable functionality to the item. The adapter will check if the item belongs to this interface in order to be expanded or collapsed.
IFlexible Basic interface for any item, the Adapter relies on this interface to set and read the current item status. Also it provides methods to:
- Auto-map a view type
- Create and bind the ViewHolder of the item.
IHeader Basic interface for header item, the Adapter relies on this type to recognize that the item is a Header.
IHolder Interface for an Adapter item to hold a complex custom model object, to be independent by others RecyclerView used simultaneously to display the same object.
ISectionable Add Header functionality to the item. The Adapter treats this item differently, it holds a reference to the IHeader item, which is monitored and automatically adapted if this item is moved, removed or inserted.
IFilterable Add filter specification to the item, the Adapter recognizes if an item can be filtered if it implements this interface and then it calls filter() method.
eu.davidea.flexibleadapter.utils
LayoutUtils Utilities for position layout calculation, orientation and span count.
eu.davidea.viewholders
*AnimatedViewHolder Interface to start animations when Adding/Removing items. Overrides the custom ItemAnimator implementation.
*ContentViewHolder ViewHolder used to setup sticky headers content.
*ExpandableViewHolder ViewHolder for expandable items, you should extend this class if you want an expandable item, to benefit of the already implemented methods.
Extends FlexibleViewHolder.
*FlexibleViewHolder Basic ViewHolder. It handles the 4 listeners: ItemClickListener ItemLongClickListener ItemMoveListener ItemSwipeListener and the activation of the view. Also, it provides complex logic for selection coherence.
You should extend this class if you want to benefit of the already implemented methods.

* = Abstract class

UI extension library 👓

Package / Class / Interface Description
eu.davidea.flexibleadapter.common
FlexibleItemAnimator Custom ItemAnimator implementation when adding/removing items.
FlexibleItemDecoration Divider decoration between items with custom Drawable and section space separation.
SmoothScrollGridLayoutManager Enhanced GridLayoutManager that adds the AutoScroll behavior for expandable items.
SmoothScrollLinearLayoutManager Enhanced LinearLayoutManager that adds the AutoScroll behavior for expandable items.
SmoothScrollStaggeredLayoutManager Enhanced StaggeredGridLayoutManagerthat adds the AutoScroll behavior for expandable items.
TopSnappedSmoothScroller Common class used by the SmoothScroll layout managers.
eu.davidea.flexibleadapter.helpers
ActionModeHelper Helper to activate the ActionMode on Activities/Fragments. It collaborates with FlexibleAdapter to handle the multiple selection and click events.
AnimatorHelper Predefined methods for Scrolling Animation.
EmptyViewHelper Handle the visibility of empty views when no data is shown / found through filter.
UndoHelper Helper to undo any operation on the list managed by the FlexibleAdapter, it shows a configurable SnackBar.
eu.davidea.flexibleadapter.utils
DrawableUtils Utils for changing/assigning a background at runtime.
FlexibleUtils Utils for the library.
Methods are declared public static.