public abstract class

StorageTask

extends ControllableTask<TResult extends StorageTask.ProvideError>
java.lang.Object
   ↳ com.google.android.gms.tasks.Task<TResult extends com.google.firebase.storage.StorageTask.ProvideError>
     ↳ com.google.firebase.storage.CancellableTask<TResult extends com.google.firebase.storage.StorageTask.ProvideError>
       ↳ com.google.firebase.storage.ControllableTask<TResult extends com.google.firebase.storage.StorageTask.ProvideError>
         ↳ com.google.firebase.storage.StorageTask<TResult extends com.google.firebase.storage.StorageTask.ProvideError>
Known Direct Subclasses

Class Overview

A controllable Task that has a synchronized state machine.

Summary

Nested Classes
interface StorageTask.ProvideError An object that returns an exception. 
class StorageTask.SnapshotBase Base class for state. 
Fields
protected final Object mSyncObject
Protected Constructors
StorageTask()
Public Methods
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 Methods
void onCanceled()
void onFailure()
void onPaused()
void onProgress()
void onQueued()
void onSuccess()
[Expand]
Inherited Methods
From class com.google.firebase.storage.ControllableTask
From class com.google.firebase.storage.CancellableTask
From class com.google.android.gms.tasks.Task
From class java.lang.Object

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.

Parameters
listener OnCompleteListener
Returns
StorageTask<TResult> 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 Activity: When the supplied Activity stops, this listener will automatically be removed.
listener OnCompleteListener
Returns
StorageTask<TResult> 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 Executor: the executor to use to call the listener
listener OnCompleteListener
Returns
StorageTask<TResult> 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 Activity: When the supplied Activity stops, this listener will automatically be removed.
listener OnFailureListener
Returns
StorageTask<TResult> 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.

Parameters
listener OnFailureListener
Returns
StorageTask<TResult> 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 Executor: the executor to use to call the listener
listener OnFailureListener
Returns
StorageTask<TResult> 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 Executor: the executor to use to call the listener
listener OnPausedListener
Returns
StorageTask<TResult> 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 Activity: When the supplied Activity stops, this listener will automatically be removed.
listener OnPausedListener
Returns
StorageTask<TResult> this Task

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

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

Parameters
listener OnPausedListener
Returns
StorageTask<TResult> 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 Executor: the executor to use to call the listener
listener OnProgressListener
Returns
StorageTask<TResult> this Task

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

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

Parameters
listener OnProgressListener
Returns
StorageTask<TResult> 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 Activity: When the supplied Activity stops, this listener will automatically be removed.
listener OnProgressListener
Returns
StorageTask<TResult> 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.

Parameters
listener OnSuccessListener
Returns
StorageTask<TResult> 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 Activity: When the supplied Activity stops, this listener will automatically be removed.
listener OnSuccessListener
Returns
StorageTask<TResult> 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 Executor: the executor to use to call the listener
listener OnSuccessListener
Returns
StorageTask<TResult> this Task

public boolean cancel ()

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

Returns
boolean 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.

Parameters
continuation Continuation
Returns
Task<TContinuationResult>

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 Executor: the executor to use to call the Continuation
continuation Continuation
Returns
Task<TContinuationResult>

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 Executor: the executor to use to call the Continuation
continuation Continuation
Returns
Task<TContinuationResult>

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.

Parameters
continuation Continuation
Returns
Task<TContinuationResult>

See also:

public Exception getException ()

Returns the exception that caused the Task to fail. Returns null if the Task is not yet complete, or completed successfully.

Returns
Exception

public TResult getResult ()

Gets the result of the Task, if it has already completed.

Returns
TResult
Throws
IllegalStateException if the Task is not yet complete
RuntimeExecutionException if the Task failed with an exception

public TResult getResult (Class<X> exceptionType)

Gets the result of the Task, if it has already completed.

Parameters
exceptionType Class
Returns
TResult
Throws
IllegalStateException if the Task is not yet complete
if the Task failed with an exception of type X
RuntimeExecutionException if the Task failed with an exception that was not of type X
Throwable

public TResult getSnapshot ()

Returns the current state of the task. This method will return state at any point of the tasks execution and may not be the final result..

Returns
TResult

public boolean isCanceled ()

Returns true if the task has been canceled.

Returns
boolean true if the task has been canceled.

public boolean isComplete ()

Returns true if the Task is complete; false otherwise.

Returns
boolean

public boolean isInProgress ()

Returns true if the task is currently running.

Returns
boolean true if the task is currently running.

public boolean isPaused ()

Returns true if the task has been paused.

Returns
boolean true if the task has been paused.

public boolean isSuccessful ()

Returns true if the Task has completed successfully; false otherwise.

Returns
boolean

public boolean pause ()

Attempts to pause the task. A paused task can later be resumed.

Returns
boolean true if this task is successfully being paused. Note that a task may not be immediately paused if it was executing another action and can still fail or complete.

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

Removes a listener.

Parameters
listener OnCompleteListener
Returns
StorageTask<TResult>

public StorageTask<TResult> removeOnFailureListener (OnFailureListener listener)

Removes a listener.

Parameters
listener OnFailureListener
Returns
StorageTask<TResult>

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

Removes a listener.

Parameters
listener OnPausedListener
Returns
StorageTask<TResult>

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

Removes a listener.

Parameters
listener OnProgressListener
Returns
StorageTask<TResult>

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

Removes a listener.

Parameters
listener OnSuccessListener
Returns
StorageTask<TResult>

public boolean resume ()

Attempts to resume a paused task.

Returns
boolean true if the task is successfully resumed. false if the task has an unrecoverable error or has entered another state that precludes resume.

Protected Methods

protected void onCanceled ()

protected void onFailure ()

protected void onPaused ()

protected void onProgress ()

protected void onQueued ()

protected void onSuccess ()