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