Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit c48c50c

Browse files
Update README.md
1 parent cd19f0e commit c48c50c

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

README.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,56 @@
1-
# AsyncTaskNeo
2-
### Android AsyncTask using kotlin Coroutines
1+
AsyncTaskNeo
2+
============
3+
4+
[![Version](https://jitpack.io/v/alibardide5124/AsyncTaskNeo.svg)](https://jitpack.io/#alibardide5124/AsyncTaskNeo)
5+
[![API](https://img.shields.io/badge/API-16%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=16)
6+
7+
Android AsyncTask using kotlin Coroutines
8+
<br/>
9+
After AsyncTask deprecated on API 29, I was looking for something to replace it with. And i found this soloution using `Kotlin Coroutins` on StackOverflow. So i decided to publish it as a library. Maybe someone needs this.
10+
11+
Implement
12+
---------
13+
Add it in your root build.gradle at the end of repositories:
14+
```groovy
15+
allprojects {
16+
repositories {
17+
...
18+
maven { url 'https://jitpack.io' }
19+
}
20+
}
21+
```
22+
Then Add the dependency
23+
```groovy
24+
dependencies {
25+
implementation 'com.github.alibardide5124:AsyncTaskNeo:LEAST_VERSION'
26+
}
27+
```
28+
Usage
29+
-----
30+
You can use this library by typing `AsyncTaskNeo.executeAsyncTask<Output, Progress>()`
31+
This function needs three input, and all of them are functions... `onPreExecute`, `doInBackground`, `onProgressUpdate` and `onPostExecute`.Just like the original AsyncTask.
32+
Here is an example of using:
33+
```kotlin
34+
AsyncTaskNeo.executeAsyncTask<Boolean, Int> (
35+
onPreExecute = {
36+
// Do something before heavy task
37+
},
38+
doInBackground = { publishProgress ->
39+
// Do some heavy works. Dont update ui here. Call publish progress for updating ui.
40+
true // Then return a Boolean (for example)
41+
},
42+
onProgressUpdate = {
43+
// Update ui here
44+
textview.text = it.toString()
45+
},
46+
onPostExecute = {
47+
// Do something on the end
48+
}
49+
)
50+
```
51+
52+
How was it? I hope you use it if you needs this.
53+
54+
License
55+
-------
56+
AsyncTaskNeo created by [Ali Bardide](https://github.com/alibardide5124) and it's licensed under a [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).

0 commit comments

Comments
 (0)