StorageTask

public abstract class StorageTask extends ControllableTask<TResult extends StorageTask.ProvideError>
Known Direct Subclasses

A controllable Task that has a synchronized state machine.

Nested Class Summary

interface StorageTask.ProvideError An object that returns an exception. 

Field Summary

protected final Object mSyncObject

Protected Constructor Summary

Public Method Summary

StorageTask<TResult>
addOnCompleteListener(OnCompleteListener<TResult> listener)
Adds a listener that is called when the Task succeeds or fails.
StorageTask<TResult>
addOnCompleteListener(Activity activity, OnCompleteListener<TResult> listener)
Adds a listener that is called when the Task succeeds or fails.
StorageTask<TResult>
addOnCompleteListener(Executor executor, OnCompleteListener<TResult> listener)
Adds a listener that is called when the Task succeeds or fails.
StorageTask<TResult>
addOnFailureListener(Activity activity, OnFailureListener listener)
Adds a listener that is called if the Task fails.
StorageTask<TResult>
addOnFailureListener(OnFailureListener listener)
Adds a listener that is called if the Task fails.
StorageTask<TResult>
addOnFailureListener(Executor executor, OnFailureListener listener)
Adds a listener that is called if the Task fails.
StorageTask<TResult>
addOnPausedListener(Executor executor, OnPausedListener<? super TResult> listener)
Adds a listener that is called when the Task becomes paused.
StorageTask<TResult>
addOnPausedListener(Activity activity, OnPausedListener<? super TResult> listener)
Adds a listener that is called when the Task becomes paused.
StorageTask<TResult>
addOnPausedListener(OnPausedListener<? super TResult> listener)
Adds a listener that is called when the Task becomes paused.
StorageTask<TResult>
addOnProgressListener(Executor executor, OnProgressListener<? super TResult> listener)
Adds a listener that is called periodically while the ControllableTask executes.
StorageTask<TResult>
addOnProgressListener(OnProgressListener<? super TResult> listener)
Adds a listener that is called periodically while the ControllableTask executes.
StorageTask<TResult>
addOnProgressListener(Activity activity, OnProgressListener<? super TResult> listener)
Adds a listener that is called periodically while the ControllableTask executes.
StorageTask<TResult>
addOnSuccessListener(OnSuccessListener<? super TResult> listener)
Adds a listener that is called if the Task completes successfully.
StorageTask<TResult>
addOnSuccessListener(Activity activity, OnSuccessListener<? super TResult> listener)
Adds a listener that is called if the Task completes successfully.
StorageTask<TResult>
addOnSuccessListener(Executor executor, OnSuccessListener<? super TResult> listener)
Adds a listener that is called if the Task completes successfully.
boolean
cancel()
Attempts to cancel the task.
<TContinuationResult> Task<TContinuationResult>
continueWith(Continuation<TResult, TContinuationResult> continuation)
Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.
<TContinuationResult> Task<TContinuationResult>
continueWith(Executor executor, Continuation<TResult, TContinuationResult> continuation)
Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.
<TContinuationResult> Task<TContinuationResult>
continueWithTask(Executor executor, Continuation<TResult, Task<TContinuationResult>> continuation)
Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.
<TContinuationResult> Task<TContinuationResult>
continueWithTask(Continuation<TResult, Task<TContinuationResult>> continuation)
Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.
Exception
getException()
Returns the exception that caused the Task to fail.
TResult
getResult()
Gets the result of the Task, if it has already completed.
<X extends Throwable> TResult
getResult(Class<X> exceptionType)
Gets the result of the Task, if it has already completed.
TResult
getSnapshot()
Returns the current state of the task.
boolean
isCanceled()
Returns true if the task has been canceled.
boolean
isComplete()
Returns true if the Task is complete; false otherwise.
boolean
isInProgress()
Returns true if the task is currently running.
boolean
isPaused()
Returns true if the task has been paused.
boolean
isSuccessful()
Returns true if the Task has completed successfully; false otherwise.
boolean
pause()
Attempts to pause the task.
StorageTask<TResult>
removeOnCompleteListener(OnCompleteListener<TResult> listener)
Removes a listener.
StorageTask<TResult>
removeOnFailureListener(OnFailureListener listener)
Removes a listener.
StorageTask<TResult>
removeOnPausedListener(OnPausedListener<? super TResult> listener)
Removes a listener.
StorageTask<TResult>
removeOnProgressListener(OnProgressListener<? super TResult> listener)
Removes a listener.
StorageTask<TResult>
removeOnSuccessListener(OnSuccessListener<? super TResult> listener)
Removes a listener.
boolean
resume()
Attempts to resume a paused task.

Protected Method Summary

void
void
void
void
void
void

Inherited Method Summary

Fields

protected final Object mSyncObject

Protected Constructors

protected StorageTask ()

Public Methods

public StorageTask<TResult> addOnCompleteListener (OnCompleteListener<TResult> listener)

Adds a listener that is called when the Task succeeds or fails.

The listener will be called on main application thread. If the task has already failed, a call to the listener will be immediately scheduled. If multiple listeners are added, they will be called in the order in which they were added.

Returns
  • this Task

public StorageTask<TResult> addOnCompleteListener (Activity activity,