Skip to content
This repository was archived by the owner on Dec 17, 2020. It is now read-only.

Commit e4b543f

Browse files
author
Rolf Smit
committed
Updated readme.
1 parent c22813a commit e4b543f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ public void onStart(){
9999

100100
## 2. How it works
101101
---
102-
**Retaining tasks**
102+
####**Retaining tasks**
103103
Tasks retained using the described method are stored in a *"no-ui-fragment"* this fragment retained across configuration changes and is added to your Activity's `FragmentManager` the first time you call `TaskHandler.getActivityTaskHandler()`. This fragment is from that point on bound to the Activity's life-cycle and holds an internal `TaskHandler`. The fragment makes sure that the internal `TaskHandler` removes all `Callback` listeners as soon as the Activity is stopping (`onStop()`).
104104

105-
**Task without callback finishes**
105+
####**Task without callback finishes**
106106
When a Task doesn't have a `Callback` listener to deliver it's results to it will skip the delivery and redeliver the results as soon as a new listener is attached. If you call the `TaskHandler.attachListener()` method in the `onStart()` method, then the listener will be fired and you need to be sure that the user-interface is ready.
107107

108108
Only the `onPostExecute()` and `onCanceled()` methods will be redelivered, other methodes won't be redelivered.
109109

110-
**Task and Callback life-cycle**
110+
####**Task and Callback life-cycle**
111111
A `Task` basically has four life-cycle methods:
112112

113113
* `onPreExecute()` *[ui-thread]*
@@ -122,10 +122,10 @@ A `Callback` listener has the same life-cycle methods as the`Task` and reflects
122122
---
123123
Besides the basics there are some more advanced API's you will probably need.
124124

125-
**Getting task results**
125+
####**Getting task results**
126126
Unlike the default Android `AsyncTask` implementation you don't get `Task` results as a parameter, instead you will need to call the `Task.getResult()` method, which returns the tasks result.
127127

128-
**Getting the tasks current state**
128+
####**Getting the tasks current state**
129129
The Android `AsyncTask` API provides the `AsyncTask.getStatus()` method which returns an enum value which can be used to determinate the tasks current state. Instead of using that method combined with an enum you can use on of the following methods:
130130

131131
* `isFinished()`
@@ -134,13 +134,13 @@ The Android `AsyncTask` API provides the `AsyncTask.getStatus()` method which re
134134
* `isResultDelivered()`
135135
* `isCanceled()`
136136

137-
**Getting the tasks last progress update**
137+
####**Getting the tasks last progress update**
138138
To get the tasks most recent progress update use the `getLastKnownProgress()` method.
139139

140-
**AdvancedCallback**
140+
####**AdvancedCallback**
141141
If you need the `onProgressUpdated` and `onCanceled` callback methods you can implement the `AdvancedCallback` interface, which is an extension of the `Callback` interface.
142142

143-
**TaskExecutor & Executor**
143+
####**TaskExecutor & Executor**
144144
You can also execute tasks without using a `TaskHandler` this means that you are responsible for removing and setting the `Callback` listener. Executing tasks without using the `TaskHandler` is handy when you don't need to get any feedback to the Activity's user-interface.
145145

146146
```java
@@ -162,7 +162,8 @@ TaskExecutor.executeOnExecutor(new ExampleTask(), yourExecutor);
162162

163163
## 4. FAQ
164164

165-
**Why does the Task class still have the onPostExecute and onPreExecute etc. methods?**
165+
####**Why does the Task class still have the onPostExecute and onPreExecute etc. methods?**
166+
166167
Although the `Callback` interface provides these methods sometimes you don't need any callback to the Activity's user-interface, at that moment the Task methods come in handy.
167168
```java
168169
private class VerySimpleTask extends Task<Void, Boolean> {

0 commit comments

Comments
 (0)