Skip to content

Instantly share code, notes, and snippets.

@ch8n
Last active April 3, 2021 20:00
Show Gist options
  • Save ch8n/9cd4314eb5c1ff8aa4d366de1fc00e9a to your computer and use it in GitHub Desktop.
Save ch8n/9cd4314eb5c1ff8aa4d366de1fc00e9a to your computer and use it in GitHub Desktop.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
val binding = MainLayoutBinding.inflate(layoutInflater)
setup(binding)
}
// write binding once and forget ✅
fun setup(binding:MainLayoutBinding) = with(binding) {
textName.text = "ch8n"
textTwitter.text = "twitter@ch8n2"
}
// similar to withContext in coroutines ✅
suspend fun foo() = withContext(Dispachers.IO){
// .. do stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment