Dependency Injection Integration

Purpose

This integration addresses the challenge of managing complex dependencies among the finite state machine (FSM) player, playback controllers, ad interfaces, and UI components within the dual-player media system. By employing Dagger 2 dependency injection, it ensures that these components are created, configured, and scoped consistently, promoting modularity, ease of testing, and cleaner separation of concerns within the player activity.

Functionality

The dependency injection setup provides scoped instances of critical playback components, wiring them together automatically and injecting them into the player activity. Key workflows include:

Example Injection Snippet

@Override
protected void injectDependency() {
    DaggerFsmComonentReal.builder()
        .fSMModuleReal(new FSMModuleReal(vpaidWebView, mTubiPlayerView))
        .build()
        .inject(this);
}

This call creates the Dagger graph, linking the player UI and ad controllers, FSM player, monitors, and ad interfaces for use within the activity.

Integration

Dependency Injection Integration tightly couples with the **Dual Player Activity** by supplying all necessary components the activity requires for orchestrating playback and ad logic. It abstracts away manual instantiation and configuration, thereby complementing:

This subtopic introduces the modular injection pattern, which is not covered in other dual player subtopics, providing a clean mechanism to manage component lifecycles and dependencies effectively.

Diagram

flowchart TD
    Activity[RealActivity]
    FSMModule[FSMModuleReal]
    Component[DaggerFsmComonentReal]
    FSMPlayer[FsmPlayerImperial]
    UIController[PlayerUIController]
    AdController[PlayerAdLogicController]
    AdRetriever[AdRetriever]
    CuePointRetriever[CuePointsRetriever]
    AdInterface[AdInterface Implementation]
    VpaidClient[TubiVPAID]
    WebView[WebView Instance]
    RootView[Player Root View]

    Activity -->|calls inject()| Component
    Component -->|provides| FSMPlayer
    Component -->|provides| UIController
    Component -->|provides| AdController
    Component -->|provides| AdRetriever
    Component -->|provides| CuePointRetriever
    Component -->|provides| AdInterface
    Component -->|provides| VpaidClient

    FSMModule -->|constructs| FSMPlayer
    FSMModule -->|constructs| UIController
    FSMModule -->|constructs| AdController
    FSMModule -->|constructs| AdRetriever
    FSMModule -->|constructs| CuePointRetriever
    FSMModule -->|constructs| AdInterface
    FSMModule -->|constructs| VpaidClient

    FSMModule --> WebView
    FSMModule --> RootView

This diagram visualizes how the `RealActivity` depends on the Dagger component to inject all necessary playback and ad-related components, which are constructed and provided by the `FSMModuleReal` using the WebView and root view as contextual parameters.