OverlayControllerCallbackAdapter


class OverlayControllerCallbackAdapter


An adapted interface for OverlayController that provides callback shaped APIs to report the latest OverlayInfo.

It should only be used if OverlayController.overlayInfo is not available. For example, an app is written in Java and cannot use Flow APIs.

Summary

Public constructors

creates a callback adapter of OverlayController.overlayInfo flow API.

Public functions

Unit
@RequiresWindowSdkExtension(version = 5)
addOverlayInfoListener(
    overlayTag: String,
    executor: Executor,
    consumer: Consumer<OverlayInfo>
)

Registers a listener for updates of OverlayInfo that overlayTag is associated with.

Unit

Unregisters a listener that was previously registered via addOverlayInfoListener.

Public constructors

OverlayControllerCallbackAdapter

Added in 1.4.0-alpha05
OverlayControllerCallbackAdapter(controller: OverlayController)

creates a callback adapter of OverlayController.overlayInfo flow API.

Parameters
controller: OverlayController

an OverlayController that can be obtained by OverlayController.getInstance.

Public functions

addOverlayInfoListener

Added in 1.4.0-alpha05
@RequiresWindowSdkExtension(version = 5)
fun addOverlayInfoListener(
    overlayTag: String,
    executor: Executor,
    consumer: Consumer<OverlayInfo>
): Unit

Registers a listener for updates of OverlayInfo that overlayTag is associated with.

If there is no active overlay ActivityStack, the reported OverlayInfo.activityStack and OverlayInfo.currentOverlayAttributes will be null.

Note that launching an overlay ActivityStack only supports on the device with WindowSdkExtensions.extensionVersion equal to or larger than 5. If WindowSdkExtensions.extensionVersion is less than 5, this flow will always report OverlayInfo without associated OverlayInfo.activityStack.

Parameters
overlayTag: String

the overlay ActivityStack's tag which is set through OverlayCreateParams

executor: Executor

the Executor to dispatch the OverlayInfo change

consumer: Consumer<OverlayInfo>

the Consumer that will be invoked on the executor when there is an update to OverlayInfo.

removeOverlayInfoListener

Added in 1.4.0-alpha05
@RequiresWindowSdkExtension(version = 5)
fun removeOverlayInfoListener(consumer: Consumer<OverlayInfo>): Unit

Unregisters a listener that was previously registered via addOverlayInfoListener.

Parameters
consumer: Consumer<OverlayInfo>

the previously registered Consumer to unregister.