Class WindowLifecycleHandler
-
- All Implemented Interfaces:
public final class WindowLifecycleHandlerHandles window lifecycle events and tracks window visibility state for a given view.
This class provides a comprehensive solution for monitoring window visibility changes across different Android API levels. It adapts its behavior based on the device's Android version, using direct window visibility observation for Android UDC+ and focus-based polling for older versions. The handler automatically manages the lifecycle of listeners and coroutines to prevent memory leaks.
-
-
Constructor Summary
Constructors Constructor Description WindowLifecycleHandler(Long windowPollingInterval, CoroutineScope coroutineScope, View observableView, InMobiLogger logger)
-
Method Summary
Modifier and Type Method Description final Flow<Boolean>observeWindowStateChanges()Provides a flow that emits window visibility state changes. final Unitdestroy()Destroys the lifecycle handler and cleans up all associated resources. -
-
Constructor Detail
-
WindowLifecycleHandler
WindowLifecycleHandler(Long windowPollingInterval, CoroutineScope coroutineScope, View observableView, InMobiLogger logger)
- Parameters:
windowPollingInterval- The interval in milliseconds for polling window state on older Android versionscoroutineScope- The CoroutineScope for managing asynchronous operationsobservableView- The View to observe for window state changes
-
-
Method Detail
-
observeWindowStateChanges
final Flow<Boolean> observeWindowStateChanges()
Provides a flow that emits window visibility state changes.
- Returns:
A Flow<Boolean> that emits true when the window is visible, false when invisible
-
-
-
-