Esempio n. 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Timber.plant(new Timber.DebugTree());

    setContentView(R.layout.activity_main);

    Timber.d("MainActivity before inject, mDemoNewDependency: " + mDemoNewDependency);
    Timber.d("MainActivity before inject, mDemoInjectDependency: " + mDemoInjectDependency);
    Timber.d(
        "MainActivity before inject, mDemoDirectInjectDependency: " + mDemoDirectInjectDependency);

    mComponent =
        DaggerDemoComponent.builder()
            .contextModule(new ContextModule(getApplicationContext()))
            .build();
    Timber.d("MainActivity inject, component: " + mComponent);
    mComponent.inject(this);

    Timber.d("MainActivity after inject, mDemoNewDependency: " + mDemoNewDependency);
    Timber.d("MainActivity after inject, mDemoInjectDependency: " + mDemoInjectDependency);
    Timber.d(
        "MainActivity after inject, mDemoDirectInjectDependency: " + mDemoDirectInjectDependency);

    getSupportFragmentManager()
        .beginTransaction()
        .add(android.R.id.content, new BlankFragment())
        .commit();
  }
Esempio n. 2
0
 // 初始化组件
 public static DemoComponent init(DemoApplication app) {
   return DaggerDemoComponent.builder().mainModule(new MainModule(app)).build();
 }