Search in sources :

Example 1 with GlobalComponent

use of com.byoutline.kickmaterial.dagger.GlobalComponent in project kickmaterial by byoutline.

the class DaggerRules method getActivityRule.

public static <ACTIVITY extends Activity> ActivityTestRule<ACTIVITY> getActivityRule(final AppComponentProvider mainComponentProv, Class<ACTIVITY> clazz) {
    final Handler mainHandler = new Handler(Looper.getMainLooper());
    return new DaggerActivityTestRule<>(clazz, (application, activity) -> {
        final KickMaterialApp app = (KickMaterialApp) application;
        final AppComponent appComponent = mainComponentProv.getComponent(app);
        final GlobalComponent globalComponent = DaggerGlobalComponent.builder().globalModule(new GlobalModule(app, appComponent.getBus(), appComponent.getAccessTokenProvider())).build();
        mainHandler.post(() -> app.setComponents(globalComponent, appComponent));
    });
}
Also used : GlobalModule(com.byoutline.kickmaterial.dagger.GlobalModule) AppComponent(com.byoutline.kickmaterial.dagger.AppComponent) Handler(android.os.Handler) KickMaterialApp(com.byoutline.kickmaterial.KickMaterialApp) GlobalComponent(com.byoutline.kickmaterial.dagger.GlobalComponent) DaggerGlobalComponent(com.byoutline.kickmaterial.dagger.DaggerGlobalComponent)

Aggregations

Handler (android.os.Handler)1 KickMaterialApp (com.byoutline.kickmaterial.KickMaterialApp)1 AppComponent (com.byoutline.kickmaterial.dagger.AppComponent)1 DaggerGlobalComponent (com.byoutline.kickmaterial.dagger.DaggerGlobalComponent)1 GlobalComponent (com.byoutline.kickmaterial.dagger.GlobalComponent)1 GlobalModule (com.byoutline.kickmaterial.dagger.GlobalModule)1