WindowInfoTrackerCallbackAdapter

Added in 1.0.0
Deprecated in 1.6.0-alpha05

public final class WindowInfoTrackerCallbackAdapter implements WindowInfoTracker


An adapter for WindowInfoTracker that allows listening for WindowLayoutInfo updates using callbacks instead of Flow.

This adapter is no longer necessary the callback-based listeners have been added to WindowLayoutInfo. Use WindowInfoTracker directly.

Summary

Public constructors

This method is deprecated. This constructor is no longer necessary.

Public methods

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

This method is deprecated. Use WindowInfoTracker.registerWindowLayoutInfoListener(Activity, Executor, Consumer).

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

This method is deprecated. Use WindowInfoTracker.registerWindowLayoutInfoListener(Context, Executor, Consumer).

void

This method is deprecated. Use WindowInfoTracker.registerWindowLayoutInfoListener(Context, Executor, Consumer).

final void

This method is deprecated. Use WindowInfoTracker.unregisterWindowLayoutInfoListener(Consumer).

void

This method is deprecated. Use WindowInfoTracker.unregisterWindowLayoutInfoListener(Consumer).

Inherited methods

From androidx.window.layout.WindowInfoTracker
@NonNull WindowLayoutInfo

This method is deprecated. This adapter is no longer necessary.

@NonNull List<@NonNull SupportedPosture>

This method is deprecated. This adapter is no longer necessary.

void

This method is deprecated. This adapter is no longer necessary.

void

This method is deprecated. This adapter is no longer necessary.

@NonNull Flow<@NonNull WindowEngagementInfo>

This method is deprecated. This adapter is no longer necessary.

@NonNull Flow<@NonNull WindowLayoutInfo>

This method is deprecated. This adapter is no longer necessary.

@NonNull Flow<@NonNull WindowLayoutInfo>

This method is deprecated. This adapter is no longer necessary.

Public constructors

WindowInfoTrackerCallbackAdapter

Added in 1.0.0
Deprecated in 1.6.0-alpha05
public WindowInfoTrackerCallbackAdapter(@NonNull WindowInfoTracker tracker)

Use WindowInfoTracker constructor instead.

Public methods

addWindowLayoutInfoListener

Added in 1.0.0
Deprecated in 1.6.0-alpha05
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 from a kotlinx.coroutines.flow.Flow. If the same consumer is registered twice then this method is a no-op.

Use WindowInfoTracker.registerWindowLayoutInfoListener instead.

Parameters
@NonNull Activity activity

an Activity that hosts a android.view.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
Deprecated in 1.6.0-alpha05
public final void addWindowLayoutInfoListener(
    @UiContext @NonNull Context context,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull WindowLayoutInfo> consumer
)

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

Use WindowInfoTracker.registerWindowLayoutInfoListener instead.

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

registerWindowLayoutInfoListener

public void registerWindowLayoutInfoListener(
    @UiContext @NonNull Context context,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull WindowLayoutInfo> listener
)

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

Use WindowInfoTracker.registerWindowLayoutInfoListener instead.

Parameters
@UiContext @NonNull Context context

a UiContext such as an Activity.

@NonNull Executor executor

that the listener will invoke on.

@NonNull Consumer<@NonNull WindowLayoutInfo> listener

for WindowLayoutInfo values.

See also
windowLayoutInfo

removeWindowLayoutInfoListener

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

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

Use WindowInfoTracker.unregisterWindowLayoutInfoListener instead.

See also
windowLayoutInfo

unregisterWindowLayoutInfoListener

public void unregisterWindowLayoutInfoListener(
    @NonNull Consumer<@NonNull WindowLayoutInfo> listener
)

Unregisters a listener to stop consuming WindowLayoutInfo values. Overridden here for compatibility.

Use WindowInfoTracker.unregisterWindowLayoutInfoListener instead.

Parameters
@NonNull Consumer<@NonNull WindowLayoutInfo> listener

The listener to be removed.

See also
windowLayoutInfo