Hola Amigos! 🙌, welcome to my coding playground! go on explore around 👩💻
Do let me know if you find something useful or want to suggest some improvement
also don't forget to checkout of blogs at chetangupta.net
LinkedIn | Medium | Twitter | StackOverflow | CodeWars | Portfolio | Github | Instagram | Youtube
Pooja's AsyncTask Challenge Self Implemented Async Task for Pooja Srivs Challenge
This is a sample project api design is similar to that of asyncTask,
abstract class AsyncTasker<Params, Progress, Result> {
abstract fun doInBackground(vararg many: Params): Result
abstract fun onPostExecute(data: Result)
abstract fun onPreExecute()
abstract fun onProgressUpdate(progress: Progress)
/** Extra function that is called when every task complete **/
abstract fun onCompleted(isInterrupted: Boolean)
/** controller function **/
fun execute(vararg many: Params) {
... doing stuff
}
/** function that interrupt underlying worker thread for immediate cancel of task **/
fun cancel() {
... doing stuff
}
}
Behind the Back uses HandlerThread
as worker thread and handler to perform the task.
- click fab to perform async task
- long click fab to perform cancel async task
- test cases
- flag to check background task is active
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.