public abstract class

CancelableOperation

extends Object
implements Cancelable Runnable
java.lang.Object
   ↳ com.urbanairship.CancelableOperation

Class Overview

A cancelable operation that executes its task on a specific looper.

Summary

Public Constructors
CancelableOperation()
CancelableOperation constructor.
CancelableOperation(Looper looper)
CancelableOperation constructor.
Public Methods
CancelableOperation addOnCancel(Cancelable cancelable)
Adds a Cancelable that will be called when operation is cancelled.
CancelableOperation addOnRun(Runnable runnable)
Adds a runnable that will be called when operation is finished.
final boolean cancel()
Cancels the operation.
final boolean cancel(boolean mayInterruptIfRunning)
Cancels the operation.
Handler getHandler()
Gets the handler for the operation.
final boolean isCancelled()
Determines if the operation is canceled.
final boolean isDone()
Determines if the operation is canceled or completed.
final void run()
Protected Methods
void onCancel()
Called on the handlers callback when the operation is canceled.
void onRun()
Called on the handlers callback when the operation is running.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.urbanairship.Cancelable
From interface java.lang.Runnable

Public Constructors

public CancelableOperation ()

CancelableOperation constructor.

public CancelableOperation (Looper looper)

CancelableOperation constructor.

Parameters
looper A Looper object whose message queue will be used for the callback, or null to make callbacks on the calling thread or main thread if the current thread does not have a looper associated with it.

Public Methods

public CancelableOperation addOnCancel (Cancelable cancelable)

Adds a Cancelable that will be called when operation is cancelled. If the operation is already canceled the operation will immediately be canceled.

Parameters
cancelable The instance that implements the Cancelable interface.

public CancelableOperation addOnRun (Runnable runnable)

Adds a runnable that will be called when operation is finished. If the operation is already finished the runnable will be called immediately.

Parameters
runnable A runnable.

public final boolean cancel ()

Cancels the operation.

Returns
  • false if the cancelable was able to be cancelled, otherwise true.

public final boolean cancel (boolean mayInterruptIfRunning)

Cancels the operation.

Parameters
mayInterruptIfRunning true if the thread executing this task should be interrupted; otherwise, in-progress tasks are allowed to complete.
Returns
  • false if the cancelable was able to be cancelled, otherwise true.

public Handler getHandler ()

Gets the handler for the operation.

Returns
  • The operation's handler.

public final boolean isCancelled ()

Determines if the operation is canceled.

Returns
  • true if canceled, otherwise false

public final boolean isDone ()

Determines if the operation is canceled or completed.

Returns
  • true if canceled or completed, otherwise false

public final void run ()

Protected Methods

protected void onCancel ()

Called on the handlers callback when the operation is canceled.

protected void onRun ()

Called on the handlers callback when the operation is running.