Skip to content

Instantly share code, notes, and snippets.

@adesamp
Last active June 8, 2021 09:14
Show Gist options
  • Save adesamp/f7313409bb958facb668fc76e4f79135 to your computer and use it in GitHub Desktop.
Save adesamp/f7313409bb958facb668fc76e4f79135 to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity() {
private lateinit var bmiBrain: BmiBrain
// initialize class
bmiBrain = BmiBrain(this)
// load value
binding.apply {
lifecycleScope.launch {
val name = async { bmiBrain.getName() }
edtName.setText(name.await())
}
}
// save value
val name = edtName.text.toString()
lifecycleScope.launch {
bmiBrain.saveName(name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment