Skip to content

Instantly share code, notes, and snippets.

@SUPERCILEX
Last active July 6, 2017 05:37
Show Gist options
  • Save SUPERCILEX/feeb14b6381c4d0f0c44a72622752534 to your computer and use it in GitHub Desktop.
Save SUPERCILEX/feeb14b6381c4d0f0c44a72622752534 to your computer and use it in GitHub Desktop.
val hadModel = ViewModelProviders.of(this).has(MyViewModel::class.java)
val model = ViewModelProviders.of(this).get(MyViewModel::class.java)
if (!hadModel) {
if (savedInstanceState != null) {
model.init(savedInstanceState.getMyStuff())
} else {
model.init(arguments.getMyStuff())
}
}
useModel()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment