Last active
November 7, 2017 19:18
-
-
Save rachitmishra/5c8b45ee706472ab17711f96fbb4c840 to your computer and use it in GitHub Desktop.
dagger-android-activity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* An activity with a `HomeViewModel` dependency | |
*/ | |
class HomeActivity : AppCompatActivity() { | |
@Inject | |
lateinit var homeViewModel: HomeViewModel // Requesting the dependency | |
override fun onCreate(savedInstanceState: Bundle?) { | |
AndroidInjection.inject(this) // This line will initialise our dependency, and has to be called before `super` | |
super.onCreate(savedInstanceState) | |
val activityHomeBinding = setDataBindingView<ActivityHomeBinding>(R.layout.activity_home) | |
activityHomeBinding.viewModel = homeViewModel | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment