Last active
January 15, 2018 11:26
-
-
Save the-dagger/37e08ee1323bbb0de287c76f2690cf21 to your computer and use it in GitHub Desktop.
This file contains 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 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