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, OnCompleteListener<TResult> listener)

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

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.

Parameters
activity When the supplied Activity stops, this listener will automatically be removed.
Returns
  • this Task

public StorageTask<TResult> addOnCompleteListener (Executor executor, OnCompleteListener<TResult> listener)

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

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.

Parameters
executor the executor to use to call the listener
Returns
  • this Task

public StorageTask<TResult> addOnFailureListener (Activity activity, OnFailureListener listener)

Adds a listener that is called if the Task fails.

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.

Parameters
activity When the supplied Activity stops, this listener will automatically be removed.
Returns
  • this Task

public StorageTask<TResult> addOnFailureListener (OnFailureListener listener)

Adds a listener that is called if the Task 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> addOnFailureListener (Executor executor, OnFailureListener listener)

Adds a listener that is called if the Task fails.

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.

Parameters
executor the executor to use to call the listener
Returns
  • this Task

public StorageTask<TResult> addOnPausedListener (Executor executor, OnPausedListener<? super TResult> listener)

Adds a listener that is called when the Task becomes paused.

Parameters
executor the executor to use to call the listener
Returns
  • this Task

public StorageTask<TResult> addOnPausedListener (Activity activity, OnPausedListener<? super TResult> listener)

Adds a listener that is called when the Task becomes paused.

Parameters
activity When the supplied Activity stops, this listener will automatically be removed.
Returns
  • this Task

public StorageTask<TResult> addOnPausedListener (OnPausedListener<? super TResult> listener)

Adds a listener that is called when the Task becomes paused.

Returns
  • this Task

public StorageTask<TResult> addOnProgressListener (Executor executor, OnProgressListener<? super TResult> listener)

Adds a listener that is called periodically while the ControllableTask executes.

Parameters
executor the executor to use to call the listener
Returns
  • this Task

public StorageTask<TResult> addOnProgressListener (OnProgressListener<? super TResult> listener)

Adds a listener that is called periodically while the ControllableTask executes.

Returns
  • this Task

public StorageTask<TResult> addOnProgressListener (Activity activity, OnProgressListener<? super TResult> listener)

Adds a listener that is called periodically while the ControllableTask executes.

Parameters
activity When the supplied Activity stops, this listener will automatically be removed.
Returns
  • this Task

public StorageTask<TResult> addOnSuccessListener (OnSuccessListener<? super TResult> listener)

Adds a listener that is called if the Task completes successfully. The listener will be called on the main application thread. If the task has already completed successfully, 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> addOnSuccessListener (Activity activity, OnSuccessListener<? super TResult> listener)

Adds a listener that is called if the Task completes successfully.

If multiple listeners are added, they will be called in the order in which they were added. If the task has already completed successfully, a call to the listener will be immediately scheduled.

Parameters
activity When the supplied Activity stops, this listener will automatically be removed.
Returns
  • this Task

public StorageTask<TResult> addOnSuccessListener (Executor executor, OnSuccessListener<? super TResult> listener)

Adds a listener that is called if the Task completes successfully.

If multiple listeners are added, they will be called in the order in which they were added. If the task has already completed successfully, a call to the listener will be immediately scheduled.

Parameters
executor the executor to use to call the listener
Returns
  • this Task

public boolean cancel ()

Attempts to cancel the task. A canceled task cannot be resumed later.

Returns
  • true if this task is successfully being canceled.

public 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.

The Continuation will be called on the main application thread.

See Also

public 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.

Parameters
executor the executor to use to call the Continuation
See Also

public 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.

Parameters
executor the executor to use to call the Continuation
See Also

public 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.

The Continuation will be called on the main application thread.

See Also

public Exception