本文整理汇总了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.");
}