TeamAmaze / AmazeFileManager

Material design file manager for Android
https://teamamaze.xyz
GNU General Public License v3.0
5.24k stars 1.56k forks source link

Adopt Kotlin coroutines over AsyncTask #2726

Open TranceLove opened 3 years ago

TranceLove commented 3 years ago

Perhaps this convenient class may help too: https://medium.com/@rahulraks25/migrating-asynctask-to-kotlin-coroutines-e93e9f45d995

Github: https://github.com/ladrahul25/CoroutineAsyncTask

EmmanuelMess commented 3 years ago

Related #2668

EmmanuelMess commented 3 years ago

I don't think that keeping the "onPreExcecute, doInBackground, publishProgress, onPostExecute" all in one file is a good idea. I've started moving the "doInBackground" part to another file, as a callable, and everything else into a "Task", and I've separated the "onPostExcecute" into "onFinish" and "onError", this allows for tasks to fail without crashing the app.

All this was done using ReactiveX (RxAndroid). If the above model can be kept when moving to coroutines it would be a good idea IMO.