LazyListPrefetchStrategy



Implementations of this interface control which indices of a LazyList should be prefetched (precomposed and premeasured during idle time) as the user interacts with it.

Implementations should invoke LazyListPrefetchScope.schedulePrefetch to schedule prefetches from the onScroll and onVisibleItemsUpdated callbacks. If any of the returned PrefetchHandles no longer need to be prefetched, use LazyLayoutPrefetchState.PrefetchHandle.cancel to cancel the request.

Summary

Public functions

Unit
LazyListPrefetchScope.onScroll(
    delta: Float,
    layoutInfo: LazyListLayoutInfo
)

onScroll is invoked when the LazyList scrolls, whether or not the visible items have changed.

Cmn
Unit

onVisibleItemsUpdated is invoked when the LazyList scrolls if the visible items have changed.

Cmn

Public properties

open PrefetchExecutor?

A PrefetchExecutor implementation which will be used to execute prefetch requests for this strategy implementation.

Cmn

Public functions

fun LazyListPrefetchScope.onScroll(
    delta: Float,
    layoutInfo: LazyListLayoutInfo
): Unit

onScroll is invoked when the LazyList scrolls, whether or not the visible items have changed. If the visible items have also changed, then this will be invoked in the same frame after onVisibleItemsUpdated.

delta can be used to understand scroll direction: delta < 0 indicates scrolling down while delta 0 indicates scrolling up.

onVisibleItemsUpdated

fun LazyListPrefetchScope.onVisibleItemsUpdated(
    layoutInfo: LazyListLayoutInfo
): Unit

onVisibleItemsUpdated is invoked when the LazyList scrolls if the visible items have changed. Info about these visible items can be found in layoutInfo's LazyListLayoutInfo.visibleItemsInfo.

Public properties

prefetchExecutor

open val prefetchExecutorPrefetchExecutor?

A PrefetchExecutor implementation which will be used to execute prefetch requests for this strategy implementation. If null, the default PrefetchExecutor for the platform will be used.