WindowInfoTrackerCallbackAdapter


class WindowInfoTrackerCallbackAdapter : WindowInfoTracker


An adapted interface for WindowInfoTracker that allows listening for events via a callback shaped API.

Summary

Public constructors

Public functions

Unit
addWindowLayoutInfoListener(
    activity: Activity,
    executor: Executor,
    consumer: Consumer<WindowLayoutInfo>
)

Registers a listener to consume WindowLayoutInfo values of the Activity window.

Unit
addWindowLayoutInfoListener(
    context: @UiContext Context,
    executor: Executor,
    consumer: Consumer<WindowLayoutInfo>
)

Registers a UiContext listener to consume WindowLayoutInfo values.

Unit

Remove a listener to stop consuming WindowLayoutInfo values.

Inherited functions

From androidx.window.layout.WindowInfoTracker
open Flow<WindowLayoutInfo>

A Flow of WindowLayoutInfo that contains all the available features.

open Flow<WindowLayoutInfo>

A Flow of WindowLayoutInfo that contains all the available features.

Inherited properties

From androidx.window.layout.WindowInfoTracker
open List<SupportedPosture>

Returns the List of SupportedPosture values.

Public constructors

WindowInfoTrackerCallbackAdapter

Added in 1.0.0
WindowInfoTrackerCallbackAdapter(tracker: WindowInfoTracker)

Public functions

addWindowLayoutInfoListener

Added in 1.0.0
fun addWindowLayoutInfoListener(
    activity: Activity,
    executor: Executor,
    consumer: Consumer<WindowLayoutInfo>
): Unit

Registers a listener to consume WindowLayoutInfo values of the Activity window. If the same consumer is registered twice then this method is a no-op.

Parameters
activity: Activity

an Activity that hosts a Window.

executor: Executor

that the consumer will invoke on.

consumer: Consumer<WindowLayoutInfo>

for WindowLayoutInfo values.

See also
windowLayoutInfo

addWindowLayoutInfoListener

Added in 1.1.0
fun addWindowLayoutInfoListener(
    context: @UiContext Context,
    executor: Executor,
    consumer: Consumer<WindowLayoutInfo>
): Unit

Registers a UiContext listener to consume WindowLayoutInfo values. If the same consumer is registered twice then this method is a no-op.

Parameters
context: @UiContext Context

a UiContext such as an Activity, created with Context#createWindowContext or is a InputMethodService.

executor: Executor

that the consumer will invoke on.

consumer: Consumer<WindowLayoutInfo>

for WindowLayoutInfo values.

See also
windowLayoutInfo

removeWindowLayoutInfoListener

Added in 1.0.0
fun removeWindowLayoutInfoListener(consumer: Consumer<WindowLayoutInfo>): Unit

Remove a listener to stop consuming WindowLayoutInfo values. If the listener has already been removed then this is a no-op.

See also
windowLayoutInfo