You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 17, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+10-9Lines changed: 10 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -99,15 +99,15 @@ public void onStart(){
99
99
100
100
## 2. How it works
101
101
---
102
-
**Retaining tasks**
102
+
####**Retaining tasks**
103
103
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()`).
104
104
105
-
**Task without callback finishes**
105
+
####**Task without callback finishes**
106
106
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.
107
107
108
108
Only the `onPostExecute()` and `onCanceled()` methods will be redelivered, other methodes won't be redelivered.
109
109
110
-
**Task and Callback life-cycle**
110
+
####**Task and Callback life-cycle**
111
111
A `Task` basically has four life-cycle methods:
112
112
113
113
*`onPreExecute()`*[ui-thread]*
@@ -122,10 +122,10 @@ A `Callback` listener has the same life-cycle methods as the`Task` and reflects
122
122
---
123
123
Besides the basics there are some more advanced API's you will probably need.
124
124
125
-
**Getting task results**
125
+
####**Getting task results**
126
126
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.
127
127
128
-
**Getting the tasks current state**
128
+
####**Getting the tasks current state**
129
129
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:
130
130
131
131
*`isFinished()`
@@ -134,13 +134,13 @@ The Android `AsyncTask` API provides the `AsyncTask.getStatus()` method which re
134
134
*`isResultDelivered()`
135
135
*`isCanceled()`
136
136
137
-
**Getting the tasks last progress update**
137
+
####**Getting the tasks last progress update**
138
138
To get the tasks most recent progress update use the `getLastKnownProgress()` method.
139
139
140
-
**AdvancedCallback**
140
+
####**AdvancedCallback**
141
141
If you need the `onProgressUpdated` and `onCanceled` callback methods you can implement the `AdvancedCallback` interface, which is an extension of the `Callback` interface.
142
142
143
-
**TaskExecutor & Executor**
143
+
####**TaskExecutor & Executor**
144
144
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.
**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
+
166
167
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.
0 commit comments