Class AttachedStateCollector

  • All Implemented Interfaces:
    kotlinx.coroutines.flow.FlowCollector

    
    public final class AttachedStateCollector
     implements FlowCollector<Boolean>
                        

    Flow collector that manages window visibility observation based on view attachment state.

    This collector starts visibility observation when the view is attached to the window and stops it when detached. It handles the transition between different observation strategies based on the Android API level and manages the lifecycle of observation jobs.

    • 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
      Unit emit(Boolean value) Handles attachment state changes by starting or stopping visibility observation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AttachedStateCollector

        AttachedStateCollector(CoroutineScope coroutineScope, View observableView, MutableStateFlow<Boolean> visibilityStateFlow, Long windowPollingInterval, InMobiLogger logger)
        Parameters:
        coroutineScope - The CoroutineScope for launching visibility observation
        observableView - The View being observed for visibility changes
        visibilityStateFlow - The MutableStateFlow to emit visibility state changes to
        windowPollingInterval - The polling interval for older Android versions
    • Method Detail

      • emit

         Unit emit(Boolean value)

        Handles attachment state changes by starting or stopping visibility observation.

        Parameters:
        value - true if the view is attached to window, false if detached