本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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"));
}
}
示例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());
}
示例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);
}
}
示例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);
}
}
示例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");
}
}
示例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);
}
}
示例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);
}
}
示例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() + "}");
}
}
示例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());
}
}