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


Java Promise.resolve方法代码示例

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


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

示例1: getAvailableVoices

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void getAvailableVoices(Promise promise) {
	if(notReady(promise)) return;

	try {
		WritableArray voicesList = Arguments.createArray();
		Voice[] array = tts.getVoices().toArray(new Voice[tts.getVoices().size()]);
		for(Voice voice: array) {
			WritableMap newVoice = returnMapForVoice(voice);
			voicesList.pushMap(newVoice);
		}

		promise.resolve(voicesList);
	} catch(Exception e) {
		promise.reject("not_found", "Unable to retrieve voices for getAvailableVoices()", e);
	}
}
 
开发者ID:echo8795,项目名称:react-native-android-text-to-speech,代码行数:18,代码来源:RNAndroidTextToSpeechModule.java

示例2: bond

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void bond(String pin, Promise promise) {
    if (debug) {
        Log.d(TAG, "bonding device");
    }

    try {
        if (currentBondingDevice == null) {
            throw new RuntimeException("no device to bond");
        }
        currentBondingDevice.setPin(pin.getBytes());
        currentBondingDevice.setPairingConfirmation(false);
        boolean result = currentBondingDevice.createBond();
        promise.resolve(result);
    } catch (Exception e) {
        promise.reject(e);
    }
}
 
开发者ID:eove,项目名称:RNRxBluetooth,代码行数:19,代码来源:RNRxBluetoothModule.java

示例3: getString

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void getString(Promise promise) {
  try {
    ClipboardManager clipboard = getClipboardService();
    ClipData clipData = clipboard.getPrimaryClip();
    if (clipData == null) {
      promise.resolve("");
    } else if (clipData.getItemCount() >= 1) {
      ClipData.Item firstItem = clipboard.getPrimaryClip().getItemAt(0);
      promise.resolve("" + firstItem.getText());
    } else {
      promise.resolve("");
    }
  } catch (Exception e) {
    promise.reject(e);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:ClipboardModule.java

示例4: setAttributes

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void setAttributes(ReadableMap attributes, final Promise promise) {
    RCTTwilioChatClient tmp = RCTTwilioChatClient.getInstance();
    JSONObject json = RCTConvert.readableMapToJson(attributes);

    StatusListener listener = new StatusListener() {
        @Override
        public void onError(ErrorInfo errorInfo) {
            super.onError(errorInfo);
            promise.reject("set-attributes-error", "Error occurred while attempting to setAttributes on user.");
        }

        @Override
        public void onSuccess() {
            promise.resolve(true);
        }
    };

    tmp.client.getMyUserInfo().setAttributes(json, listener);
}
 
开发者ID:ccm-innovation,项目名称:react-native-twilio-chat,代码行数:21,代码来源:RCTTwilioChatClient.java

示例5: close

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void close(String id, Promise promise) {
    try {
        Graph graph = graphs.get(id);
        graph.close();
        promise.resolve(true);
    } catch (Exception e) {
        promise.reject(e);
    }
}
 
开发者ID:reneweb,项目名称:react-native-tensorflow,代码行数:11,代码来源:RNTensorFlowGraphModule.java

示例6: startDiscovery

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void startDiscovery(Promise promise) {
    if (debug) {
        Log.d(TAG, "request discovery: start...");
    }
    boolean result = rxBluetooth.startDiscovery();
    if (result) {
        promise.resolve(null);
    } else {
        promise.reject(new RuntimeException("could not start discovery"));
    }
}
 
开发者ID:eove,项目名称:RNRxBluetooth,代码行数:13,代码来源:RNRxBluetoothModule.java

示例7: getCurrentConnectivity

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void getCurrentConnectivity(Promise promise) {
  if (mNoNetworkPermission) {
    promise.reject(ERROR_MISSING_PERMISSION, MISSING_PERMISSION_MESSAGE, null);
    return;
  }
  promise.resolve(createConnectivityEventMap());
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:9,代码来源:NetInfoModule.java

示例8: getBrightness

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void getBrightness(Promise promise) {
    try {
        int val = Settings.System.getInt(getReactApplicationContext().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
        promise.resolve(val * 1.0f / 255);
    } catch (Settings.SettingNotFoundException e) {
        e.printStackTrace();
        promise.reject("-1", "get brightness fail", e);
    }
}
 
开发者ID:c19354837,项目名称:react-native-system-setting,代码行数:11,代码来源:SystemSetting.java

示例9: importKey

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
/**
 * Stores the given encrypted JSON key into the key directory.
 *
 * @param key           JSON key
 * @param oldPassphrase Passphrase
 * @param newPassphrase New passphrase
 * @param promise       Promise
 * @return Return account object
 */
@ReactMethod
public void importKey(byte[] key, String oldPassphrase, String newPassphrase, Promise promise) {
    try {
        Account acc = GethHolder.getKeyStore().importKey(key, oldPassphrase, newPassphrase);
        promise.resolve(acc);
    } catch (Exception e) {
        promise.reject(IMPORT_KEY_ERROR, e);
    }
}
 
开发者ID:YsnKsy,项目名称:react-native-geth,代码行数:19,代码来源:RNGethModule.java

示例10: getDefaultLocale

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void getDefaultLocale(Promise promise) {
	if(notReady(promise)) return;
	
	try {
		Locale defaultLocale;

		if(Build.VERSION.SDK_INT >= 21)	
			defaultLocale = tts.getDefaultVoice().getLocale();
		else 
			defaultLocale = tts.getDefaultLanguage();

		WritableMap map = returnMapForLocale(defaultLocale);
		promise.resolve(map);
	} catch(Exception e) {
		promise.reject("error", "Unable to retrieve locale for getDefaultLocale()", e);
	}
}
 
开发者ID:echo8795,项目名称:react-native-android-text-to-speech,代码行数:19,代码来源:RNAndroidTextToSpeechModule.java

示例11: isLocationEnabled

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void isLocationEnabled(Promise promise) {
    if (lm != null) {
        promise.resolve(lm.isProviderEnabled(LocationManager.GPS_PROVIDER));
    } else {
        promise.reject("-1", "get location manager fail");
    }
}
 
开发者ID:c19354837,项目名称:react-native-system-setting,代码行数:9,代码来源:SystemSetting.java

示例12: transmit

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void transmit(Integer carrierFrequency, ReadableArray burstsPattern, Promise promise) {
    int[] pattern = new int[burstsPattern.size()];

    for (int i = 0; i < burstsPattern.size(); i++) {
        pattern[i] = burstsPattern.getInt(i);
    }

    try {
        manager.transmit(carrierFrequency, pattern);
        promise.resolve(true);
    } catch (Exception e) {
        promise.reject(e);
    }
}
 
开发者ID:danielr18,项目名称:react-native-ir-manager,代码行数:16,代码来源:RNIRManagerModule.java

示例13: areNotificationsEnabled

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void areNotificationsEnabled(Promise promise) {
  try {
    boolean isEnabled = NotificationManagerCompat.from(getReactApplicationContext()).areNotificationsEnabled();
    promise.resolve(isEnabled);
  } catch (Exception e) {
    promise.reject(e);
  }
}
 
开发者ID:dmbookpro,项目名称:react-native-os-settings-manager,代码行数:10,代码来源:RNOsSettingsManagerModule.java

示例14: set

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void set(String alias, String input, Promise promise) {
  try {
    setCipherText(alias, input);
    promise.resolve("stored ciphertext in app storage");
  } catch (Exception e) {
    e.printStackTrace();
    Log.e(Constants.TAG, "Exception: " + e.getMessage());
    promise.reject("{\"code\":9,\"api-level\":" + Build.VERSION.SDK_INT + ",\"message\":" + e.getMessage() + "}");
  }
}
 
开发者ID:pradeep1991singh,项目名称:react-native-secure-key-store,代码行数:12,代码来源:RNSecureKeyStoreModule.java

示例15: writeToFile

import com.facebook.react.bridge.Promise; //导入方法依赖的package包/类
@ReactMethod
public void writeToFile(String relativePath, String content, boolean isAppend, String storage, Promise promise) {
  try {
    writeToFile(relativePath, content, isAppend, Storage.valueOf(storage));
    promise.resolve(true);
  } catch (IOException e) {
    promise.reject("ERROR", e.getMessage());
  }
}
 
开发者ID:hnq90,项目名称:react-native-filesystem-v1,代码行数:10,代码来源:RNFileSystem.java


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