https://github.com/hehonghui/simpletask
A Simple Task Library to use AsyncTask easier.
https://github.com/hehonghui/simpletask
Last synced: 9 months ago
JSON representation
A Simple Task Library to use AsyncTask easier.
- Host: GitHub
- URL: https://github.com/hehonghui/simpletask
- Owner: hehonghui
- License: mit
- Created: 2015-03-07T01:40:31.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-07T02:04:49.000Z (over 11 years ago)
- Last Synced: 2025-03-21T11:50:35.328Z (over 1 year ago)
- Language: Java
- Size: 112 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleTask
A Simple Task Library to use AsyncTask easier.Highly inspired by [TinyTask](https://github.com/inaka/TinyTask),but with a simpler API.
## Abstract
Android's AsyncTasks are highly criticized for being bad, unreliable, outdated, etc. Are they perfect? No. Do we have better alternatives? Sure, but sometimes all we want is a quick and simple way to run something in the background.
## What is it, really?
Just a simple wrapper around an AsyncTask, with a easier API.
See the case below :
```
new AsyncTask() {
protected void onPreExecute() {
}
@Override
protected String doInBackground(Void... params) {
return null;
}
protected void onPostExecute(String result) {
}
}.execute();
```
The two Void generic param is not necessary, but how can we simplify the work ? SimpleTask is the Answer.
## Usage
### jar
[SimpleTask.jar](library/simpletask.jar?raw=true "download") .
### Code Example
```
SimpleTask.newTask(new Worker() {
@Override
protected void beforeExecute() {
// execute before doInBackground. ( UI Thread )
}
@Override
protected String doInBackground() {
// do your work in background.
return null;
}
@Override
protected void afterExecute(String result) {
// execute after doInBackground. ( UI Thread )
}
}).execute();
```
## Different with TinyTask
* the api is more readble ;
* the api is simpler;
* type-safe, no warnning, see TinyTask : .