{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

WindowRecomposerKt

public final class WindowRecomposerKt


Summary

Public methods

static final @NonNull Recomposer
@ExperimentalComposeUiApi
createLifecycleAwareWindowRecomposer(
    @NonNull View receiver,
    @NonNull CoroutineContext coroutineContext,
    Lifecycle lifecycle
)

Create a Lifecycle and window attachment-aware Recomposer for this View with the same behavior as WindowRecomposerFactory.LifecycleAware.

static final CompositionContext

Returns the parent CompositionContext for this point in the view hierarchy, or null if none can be found.

static final CompositionContext

The CompositionContext that should be used as a parent for compositions at or below this view in the hierarchy.

static final void
setCompositionContext(
    @NonNull View receiver,
    CompositionContext compositionContext
)

The CompositionContext that should be used as a parent for compositions at or below this view in the hierarchy.

Public methods

createLifecycleAwareWindowRecomposer

@ExperimentalComposeUiApi
public static final @NonNull Recomposer createLifecycleAwareWindowRecomposer(
    @NonNull View receiver,
    @NonNull CoroutineContext coroutineContext,
    Lifecycle lifecycle
)

Create a Lifecycle and window attachment-aware Recomposer for this View with the same behavior as WindowRecomposerFactory.LifecycleAware.

coroutineContext will override any CoroutineContext elements from the default configuration normally used for this content view. The default CoroutineContext contains AndroidUiDispatcher.CurrentThread; this function should only be called from the UI thread of this View or its intended UI thread if it is currently detached.

If lifecycle is null or not supplied the LifecycleOwner returned by findViewTreeLifecycleOwner will be used; if a non-null lifecycle is not provided and a ViewTreeLifecycleOwner is not present an IllegalStateException will be thrown.

The returned Recomposer will be cancelled when this View is detached from a window or if its determined Lifecycle is destroyed. Recomposition and associated frame-based effects may be throttled or paused while the Lifecycle is not at least Lifecycle.State.STARTED.

findViewTreeCompositionContext

public static final CompositionContext findViewTreeCompositionContext(@NonNull View receiver)

Returns the parent CompositionContext for this point in the view hierarchy, or null if none can be found.

See compositionContext to get or set the parent CompositionContext for a specific view.

getCompositionContext

public static final CompositionContext getCompositionContext(@NonNull View receiver)

The CompositionContext that should be used as a parent for compositions at or below this view in the hierarchy. Set to non-null to provide a CompositionContext for compositions created by child views, or null to fall back to any CompositionContext provided by ancestor views.

See findViewTreeCompositionContext.

setCompositionContext

public static final void setCompositionContext(
    @NonNull View receiver,
    CompositionContext compositionContext
)

The CompositionContext that should be used as a parent for compositions at or below this view in the hierarchy. Set to non-null to provide a CompositionContext for compositions created by child views, or null to fall back to any CompositionContext provided by ancestor views.

See findViewTreeCompositionContext.