|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectandroid.os.AsyncTask<ParameterT,ProgressT,ReturnT>
com.github.droidfu.concurrent.BetterAsyncTask<ParameterT,ProgressT,ReturnT>
ParameterT
- ProgressT
- ReturnT
- public abstract class BetterAsyncTask<ParameterT,ProgressT,ReturnT>
Works in a similar way to AsyncTask but provides extra functionality. 1) It keeps track of the active instance of each Context, ensuring that the correct instance is reported to. This is very useful if your Activity is forced into the background, or the user rotates his device. 2) A progress dialog is automatically shown. See useCustomDialog() disableDialog() 3) If an Exception is thrown from inside doInBackground, this is now handled by the handleError method. 4) You should now longer override onPreExecute(), doInBackground() and onPostExecute(), instead you should use before(), doCheckedInBackground() and after() respectively. These features require that the Application extends DroidFuApplication.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class android.os.AsyncTask |
---|
android.os.AsyncTask.Status |
Constructor Summary | |
---|---|
BetterAsyncTask(android.content.Context context)
Creates a new BetterAsyncTask who displays a progress dialog on the specified Context. |
Method Summary | |
---|---|
protected abstract void |
after(android.content.Context context,
ReturnT result)
A replacement for onPostExecute. |
protected void |
before(android.content.Context context)
Override to run code in the UI thread before this Task is run. |
void |
disableDialog()
Disable the display of a dialog during the execution of this task. |
protected ReturnT |
doCheckedInBackground(android.content.Context context,
ParameterT... params)
Override to perform computation in a background thread |
protected ReturnT |
doInBackground(ParameterT... params)
|
boolean |
failed()
Has an exception been thrown inside doCheckedInBackground() |
protected android.content.Context |
getCallingContext()
Gets the most recent instance of this Context. |
protected abstract void |
handleError(android.content.Context context,
Exception error)
Runs in the UI thread if there was an exception throw from doCheckedInBackground |
protected void |
onPostExecute(ReturnT result)
|
protected void |
onPreExecute()
|
void |
setCallable(BetterAsyncTaskCallable<ParameterT,ProgressT,ReturnT> callable)
Use a BetterAsyncTaskCallable instead of overriding doCheckedInBackground() |
void |
useCustomDialog(int dialogId)
Use a custom resource ID for the progress dialog |
Methods inherited from class android.os.AsyncTask |
---|
cancel, execute, get, get, getStatus, isCancelled, onCancelled, onProgressUpdate, publishProgress |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BetterAsyncTask(android.content.Context context)
context
- Method Detail |
---|
protected android.content.Context getCallingContext()
protected final void onPreExecute()
onPreExecute
in class android.os.AsyncTask<ParameterT,ProgressT,ReturnT>
protected void before(android.content.Context context)
context
- protected final ReturnT doInBackground(ParameterT... params)
doInBackground
in class android.os.AsyncTask<ParameterT,ProgressT,ReturnT>
protected ReturnT doCheckedInBackground(android.content.Context context, ParameterT... params) throws Exception
context
- params
-
Exception
protected abstract void handleError(android.content.Context context, Exception error)
context
- The most recent instance of the Context that executed this BetterAsyncTaskerror
- The thrown exception.protected final void onPostExecute(ReturnT result)
onPostExecute
in class android.os.AsyncTask<ParameterT,ProgressT,ReturnT>
protected abstract void after(android.content.Context context, ReturnT result)
context
- The most recent instance of the Context that executed this BetterAsyncTaskresult
- The result returned from doCheckedInBackgroundpublic boolean failed()
public void setCallable(BetterAsyncTaskCallable<ParameterT,ProgressT,ReturnT> callable)
callable
- public void useCustomDialog(int dialogId)
dialogId
- public void disableDialog()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |