Skip to content

Instantly share code, notes, and snippets.

@caseykulm
Last active July 31, 2017 16:27
Show Gist options
  • Save caseykulm/c1cea230fb021e6c31975679573484e8 to your computer and use it in GitHub Desktop.
Save caseykulm/c1cea230fb021e6c31975679573484e8 to your computer and use it in GitHub Desktop.
public class App extends Application {
private AppComponent appComponent;
@Override
public void onCreate() {
appComponent = DaggerAppComponent
.module1(new Module1())
.etcModule(new EtcModule())
.build();
}
private static App get(Context context) {
return (App) context.getApplicationContext();
}
public static AppComponent getAppComponent(Context context) {
return get(context).appComponent;
}
}
public class SomeActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle bundle) {
App.get(this)
.inject(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment