Class ViewabilityManagerImpl
-
- All Implemented Interfaces:
-
com.inmobi.media.ads.common.viewability.ViewabilityManager
public final class ViewabilityManagerImpl implements ViewabilityManager<Unit>
Concrete implementation of ViewabilityManager for tracking view viewability with duration-based measurement.
This class provides a comprehensive viewability tracking solution that monitors view visibility and emits events when views remain visible for the required duration. It integrates with a VisibilityTracker to detect visibility changes and implements precise timing logic to ensure accurate viewability measurement according to industry standards.
The implementation handles complex scenarios such as:
Preventing duplicate viewability events for the same view
Managing coroutine lifecycle and resource cleanup
Handling pause/resume cycles without losing tracking state
Canceling in-progress timing when views become invisible
The manager uses a flow-based architecture to provide reactive viewability events, making it easy to integrate with other reactive systems and UI components. It ensures thread safety and proper resource management throughout the viewability tracking lifecycle.
-
-
Constructor Summary
Constructors Constructor Description ViewabilityManagerImpl(VisibilityTracker visibilityTracker, ViewabilityTrackerConfig viewabilityTrackerConfig)
-
Method Summary
Modifier and Type Method Description Flow<Unit>startTracking()Starts tracking the viewability of the view. Unitresume()Resumes tracking the viewability of the view. Unitpause()Pauses tracking the viewability of the view. Unitstop()Stops tracking the viewability of the view and releases resources. -
-
Constructor Detail
-
ViewabilityManagerImpl
ViewabilityManagerImpl(VisibilityTracker visibilityTracker, ViewabilityTrackerConfig viewabilityTrackerConfig)
-
-
Method Detail
-
startTracking
Flow<Unit> startTracking()
Starts tracking the viewability of the view.
This method starts the VisibilityTracker and collects its events. When the view becomes visible, it starts a timer. If the view remains visible for the duration specified in viewabilityTrackerConfig.impressionMinDuration, an event is emitted through the Flow returned by this method.
- Returns:
A Flow that emits an event when the view becomes viewable for the required duration.
-
-
-
-