public class RequestQueue extends Request
handler, requestHandler| Modifier and Type | Method and Description |
|---|---|
RequestQueue |
add(Operation operation)
Enqueues a new operation.
|
void |
await()
Synchronously waits until all enqueued requests are done.
|
RequestQueue |
before(BeforeCallback callback)
Sets a callback that will be executed before the execution of this operation starts.
|
void |
cancelQueue()
Cancels all the enqueued operations that were not executed yet.
|
RequestQueue |
done(SuccessCallback callback)
Use to set a completion callback.
|
RequestQueue |
fail(FailCallback callback)
Use to set a callback that will be called in case the request has failed.
|
RequestQueue |
invalid(InvalidRequestCallback callback)
Use to set a callback that will be called in case the request was invalid, for example
called before the device was connected.
|
boolean |
isEmpty()
Returns whether the set is empty, or not.
|
RequestQueue |
setHandler(android.os.Handler handler)
Sets the handler that will be used to invoke callbacks.
|
int |
size()
Returns number of enqueued operations.
|
createBond, enqueue, newConnectionPriorityRequest, newDisableBatteryLevelNotificationsRequest, newDisableIndicationsRequest, newDisableNotificationsRequest, newEnableBatteryLevelNotificationsRequest, newEnableIndicationsRequest, newEnableNotificationsRequest, newMtuRequest, newReadBatteryLevelRequest, newReadPhyRequest, newReadRequest, newReadRequest, newReadRssiRequest, newRefreshCacheRequest, newSetPreferredPhyRequest, newSleepRequest, newWaitForIndicationRequest, newWaitForNotificationRequest, newWriteRequest, newWriteRequest, newWriteRequest, newWriteRequest, newWriteRequest, newWriteRequest, removeBond@NonNull public RequestQueue setHandler(@NonNull android.os.Handler handler)
RequestBleManager will be used.setHandler in class Requesthandler - The handler to invoke callbacks for this request.@NonNull public RequestQueue done(@NonNull SuccessCallback callback)
Request@NonNull public RequestQueue fail(@NonNull FailCallback callback)
RequestBleManager.connect(BluetoothDevice) was never called), the
Request.invalid(InvalidRequestCallback) will be used instead, as the
BluetoothDevice is not known.
This callback will be ignored if request was executed synchronously, in which case the error will be returned as an exception.
@NonNull public RequestQueue invalid(@NonNull InvalidRequestCallback callback)
Request@NonNull public RequestQueue before(@NonNull BeforeCallback callback)
Request@NonNull public RequestQueue add(@NonNull Operation operation)
operation - the new operation to be enqueued.java.lang.IllegalStateException - if the operation was enqueued before.java.lang.IllegalArgumentException - if the operation is not a Request.public int size()
public boolean isEmpty()
public void cancelQueue()
It is safe to call this method in Request.done(SuccessCallback) or
Request.fail(FailCallback) callback;
public final void await()
throws RequestFailedException,
DeviceDisconnectedException,
BluetoothDisabledException,
InvalidRequestException,
java.lang.InterruptedException
Callbacks set using before(BeforeCallback), done(SuccessCallback) and
fail(FailCallback) will be ignored.
This method may not be called from the main (UI) thread.
RequestFailedException - thrown when the BLE request finished with status other
than BluetoothGatt.GATT_SUCCESS.java.lang.IllegalStateException - thrown when you try to call this method from the main
(UI) thread.DeviceDisconnectedException - thrown when the device disconnected before the request
was completed.BluetoothDisabledException - thrown when the Bluetooth adapter has been disabled.InvalidRequestException - thrown when the request was called before the device was
connected at least once (unknown device).java.lang.InterruptedException - thrown when one of the request has failed with a timeout.