CollectionPreparationManager

This class is responsible for preparing the items in the collection. It will prepare the items that are in the viewport and the items that are in the range of the viewport.

Constructors

Link copied to clipboard
constructor(layoutInfo: LayoutInfo)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Indicates whether an approximate range size has been calculated for the viewport. This property is used to determine if the collection has estimated how many items can fit in the visible area, which is essential for efficient range computation.

Functions

Link copied to clipboard
Link copied to clipboard
fun bind(view: RecyclerView, rangeRatio: Float, onEnterRange: (Int) -> Unit, onExitRange: (Int) -> Unit)
Link copied to clipboard
fun estimateItemsInViewPort(collectionSize: Size, childSize: Size)

Estimates the number of items that can fit in the viewport based on measuring a sample item. This calculation is performed only once when estimatedItemsInViewPort is unset and helps determine how many items should be prepared for rendering to optimize performance.

Link copied to clipboard
fun maybePostUpdateViewportAndComputeRange(firstVisibleIndex: Int = layoutInfo.findFirstVisibleItemPosition(), lastVisibleIndex: Int = layoutInfo.findLastVisibleItemPosition())

Attempts to update the viewport and compute the range of items that should be prepared. This method checks if the viewport needs updating and posts a runnable to handle the update. It also triggers computation of which items should enter or exit the preparation range.

Link copied to clipboard
Link copied to clipboard