Batch

public final classBatchextendsPendingResult

Handles a batch ofPendingResultitems. Callbacks can be added and you can block to wait for all items in the batch to complete like any otherPendingResultitem. A Batch can also be canceled if the results are no longer needed. In this case, theonBatchCompletecallback will never be triggered.

The results can be taken either from the underlyingPendingResults or viatakebut not both.

Summary

Nested types

public final classBatch.Builder

Builder forBatchobjects.

Protected fields

finalWeakReference<GoogleApiClient>

This reference will never be null so long as the GoogleApiClient is connected.

Public methods

final R

Blocks until the task is completed.

final R
await(long time,TimeUnitunits)

Blocks until the task is completed or has timed out waiting for the result.

void

Requests that the batch be canceled.

void
boolean

Indicates whether the pending result has been canceled either due to callingdisconnector callingcanceldirectly on the pending result or an enclosingBatch.

final void

Set the callback here if you want the result to be delivered via a callback when the result is ready.

final void

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 methods

Fromcom.google.android.gms mon.api.PendingResult
abstract @NonNullR
await(long time, @NonNullTimeUnitunits)

Blocks until the task is completed or has timed out waiting for the result.

abstract void

Set the callback here if you want the result to be delivered via a callback when the result is ready.

abstract void

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.

@NonNullTransformedResult<S>
<S extendsResult>then(@NonNullResultTransform<Object,S> transform)

Transforms the result by making another API call.

Protected fields

mApiClient

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

await

public final Rawait()

Blocks until the task is completed. This is not allowed on the UI thread. The returned result object can have an additional failure mode ofINTERRUPTED.

await

public final Rawait(long time,TimeUnitunits)

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 eitherINTERRUPTEDorTIMEOUT.

cancel

public voidcancel()

Requests that the batch be canceled. Cancels all underlyingPendingResults.

onResultwill never be called,awaitwill return a failed result with statusCANCELED.

clearResultCallback

public voidclearResultCallback()

isCanceled

public booleanisCanceled()

Indicates whether the pending result has been canceled either due to callingdisconnector callingcanceldirectly on the pending result or an enclosingBatch.

setResultCallback

public final voidsetResultCallback(@NullableResultCallback<Object> callback)

Set the callback here if you want the result to be delivered via a callback when the result is ready.

setResultCallback

public final voidsetResultCallback(
ResultCallback<Object> callback,
long time,
TimeUnitunits
)

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 ofTIMEOUT.