CancellableTask

abstract class CancellableTask<StateT> : Task

Known direct subclasses
ControllableTask

Represents an asynchronous operation that can be paused, resumed and canceled.

Known indirect subclasses
FileDownloadTask

A task that downloads bytes of a GCS blob to a specified File.

StorageTask

A controllable Task that has a synchronized state machine.

StreamDownloadTask

A task that downloads bytes of a GCS blob.

UploadTask

An controllable task that uploads and fires events for success, progress and failure.


Represents an asynchronous operation that can be canceled.

Parameters
<StateT>

the type of state this operation returns in events.

Summary

Public constructors

Public functions

abstract CancellableTask<StateT!>

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

abstract CancellableTask<StateT!>
addOnProgressListener(
    activity: Activity,
    listener: OnProgressListener<Any!>
)

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

abstract CancellableTask<StateT!>
addOnProgressListener(
    executor: Executor,
    listener: OnProgressListener<Any!>
)

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

abstract Boolean

Attempts to cancel the task.

abstract Boolean
abstract Boolean

Inherited functions

From com.google.android.gms.tasks.Task
Task<TResult!>!
Task<TResult!>!
abstract Task<TResult!>!
abstract Task<TResult!>!
Task<TContinuationResult!>!
<TContinuationResult> continueWith(
    p: Continuation<TResult!, TContinuationResult!>!
)
Task<TContinuationResult!>!
<TContinuationResult> continueWithTask(
    p: Continuation<TResult!, Task<TContinuationResult!>!>!
)
abstract Exception!
abstract TResult!
abstract Boolean
abstract Boolean
Task<TContinuationResult!>!
<TContinuationResult> onSuccessTask(
    p: SuccessContinuation<TResult!, TContinuationResult!>!
)

Public constructors

CancellableTask

CancellableTask()

Public functions

addOnProgressListener

abstract fun addOnProgressListener(listener: OnProgressListener<Any!>): CancellableTask<StateT!>

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

Returns
CancellableTask<StateT!>

this Task

addOnProgressListener

abstract fun addOnProgressListener(
    activity: Activity,
    listener: OnProgressListener<Any!>
): CancellableTask<StateT!>

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.

Returns
CancellableTask<StateT!>

this Task

addOnProgressListener

abstract fun addOnProgressListener(
    executor: Executor,
    listener: OnProgressListener<Any!>
): CancellableTask<StateT!>

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

Parameters
executor: Executor

the executor to use to call the listener

Returns
CancellableTask<StateT!>

this Task

cancel

abstract fun cancel(): Boolean

Attempts to cancel the task. A canceled task cannot be resumed later. A canceled task calls back on listeners subscribed to addOnFailureListener with an exception that indicates the task was canceled.

Returns
Boolean

true if this task was successfully canceled or is in the process of being canceled. Returns false if the task is already completed or in a state that cannot be canceled.

isCanceled

abstract fun isCanceled(): Boolean
Returns
Boolean

true if the task has been canceled.

isInProgress

abstract fun isInProgress(): Boolean
Returns
Boolean

true if the task is currently running.