🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

LazyLayoutPrefetchState

State for lazy items prefetching, used by lazy layouts to instruct the prefetcher.

Source set: Common
@Suppress("DEPRECATION") // b/420551535
public class LazyLayoutPrefetchState()

State for lazy items prefetching, used by lazy layouts to instruct the prefetcher.

Functions

schedulePrecomposition

Source set: Common
public fun schedulePrecomposition(@IntRange(from = 0) index: Int): PrefetchHandle

Schedules precomposition for the new item. If you also want to premeasure the item please use schedulePrecompositionAndPremeasure instead. This function should only be called once per item. If the item has already been composed at the time this request executes, either from a previous call to this function or because the item is already visible, this request should have no meaningful effect.

Parameters

index item index to prefetch.

Return

A PrefetchHandle which can be used to control the lifecycle of the prefetch request. Use PrefetchHandle.cancel to cancel the request or PrefetchHandle.markAsUrgent to mark the request as urgent.

schedulePrecompositionAndPremeasure

Source set: Common
public fun schedulePrecompositionAndPremeasure(
        @IntRange(from = 0) index: Int,
        constraints: Constraints,
        onItemPremeasured: (PrefetchResultScope.() -> Unit)? = null,
    ): PrefetchHandle

Schedules precomposition and premeasure for the new item. This should be used instead of schedulePrecomposition if you also want to premeasure the item. This function should only be called once per item. If the item has already been composed / measured at the time this request executes, either from a previous call to this function or because the item is already visible, this request should have no meaningful effect.

Parameters

index item index to prefetch.
constraints Constraints to use for premeasuring.
onItemPremeasured This callback is called when the item premeasuring is finished. If the request is canceled or no measuring is performed this callback won't be called. Use PrefetchResultScope.getSize to get the item's size.

Return

A PrefetchHandle which can be used to control the lifecycle of the prefetch request. Use PrefetchHandle.cancel to cancel the request or PrefetchHandle.markAsUrgent to mark the request as urgent.

Members

PrefetchHandle

Source set: Common
public sealed interface PrefetchHandle

A handle to control some aspects of the prefetch request.

Functions

cancel

Source set: Common
public fun cancel()

Notifies the prefetcher that previously scheduled item is no longer needed. If the item was precomposed already it will be disposed.

markAsUrgent

Source set: Common
public fun markAsUrgent()

Marks this prefetch request as urgent, which is a way to communicate that the requested item is expected to be needed during the next frame.

For urgent requests we can proceed with doing the prefetch even if the available time in the frame is less than we spend on similar prefetch requests on average.

PrefetchResultScope

Source set: Common
public sealed interface PrefetchResultScope

A scope for schedulePrecompositionAndPremeasure callbacks. The scope provides additional information about a prefetched item.

Properties

placeablesCount

Source set: Common
public val placeablesCount: Int

The amount of placeables composed into this item.

index

Source set: Common
public val index: Int

The index of the prefetched item.

Functions

getSize

Source set: Common
public fun getSize(@IntRange(from = 0) placeableIndex: Int): IntSize

Retrieves the latest measured size for a given placeable placeableIndex in pixels.