当前位置: 首页>>代码示例>>Java>>正文


Java RxBleCustomOperation类代码示例

本文整理汇总了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());
        }
    });
}
 
开发者ID:Polidea,项目名称:RxAndroidBle,代码行数:46,代码来源:RxBleConnectionImpl.java

示例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.");
}
 
开发者ID:Polidea,项目名称:RxAndroidBle,代码行数:5,代码来源:RxBleConnectionMock.java


注:本文中的com.polidea.rxandroidble.RxBleCustomOperation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。