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


Java DeferredObject.promise方法代码示例

本文整理汇总了Java中org.jdeferred.impl.DeferredObject.promise方法的典型用法代码示例。如果您正苦于以下问题:Java DeferredObject.promise方法的具体用法?Java DeferredObject.promise怎么用?Java DeferredObject.promise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jdeferred.impl.DeferredObject的用法示例。


在下文中一共展示了DeferredObject.promise方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: push

import org.jdeferred.impl.DeferredObject; //导入方法依赖的package包/类
/**
 * Push the thread to firebase.
 **/
public Promise<BThread, BError, Void> push(){

    if (DEBUG) Timber.v("push");
    
    final DeferredObject<BThread, BError, Void> deferred = new DeferredObject<>();
    
    DatabaseReference ref = null;
    if (StringUtils.isNotEmpty(model.getEntityID()))
    {
        ref = FirebasePaths.threadRef(model.getEntityID());
    }
    else
    {
        // Creating a new entry for this thread.
        ref = FirebasePaths.threadRef().push();
        model.setEntityID(ref.getKey());
        
        // Updating the database.
        DaoCore.updateEntity(model);
    }
    
    
    ref.updateChildren(serialize(), new DatabaseReference.CompletionListener() {
        @Override
        public void onComplete(DatabaseError firebaseError, DatabaseReference firebase) {
            if (firebaseError != null)
            {
                deferred.reject(getFirebaseError(firebaseError));
            }
            else deferred.resolve(model);
        }
    });
    
    return deferred.promise();
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:39,代码来源:BThreadWrapper.java

示例2: readCharacteristic

import org.jdeferred.impl.DeferredObject; //导入方法依赖的package包/类
public Promise<BluetoothGattCharacteristic, Integer, Void> readCharacteristic(BluetoothGattCharacteristic characteristic) {
    checkConnected();
    // If there's already a request in flight, return the current promise for results.
    DeferredObject<BluetoothGattCharacteristic, Integer, Void> deferred = readCharacteristic.get(new CharacteristicKey(characteristic));
    if (deferred != null && deferred.isPending()) {
        return deferred.promise();
    }
    // Read descriptor and return a promise for the results.
    deferred = new DeferredObject<BluetoothGattCharacteristic, Integer, Void>();
    if (!gatt.readCharacteristic(characteristic)) {
        deferred.reject(null);
    }
    readCharacteristic.put(new CharacteristicKey(characteristic), deferred);
    return deferred.promise();
}
 
开发者ID:tdicola,项目名称:BetterBluetoothLE,代码行数:16,代码来源:AsyncBluetoothGatt.java

示例3: writeCharacteristic

import org.jdeferred.impl.DeferredObject; //导入方法依赖的package包/类
public Promise<BluetoothGattCharacteristic, Integer, Void> writeCharacteristic(BluetoothGattCharacteristic characteristic) {
    checkConnected();
    // If there's already a request in flight, return the current promise for results.
    DeferredObject<BluetoothGattCharacteristic, Integer, Void> deferred = writeCharacteristic.get(new CharacteristicKey(characteristic));
    if (deferred != null && deferred.isPending()) {
        return deferred.promise();
    }
    // Read descriptor and return a promise for the results.
    deferred = new DeferredObject<BluetoothGattCharacteristic, Integer, Void>();
    if (!gatt.writeCharacteristic(characteristic)) {
        deferred.reject(null);
    }
    writeCharacteristic.put(new CharacteristicKey(characteristic), deferred);
    return deferred.promise();
}
 
开发者ID:tdicola,项目名称:BetterBluetoothLE,代码行数:16,代码来源:AsyncBluetoothGatt.java

示例4: readDescriptor

import org.jdeferred.impl.DeferredObject; //导入方法依赖的package包/类
public Promise<BluetoothGattDescriptor, Integer, Void> readDescriptor(BluetoothGattDescriptor descriptor) {
    checkConnected();
    // If there's already a request in flight, return the current promise for results.
    DeferredObject<BluetoothGattDescriptor, Integer, Void> deferred = readDescriptor.get(new DescriptorKey(descriptor));
    if (deferred != null && deferred.isPending()) {
        return deferred.promise();
    }
    // Read descriptor and return a promise for the results.
    deferred = new DeferredObject<BluetoothGattDescriptor, Integer, Void>();
    if (!gatt.readDescriptor(descriptor)) {
        deferred.reject(null);
    }
    readDescriptor.put(new DescriptorKey(descriptor), deferred);
    return deferred.promise();
}
 
开发者ID:tdicola,项目名称:BetterBluetoothLE,代码行数:16,代码来源:AsyncBluetoothGatt.java

示例5: writeDescriptor

import org.jdeferred.impl.DeferredObject; //导入方法依赖的package包/类
public Promise<BluetoothGattDescriptor, Integer, Void> writeDescriptor(BluetoothGattDescriptor descriptor) {
    checkConnected();
    // If there's already a request in flight, return the current promise for results.
    DeferredObject<BluetoothGattDescriptor, Integer, Void> deferred = writeDescriptor.get(new DescriptorKey(descriptor));
    if (deferred != null && deferred.isPending()) {
        return deferred.promise();
    }
    // Write descriptor and return a promise for the results.
    deferred = new DeferredObject<BluetoothGattDescriptor, Integer, Void>();
    if (!gatt.writeDescriptor(descriptor)) {
        deferred.reject(null);
    }
    writeDescriptor.put(new DescriptorKey(descriptor), deferred);
    return deferred.promise();
}
 
开发者ID:tdicola,项目名称:BetterBluetoothLE,代码行数:16,代码来源:AsyncBluetoothGatt.java

示例6: setCharacteristicNotification

import org.jdeferred.impl.DeferredObject; //导入方法依赖的package包/类
public Promise<Void, Void, BluetoothGattCharacteristic> setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enable) {
    checkConnected();
    DeferredObject<Void, Void, BluetoothGattCharacteristic> deferred = changeCharacteristic.get(new CharacteristicKey(characteristic));
    // Handle when enable has already been called.
    if (enable && deferred != null && deferred.isPending()) {
        // Return the in progress deferred.
        return deferred.promise();
    }
    // Handle disable for an already established notification.
    else if (!enable && deferred != null) {
        // Finish the current deferred.
        deferred.resolve(null);
        changeCharacteristic.remove(new CharacteristicKey(characteristic));
        // Disable notifications.
        deferred = new DeferredObject<Void, Void, BluetoothGattCharacteristic>();
        if (!gatt.setCharacteristicNotification(characteristic, false)) {
            deferred.reject(null);
        }
        else {
            deferred.resolve(null);
        }
        // Return a deferred to give success/failure of the disable.
        // This deferred is immediately resolved or rejected because there is no async indication
        // of the setCharacteristicNotification finishing (only progress updates).
        return deferred.promise();
    }
    // Handle enabling notifications.
    else if (enable) {
        // Setup and return the deferred for receiving progress of notification changes.
        deferred = new DeferredObject<Void, Void, BluetoothGattCharacteristic>();
        if (!gatt.setCharacteristicNotification(characteristic, true)) {
            deferred.reject(null);
        }
        changeCharacteristic.put(new CharacteristicKey(characteristic), deferred);
        return deferred.promise();
    }
    // Ignore disabling a notification that isn't enabled.
    else {
        // Return a successfull result immediately.
        deferred = new DeferredObject<Void, Void, BluetoothGattCharacteristic>();
        deferred.resolve(null);
        return deferred.promise();
    }
}
 
开发者ID:tdicola,项目名称:BetterBluetoothLE,代码行数:45,代码来源:AsyncBluetoothGatt.java


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