WindowInfoTrackerCallbackAdapter


public final class WindowInfoTrackerCallbackAdapter implements WindowInfoTracker


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

Summary

Public methods

final void
addWindowLayoutInfoListener(
    @NonNull Activity activity,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull WindowLayoutInfo> consumer
)

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

final void
addWindowLayoutInfoListener(
    @UiContext @NonNull Context context,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull WindowLayoutInfo> consumer
)

Registers a UiContext listener to consume WindowLayoutInfo values.

final void

Remove a listener to stop consuming WindowLayoutInfo values.

Inherited methods

From androidx.window.layout.WindowInfoTracker
@NonNull List<@NonNull SupportedPosture>

Returns the List of SupportedPosture values.

@NonNull Flow<@NonNull WindowLayoutInfo>

A Flow of WindowLayoutInfo that contains all the available features.

@NonNull Flow<@NonNull WindowLayoutInfo>

A Flow of WindowLayoutInfo that contains all the available features.

Public constructors

WindowInfoTrackerCallbackAdapter

Added in 1.0.0
public WindowInfoTrackerCallbackAdapter(@NonNull WindowInfoTracker tracker)

Public methods

addWindowLayoutInfoListener

Added in 1.0.0
public final void addWindowLayoutInfoListener(
    @NonNull Activity activity,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull WindowLayoutInfo> consumer
)

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
@NonNull Activity activity

an Activity that hosts a Window.

@NonNull Executor executor

that the consumer will invoke on.

@NonNull Consumer<@NonNull WindowLayoutInfo> consumer

for WindowLayoutInfo values.

See also
windowLayoutInfo

addWindowLayoutInfoListener

Added in 1.1.0
public final void addWindowLayoutInfoListener(
    @UiContext @NonNull Context context,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull WindowLayoutInfo> consumer
)

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

Parameters
@UiContext @NonNull Context context

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

@NonNull Executor executor

that the consumer will invoke on.

@NonNull Consumer<@NonNull WindowLayoutInfo> consumer

for WindowLayoutInfo values.

See also
windowLayoutInfo

removeWindowLayoutInfoListener

Added in 1.0.0
public final void removeWindowLayoutInfoListener(
    @NonNull Consumer<@NonNull WindowLayoutInfo> consumer
)

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

See also
windowLayoutInfo