Skip to content

Instantly share code, notes, and snippets.

@lewisevans
Last active November 15, 2018 16:33
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 lewisevans/f5b084b571f6d66cc7dec3ff41810420 to your computer and use it in GitHub Desktop.
Save lewisevans/f5b084b571f6d66cc7dec3ff41810420 to your computer and use it in GitHub Desktop.
abstract class BaseActivity<VM : BaseViewModel> : DaggerAppCompatActivity() {
@Inject
internal lateinit var viewModelFactory: ViewModelFactory<VM>
protected lateinit var viewModel:VM
internal inline fun <reified VM : ViewModel> viewModelWith(act: FragmentActivity): VM =
ViewModelProviders.of(act, viewModelFactory).get(VM::class.java)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment