當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。