android / codelab-android-dagger

Apache License 2.0
181 stars 157 forks source link

Add separate branch implementing optional step from codelab #4

Open shumelchyk opened 4 years ago

shumelchyk commented 4 years ago

Add separate branch implementing optional step from codelab:

  1. [Optional] Try Dependency Injection on your own There's one more part of the codelab app for you to experiment with, and that's refactoring to have a SplashScreen: MainActivity.kt handles the logic of what screen needs to be shown when opening the app. That's problematic because we're doing conditional dependency injection, only injecting when the user will remain on the MainActivity.

These steps don't contain comments or code, so try it on your own:

Create a SplashActivity with a SplashViewModel that handles the logic of what screen to display. As we've been doing, use dependency injection in SplashActivity to get fields injected by Dagger. Remove the logic in the onCreate method of the MainActivity.kt since when the Activity is opened, the user will be logged in.