Skip to content

Instantly share code, notes, and snippets.

@Rapbong
Created July 28, 2019 06:50
Show Gist options
  • Save Rapbong/0e5f0336d55fbaa01d219a67f795fc2f to your computer and use it in GitHub Desktop.
Save Rapbong/0e5f0336d55fbaa01d219a67f795fc2f to your computer and use it in GitHub Desktop.
class MainViewModel : ViewModel() {
...
fun onClick() {
val handler = Handler()
handler.postDelayed(runnable, 1500)
val asyncTask = BackGroundTask(eventData)
asyncTask.execute()
}
}
class BackGroundTask(private val eventData: MutableLiveData<String>) : AsyncTask<String, String, Int>() {
override fun doInBackground(vararg p0: String?): Int {
Thread.sleep(500)
eventData.postValue("AsyncTask")
return 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment