Skip to content

Instantly share code, notes, and snippets.

@pandulapeter
Last active February 20, 2018 13:49
Show Gist options
  • Save pandulapeter/612a8c558446299cc3dba2f60a272d18 to your computer and use it in GitHub Desktop.
Save pandulapeter/612a8c558446299cc3dba2f60a272d18 to your computer and use it in GitHub Desktop.
Example usage of BundleDelegate
class GameActivity : AppCompatActivity() {
private var Bundle.score by BundleDelegate.Int("key_score")
private var score = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
savedInstanceState?.let { score = it.score }
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.score = score
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment