Guest User

Untitled

a guest
Nov 22nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. class AndroidInjectorApp: Application(), HasActivityInjector{
  2. companion object {
  3. @JvmStatic lateinit var appComponent: AppComponent
  4. }
  5.  
  6. @Inject
  7. lateinit var mActivityDispatchingAndroidInjector: DispatchingAndroidInjector<Activity>
  8.  
  9. override fun onCreate() {
  10. super.onCreate()
  11.  
  12. appComponent = createComponent()
  13. appComponent.inject(this)
  14.  
  15. }
  16.  
  17. /**
  18. * Initialize Dependency Injection With Dagger
  19. * Level DI Application
  20. * */
  21.  
  22.  
  23. fun createComponent(): AppComponent {
  24. val appComponent = DaggerAppComponent.builder()
  25. .application(this)
  26. .build()
  27. return appComponent
  28. }
  29.  
  30. override fun activityInjector(): AndroidInjector<Activity> {
  31. return mActivityDispatchingAndroidInjector
  32. }
  33.  
  34. }
Add Comment
Please, Sign In to add comment