Last active
February 20, 2018 13:49
-
-
Save pandulapeter/612a8c558446299cc3dba2f60a272d18 to your computer and use it in GitHub Desktop.
Example usage of BundleDelegate
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
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