LazyCollectionController

A controller that can be set on a LazyCollection to trigger external events. Most calls should be made on the main thread e.g. within a Style.onClick { } callback.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Tells if the refresh indicator is currently shown. Reflects the pending value when unbound.

Link copied to clipboard

Retrieve a reference to the RecyclerView. This should be avoided if possible, but may be necessary e.g. for custom animations.

Link copied to clipboard

A reference to the SnapHelper that is currently attached to the RecyclerView. If this LazyCollection isn't mounted or doesn't have an associated SnapHelper, returns null.

Functions

Link copied to clipboard
fun scrollBy(@Px dx: Int, @Px dy: Int)

Scroll the LazyCollection by a given number of pixels. The Scroll is instant. For an animated scroll use smoothScrollBy.

Link copied to clipboard
fun scrollToId(id: Any, @Px offset: Int = 0)

Scroll the LazyCollection so that the child with the given id is fully visible. For an animated scroll use smoothScrollToId.

Link copied to clipboard
fun scrollToIndex(index: Int, @Px offset: Int = 0)

Scroll the LazyCollection so that the child at the given index is fully visible. For an animated scroll use smoothScrollToIndex.

Link copied to clipboard
fun setRecyclerUpdate(listener: (RecyclerView?) -> Unit)

Request a callback when a RecyclerView is bound or unbound. The listener is retained for the controller's lifetime and auto-re-attached on every underlying-controller (re)bind, so it keeps firing across rebinds — including when a retained ComponentTree is rehosted onto a new LithoView and the RecyclerView is re-mounted (tab-switch back, rotation). Callers no longer need to re-register from their own mount/lifecycle hook. Pass an empty lambda to detach.

Link copied to clipboard
fun setRefreshing(isRefreshing: Boolean)

Toggle the refresh indicator. Not needed inside LazyCollection's onPullToRefresh callback — triggered automatically. Calls made before the controller binds are stashed (latest-wins) and applied once on bind.

Link copied to clipboard
fun smoothScrollBy(@Px dx: Int, @Px dy: Int)

Perform and animated scroll on the LazyCollection by a given number of pixels. For an instantaneous scroll use scrollBy.

Link copied to clipboard
fun smoothScrollToId(id: Any, @Px offset: Int = 0, smoothScrollAlignmentType: SmoothScrollAlignmentType = SmoothScrollAlignmentType.DEFAULT)

Perform an animated scroll on the LazyCollection so that the child with the given id is fully visible. For an animated scroll use smoothScrollToId.

Link copied to clipboard
fun smoothScrollToIndex(index: Int, @Px offset: Int = 0, smoothScrollAlignmentType: SmoothScrollAlignmentType = SmoothScrollAlignmentType.DEFAULT)

Perform an animated scroll on the LazyCollection so that the child at the given index is fully visible. For an instantaneous scroll use scrollToIndex.