Created
July 28, 2019 06:50
-
-
Save Rapbong/0e5f0336d55fbaa01d219a67f795fc2f 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 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