本文整理匯總了Java中com.polidea.rxandroidble.RxBleCustomOperation類的典型用法代碼示例。如果您正苦於以下問題:Java RxBleCustomOperation類的具體用法?Java RxBleCustomOperation怎麽用?Java RxBleCustomOperation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RxBleCustomOperation類屬於com.polidea.rxandroidble包,在下文中一共展示了RxBleCustomOperation類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: queue
import com.polidea.rxandroidble.RxBleCustomOperation; //導入依賴的package包/類
@Override
public <T> Observable<T> queue(@NonNull final RxBleCustomOperation<T> operation) {
return operationQueue.queue(new QueueOperation<T>() {
@Override
@SuppressWarnings("ConstantConditions")
protected void protectedRun(final Emitter<T> emitter, final QueueReleaseInterface queueReleaseInterface) throws Throwable {
final Observable<T> operationObservable;
try {
operationObservable = operation.asObservable(bluetoothGatt, gattCallback, callbackScheduler);
} catch (Throwable throwable) {
queueReleaseInterface.release();
throw throwable;
}
if (operationObservable == null) {
queueReleaseInterface.release();
throw new IllegalArgumentException("The custom operation asObservable method must return a non-null observable");
}
final QueueReleasingEmitterWrapper<T> emitterWrapper = new QueueReleasingEmitterWrapper<>(emitter, queueReleaseInterface);
operationObservable
.doOnTerminate(clearNativeCallbackReferenceAction())
.subscribe(emitterWrapper);
}
/**
* The Native Callback abstractions is intended to be used only in a custom operation, therefore, to make sure
* that we won't leak any references it's a good idea to clean it.
*/
private Action0 clearNativeCallbackReferenceAction() {
return new Action0() {
@Override
public void call() {
gattCallback.setNativeCallback(null);
}
};
}
@Override
protected BleException provideException(DeadObjectException deadObjectException) {
return new BleDisconnectedException(deadObjectException, bluetoothGatt.getDevice().getAddress());
}
});
}
示例2: queue
import com.polidea.rxandroidble.RxBleCustomOperation; //導入依賴的package包/類
@Override
public <T> Observable<T> queue(@NonNull RxBleCustomOperation<T> operation) {
throw new UnsupportedOperationException("Mock does not support queuing custom operation.");
}