Handles a batch ofPendingResult
items. Callbacks can be added and you can block to wait for all items in the batch to
complete like any otherPendingResult
item. A Batch can also be canceled if the results are no longer needed. In this case, the
onBatchComplete
callback will never be triggered.
The results can be taken either from the underlyingPendingResult
s
or via
BatchResult.take(BatchResultToken)
but not both.
Nested Class Summary
class | Batch.Builder | Builder forBatch
objects. |
Field Summary
protected finalWeakReference<GoogleApiClient> | mApiClient | This reference will never be null so long as the GoogleApiClient is connected. |
Public Method Summary
final R extendsResult |
await()
Blocks until the task is completed.
|
final R extendsResult | |
void |
cancel()
Requests that the batch be canceled.
|
void | |
BatchResult |
createFailedResult(Status
status)
Creates a result of type
<R> that represents a failure with
the specifiedStatus .
|
boolean |
isCanceled()
Indicates whether the pending result has been canceled either due to calling
GoogleApiClient.disconnect() or calling
cancel() directly on the pending result or an enclosing
Batch .
|
final void |
setResultCallback(ResultCallback<? super R extendsResult>
callback)
Set the callback here if you want the result to be delivered via a callback
when the result is ready.
|
final void |
setResultCallback(ResultCallback<? super R extendsResult>
callback, long time,TimeUnit
units)
Set the callback here if you want the result to be delivered via a callback
when the result is ready or has timed out waiting for the result.
|
Inherited Method Summary
Fields
protected finalWeakReference<GoogleApiClient> mApiClient
This reference will never be null so long as the GoogleApiClient is connected. It needs to be weak so that PendingResults don't pin disconnected GACs due to binder references to the PendingResults.
Public Methods
public final R extendsResult await()
Blocks until the task is completed. This is not allowed on the UI thread. The
returned result object can have an additional failure mode of
CommonStatusCodes.INTERRUPTED
.
public final R extendsResult await(long time, TimeUnit units)
Blocks until the task is completed or has timed out waiting for the result. This is
not allowed on the UI thread. The returned result object can have an additional failure
mode of either
CommonStatusCodes.INTERRUPTED
orCommonStatusCodes.TIMEOUT
.
public voidcancel()
Requests that the batch be canceled. Cancels all underlying
PendingResult
s.
ResultCallback.onResult(Result)
will never be called,await()
will return a failed result with statusCommonStatusCodes.CANCELED
.
public voidclearResultCallback()
publicBatchResult createFailedResult(Status status)
Creates a result of type<R>
that represents a failure with the
specifiedStatus
.
public booleanisCanceled()
Indicates whether the pending result has been canceled either due to calling
GoogleApiClient.disconnect()
or callingcancel()
directly on the pending result or an enclosingBatch
.
public final voidsetResultCallback(ResultCallback<? super R extendsResult> callback)
Set the callback here if you want the result to be delivered via a callback when the result is ready.
public final voidsetResultCallback(ResultCallback<? super R extendsResult> callback, long time,TimeUnit units)
Set the callback here if you want the result to be delivered via a callback when the
result is ready or has timed out waiting for the result. The returned result object can
have an additional failure mode ofCommonStatusCodes.TIMEOUT
.