Skip to content

Instantly share code, notes, and snippets.

@the-dagger
Last active January 15, 2018 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-dagger/37e08ee1323bbb0de287c76f2690cf21 to your computer and use it in GitHub Desktop.
Save the-dagger/37e08ee1323bbb0de287c76f2690cf21 to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//Notice that I didn't need to call findViewById(), thanks to Synthetic Binding!
btndownload.setOnClickListener { downloadData() }
}
fun downloadData() {
doAsync {
//Execute all the lon running tasks here
val s: String = makeNetworkCall()
uiThread {
//Update the UI thread here
alert("Downloaded data is $s", "Hi I'm an alert") {
yesButton { toast("Yay !") }
noButton { toast(":( !") }
}.show()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment