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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Flow<Unit> startTracking() Starts tracking the viewability of the view.
      Unit resume() Resumes tracking the viewability of the view.
      Unit pause() Pauses tracking the viewability of the view.
      Unit stop() Stops tracking the viewability of the view and releases resources.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.

      • resume

         Unit resume()

        Resumes tracking the viewability of the view.

      • pause

         Unit pause()

        Pauses tracking the viewability of the view.

      • stop

         Unit stop()

        Stops tracking the viewability of the view and releases resources.