vilnius / tvarkau-vilniu

Tvarkau Vilniu Android app
https://play.google.com/store/apps/details?id=lt.vilnius.tvarkau
MIT License
24 stars 14 forks source link

Refurbish Di using Dagger for Android 2.17 #235

Closed mjurkus closed 6 years ago

mjurkus commented 6 years ago

Lots of changes here but business logic is not changed.

This change simplifies dependency injection to the max. Now fragments and activities don't have to know how dependencies are injected. When new fragment is added - just do this

    @ContributesAndroidInjector
    abstract fun someNewFragment(): SomeNewFragment

and that's it.

@vycius

mjurkus commented 6 years ago

This also is required for correct ViewModel creation at runtime. Now we lose all ViewModels created @ onActivityCreated() since at the moment only at this point all dependencies are injected.

With this change - all dependencies are ready @ onCreate() and ViewModels will be created only once per fragment lifetime.