public final class CancellationSignal
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
CancellationSignal.OnCancelListener
Listens for cancellation.
|
| Constructor and Description |
|---|
CancellationSignal()
Creates a cancellation signal, initially not canceled.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancels the operation and signals the cancellation listener.
|
boolean |
isCanceled()
Returns true if the operation has been canceled.
|
void |
setOnCancelListener(CancellationSignal.OnCancelListener listener)
Sets the cancellation listener to be called when canceled.
|
void |
throwIfCanceled()
Throws
OperationCanceledException if the operation has been canceled. |
public CancellationSignal()
public boolean isCanceled()
public void throwIfCanceled()
OperationCanceledException if the operation has been canceled.OperationCanceledException - if the operation has been canceled.public void cancel()
public void setOnCancelListener(CancellationSignal.OnCancelListener listener)
cancel() has already been called, then the provided
listener is invoked immediately.
This method is guaranteed that the listener will not be called after it
has been removed.listener - The cancellation listener, or null to remove the current listener.