-
Notifications
You must be signed in to change notification settings - Fork 553
5.x | Scrollable Headers and Footers
Scrollable Headers and Footers are special items that scroll along with all others, but they don't belongs to main items (business items) and they are always handled by the adapter beside the main items. Those items are persistently located at the first and last positions.
- Cannot be selectable nor draggable.
- Cannot be inserted twice, but many can be inserted.
- Can be added and removed with certain delay without impacts for the current selection.
- Can be of any type (also expandable) so they can be bound at runtime with any data inside. When expanded, subItems will become headers or footers too.
- Cannot be filtered because they are not part of the main list, but added separately at the initialization phase (basically, implementing
IFilterable
will be useless). -
Adding, updating, removing, moving and swapping main items with specific positions, must always be done via previous call
getGlobalPositionOf()
as usual. - The method
getMainItemCount()
will get the number of the main item only without scrollable headers count. That means that, the methodgetItemCount()
continues to returns the number of all items in the adapter, included headers and footers! - The size of
onUpdateEmptyView()
parameter represents the main item count! - Dragging main items doesn't impact the headers and footers.
- Headers lay always before any main item.
- Footers lay always after any main item.
-
progressItem
for endless scroll is a footer item but it is always displayed between the main items and the others footers, even if added later.
As shortly written, many Headers and Footers can be added, but cannot be inserted twice. There's an order of addition when multiple headers and footers are added: every new Header and Footer is added at the edge of list, with the exception of the progress item, as following:
Headers and Footers can be added and removed with a specific delay, and they follows the order of addition as shown above. Optionally the list can be smooth scrolled to the item when added. This means that, if you want to scroll to this item, the delay should be reasonable.
ℹ️ Note: The speed of the smooth scroll can be customized by changing the value
TopSnappedSmoothScroller.MILLISECONDS_PER_INCH
(100ms default) before creating the LayoutManager.
Adding Headers and Footers at startup without delay and when scroll animation (loading animation) is enabled, will animate those special items too, using the animations of the method FlexibleViewHolder.scrollAnimators(..)
.
But adding Headers and Footers at startup with delay, it will trigger the notification animation of the item (from ItemAnimator) if set. You should not use the scroll animation in this case, but you might want to specify a unique insert and remove animation by implementing AnimatedViewHolder
.
- 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!