Skip to content

Instantly share code, notes, and snippets.

@lukaspili
Created March 6, 2015 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaspili/45e5be2da3849e18498f to your computer and use it in GitHub Desktop.
Save lukaspili/45e5be2da3849e18498f to your computer and use it in GitHub Desktop.
public class App extends Application {
private MortarScope mortarScope;
private Component component;
@Override
public Object getSystemService(String name) {
return mortarScope.hasService(name) ? mortarScope.getService(name) : super.getSystemService(name);
}
@Override
public void onCreate() {
super.onCreate();
component = Dagger_App_Component.create();
component.inject(this);
mortarScope = MortarScope.buildRootScope()
.withService(DaggerService.SERVICE_NAME, component)
.build();
}
@dagger.Component
@Singleton
public static interface Component {
RestClient restClient();
SessionManager sessionManager();
void inject(App app);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment