LoadBundleTask

public class LoadBundleTask extends Task


Represents the task of loading a Firestore bundle. It provides progress of bundle loading, as well as task completion and error events.

Summary

Public methods

@NonNull Task<LoadBundleTaskProgress>

Adds a listener that is called if the Task is canceled.

@NonNull Task<LoadBundleTaskProgress>
addOnCanceledListener(
    @NonNull Activity activity,
    @NonNull OnCanceledListener onCanceledListener
)

Adds an Activity-scoped listener that is called if the Task is canceled.

@NonNull Task<LoadBundleTaskProgress>
addOnCanceledListener(
    @NonNull Executor executor,
    @NonNull OnCanceledListener onCanceledListener
)

Adds a listener that is called if the Task is canceled.

@NonNull Task<LoadBundleTaskProgress>

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

@NonNull Task<LoadBundleTaskProgress>

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

@NonNull Task<LoadBundleTaskProgress>

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

@NonNull Task<LoadBundleTaskProgress>

Adds a listener that is called if the Task fails.

@NonNull Task<LoadBundleTaskProgress>
addOnFailureListener(
    @NonNull Activity activity,
    @NonNull OnFailureListener onFailureListener
)

Adds a listener that is called if the Task fails.

@NonNull Task<LoadBundleTaskProgress>
addOnFailureListener(
    @NonNull Executor executor,
    @NonNull OnFailureListener onFailureListener
)

Adds a listener that is called if the Task fails.

@NonNull LoadBundleTask

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

@NonNull LoadBundleTask

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

@NonNull LoadBundleTask

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

@NonNull Task<LoadBundleTaskProgress>

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

@NonNull Task<LoadBundleTaskProgress>
addOnSuccessListener(
    @NonNull Activity activity,
    @NonNull OnSuccessListener<Object> onSuccessListener
)

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

@NonNull Task<LoadBundleTaskProgress>
addOnSuccessListener(
    @NonNull Executor executor,
    @NonNull OnSuccessListener<Object> onSuccessListener
)

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

@NonNull Task<TContinuationResult>
<TContinuationResult> continueWith(
    @NonNull Continuation<LoadBundleTaskProgress, TContinuationResult> continuation
)

Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.

@NonNull Task<TContinuationResult>
<TContinuationResult> continueWith(
    @NonNull Executor executor,
    @NonNull Continuation<LoadBundleTaskProgress, TContinuationResult> continuation
)

Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.

@NonNull Task<TContinuationResult>
<TContinuationResult> continueWithTask(
    @NonNull Continuation<LoadBundleTaskProgressTask<TContinuationResult>> continuation
)

Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.

@NonNull Task<TContinuationResult>
<TContinuationResult> continueWithTask(
    @NonNull Executor executor,
    @NonNull Continuation<LoadBundleTaskProgressTask<TContinuationResult>> continuation
)

Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.

@Nullable Exception

Returns the exception that caused the Task to fail.

@NonNull LoadBundleTaskProgress

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

@NonNull LoadBundleTaskProgress
<X extends Throwable> getResult(@NonNull Class<X> exceptionType)

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

boolean

Returns true if the task has been canceled.

boolean

Returns true if the Task is complete; false otherwise.

boolean

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

@NonNull Task<TContinuationResult>
<TContinuationResult> onSuccessTask(
    @NonNull SuccessContinuation<LoadBundleTaskProgress, TContinuationResult> successContinuation
)

Returns a new Task that will be completed with the result of applying the specified SuccessContinuation to this Task when this Task completes successfully.

@NonNull Task<TContinuationResult>
<TContinuationResult> onSuccessTask(
    @NonNull Executor executor,
    @NonNull SuccessContinuation<LoadBundleTaskProgress, TContinuationResult> successContinuation
)

Returns a new Task that will be completed with the result of applying the specified SuccessContinuation to this Task when this Task completes successfully.

Public methods

addOnCanceledListener

public @NonNull Task<LoadBundleTaskProgressaddOnCanceledListener(@NonNull OnCanceledListener onCanceledListener)

Adds a listener that is called if the Task is canceled.

The listener will be called on main application thread. If the Task has already been canceled, 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
@NonNull Task<LoadBundleTaskProgress>

this Task

addOnCanceledListener

public @NonNull Task<LoadBundleTaskProgressaddOnCanceledListener(
    @NonNull Activity activity,
    @NonNull OnCanceledListener onCanceledListener
)

Adds an Activity-scoped listener that is called if the Task is canceled.

The listener will be called on main application thread. If the task has already been canceled, 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.

The listener will be automatically removed during onStop.

Returns
@NonNull Task<LoadBundleTaskProgress>

this Task

addOnCanceledListener

public @NonNull Task<LoadBundleTaskProgressaddOnCanceledListener(
    @NonNull Executor executor,
    @NonNull OnCanceledListener onCanceledListener
)

Adds a listener that is called if the Task is canceled.

If the task has already been canceled, 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
@NonNull Executor executor

the executor to use to call the listener

Returns
@NonNull Task<LoadBundleTaskProgress>

this Task

addOnCompleteListener

public @NonNull Task<LoadBundleTaskProgressaddOnCompleteListener(
    @NonNull OnCompleteListener<LoadBundleTaskProgress> onCompleteListener
)

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
@NonNull Task<LoadBundleTaskProgress>

this Task

addOnCompleteListener

public @NonNull Task<LoadBundleTaskProgressaddOnCompleteListener(
    @NonNull Activity activity,
    @NonNull OnCompleteListener<LoadBundleTaskProgress> onCompleteListener
)

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
@NonNull Activity activity

When the supplied Activity stops, this listener will automatically be removed.

Returns
@NonNull Task<LoadBundleTaskProgress>

this Task

addOnCompleteListener

public @NonNull Task<LoadBundleTaskProgressaddOnCompleteListener(
    @NonNull Executor executor,
    @NonNull OnCompleteListener<LoadBundleTaskProgress> onCompleteListener
)

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
@NonNull Executor executor

the executor to use to call the listener

Returns
@NonNull Task<LoadBundleTaskProgress>

this Task

addOnFailureListener

public @NonNull Task<LoadBundleTaskProgressaddOnFailureListener(@NonNull OnFailureListener onFailureListener)

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
@NonNull Task<LoadBundleTaskProgress>

this Task

addOnFailureListener

public @NonNull Task<LoadBundleTaskProgressaddOnFailureListener(
    @NonNull Activity activity,
    @NonNull OnFailureListener onFailureListener
)

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
@NonNull Activity activity

When the supplied Activity stops, this listener will automatically be removed.

Returns
@NonNull Task<LoadBundleTaskProgress>

this Task

addOnFailureListener

public @NonNull Task<LoadBundleTaskProgressaddOnFailureListener(
    @NonNull Executor executor,
    @NonNull OnFailureListener onFailureListener
)

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
@NonNull Executor executor

the executor to use to call the listener

Returns
@NonNull Task<LoadBundleTaskProgress>

this Task

addOnProgressListener

public @NonNull LoadBundleTask addOnProgressListener(
    @NonNull OnProgressListener<LoadBundleTaskProgress> listener
)

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

The listener will be called on main application thread. If multiple listeners are added, they will be called in the order in which they were added.

The listener will be automatically removed during onStop.

Returns
@NonNull LoadBundleTask

this Task

addOnProgressListener

public @NonNull LoadBundleTask addOnProgressListener(
    @NonNull Activity activity,
    @NonNull OnProgressListener<LoadBundleTaskProgress> listener
)

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

The listener will be called on main application thread. If multiple listeners are added, they will be called in the order in which they were added.

The listener will be automatically removed during onStop.

Parameters
@NonNull Activity activity

When the supplied Activity stops, this listener will automatically be removed.

Returns
@NonNull LoadBundleTask

this Task

addOnProgressListener

public @NonNull LoadBundleTask addOnProgressListener(
    @NonNull Executor executor,
    @NonNull OnProgressListener<LoadBundleTaskProgress> listener
)

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

If multiple listeners are added, they will be called in the order in which they were added.

Parameters
@NonNull Executor executor

the executor to use to call the listener

Returns
@NonNull LoadBundleTask

this Task

addOnSuccessListener

public @NonNull Task<LoadBundleTaskProgressaddOnSuccessListener(
    @NonNull OnSuccessListener<Object> onSuccessListener
)

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
@NonNull Task<LoadBundleTaskProgress>

this Task

addOnSuccessListener

public @NonNull Task<LoadBundleTaskProgressaddOnSuccessListener(
    @NonNull Activity activity,
    @NonNull OnSuccessListener<Object> onSuccessListener
)

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
@NonNull Activity activity

When the supplied Activity stops, this listener will automatically be removed.

Returns
@NonNull Task<LoadBundleTaskProgress>

this Task

addOnSuccessListener

public @NonNull Task<LoadBundleTaskProgressaddOnSuccessListener(
    @NonNull Executor executor,
    @NonNull OnSuccessListener<Object> onSuccessListener
)

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
@NonNull Executor executor

the executor to use to call the listener

Returns
@NonNull Task<LoadBundleTaskProgress>

this Task

continueWith

public @NonNull Task<TContinuationResult> <TContinuationResult> continueWith(
    @NonNull Continuation<LoadBundleTaskProgress, 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
then

continueWith

public @NonNull Task<TContinuationResult> <TContinuationResult> continueWith(
    @NonNull Executor executor,
    @NonNull Continuation<LoadBundleTaskProgress, TContinuationResult> continuation
)

Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.

Parameters
@NonNull Executor executor

the executor to use to call the Continuation

See also
then

continueWithTask

public @NonNull Task<TContinuationResult> <TContinuationResult> continueWithTask(
    @NonNull Continuation<LoadBundleTaskProgressTask<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
then

continueWithTask

public @NonNull Task<TContinuationResult> <TContinuationResult> continueWithTask(
    @NonNull Executor executor,
    @NonNull Continuation<LoadBundleTaskProgressTask<TContinuationResult>> continuation
)

Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.

Parameters
@NonNull Executor executor

the executor to use to call the Continuation

See also
then

getException

public @Nullable Exception getException()

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

getResult

public @NonNull LoadBundleTaskProgress getResult()

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

Throws
java.lang.IllegalStateException java.lang.IllegalStateException

if the Task is not yet complete

com.google.android.gms.tasks.RuntimeExecutionException com.google.android.gms.tasks.RuntimeExecutionException

if the Task failed with an exception

getResult

public @NonNull LoadBundleTaskProgress <X extends Throwable> getResult(@NonNull Class<X> exceptionType)

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

Throws
java.lang.IllegalStateException java.lang.IllegalStateException

if the Task is not yet complete

X X

if the Task failed with an exception of type X

com.google.android.gms.tasks.RuntimeExecutionException com.google.android.gms.tasks.RuntimeExecutionException

if the Task failed with an exception that was not of type X

isCanceled

public boolean isCanceled()

Returns true if the task has been canceled.

isComplete

public boolean isComplete()

Returns true if the Task is complete; false otherwise.

isSuccessful

public boolean isSuccessful()

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

onSuccessTask

public @NonNull Task<TContinuationResult> <TContinuationResult> onSuccessTask(
    @NonNull SuccessContinuation<LoadBundleTaskProgress, TContinuationResult> successContinuation
)

Returns a new Task that will be completed with the result of applying the specified SuccessContinuation to this Task when this Task completes successfully. If the previous Task fails, the onSuccessTask completion will be skipped and failure listeners will be invoked.

The SuccessContinuation will be called on the main application thread.

If the previous Task is canceled, the returned Task will also be canceled and the SuccessContinuation would not execute.

onSuccessTask

public @NonNull Task<TContinuationResult> <TContinuationResult> onSuccessTask(
    @NonNull Executor executor,
    @NonNull SuccessContinuation<LoadBundleTaskProgress, TContinuationResult> successContinuation
)

Returns a new Task that will be completed with the result of applying the specified SuccessContinuation to this Task when this Task completes successfully. If the previous Task fails, the onSuccessTask completion will be skipped and failure listeners will be invoked.

If the previous Task is canceled, the returned Task will also be canceled and the SuccessContinuation would not execute.

Parameters
@NonNull Executor executor

the executor to use to call the SuccessContinuation