Class FetchingState

  • All Implemented Interfaces:
    com.inmobi.media.ads.common.base.state.State , com.inmobi.media.ads.common.listeners.AUMDestroyListener , com.inmobi.media.ads.common.listeners.FetchTimeoutListener , com.inmobi.media.ads.common.listeners.InternalLoadTimeoutListener

    
    public abstract class FetchingState
    extends AdManagerComponentWrapper implements State, FetchTimeoutListener, InternalLoadTimeoutListener, AUMDestroyListener
                        

    Represents the state when an ad unit manager is actively fetching ads from the server.

    This abstract state handles the ad fetching process using AdFetchManager, manages timeout scenarios, and processes the server response. It implements multiple listener interfaces to handle fetch timeouts, internal load timeouts, and destruction events. Upon successful ad retrieval, it transitions to the next appropriate state, while failures result in transition to FetchFailedState.

    • Method Detail

      • initialize

         Unit initialize()

        Initializes the fetching state and begins the ad fetch process.

        This method starts the fetch operation using AdFetchManager in a coroutine, handles successful responses by calling onAdResponseParseSuccess, and manages failures through handleAdFetchFailureException.

      • onInternalLoadTimeout

         Unit onInternalLoadTimeout()

        Handles internal load timeout during the fetch process.

        This method is called when an internal timeout occurs during ad fetching, resulting in transition to FetchFailedState with appropriate error code.

      • cleanUp

         Unit cleanUp()

        Finalizes the state and cancels the child coroutine scope.

      • onFetchTimeout

         Unit onFetchTimeout()

        Handles fetch timeout events.

        Called when the fetch operation times out, resulting in transition to FetchFailedState with timeout error code.