本文整理汇总了Java中com.facebook.react.bridge.WritableArray类的典型用法代码示例。如果您正苦于以下问题:Java WritableArray类的具体用法?Java WritableArray怎么用?Java WritableArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WritableArray类属于com.facebook.react.bridge包,在下文中一共展示了WritableArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRangingResponse
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
private WritableMap createRangingResponse(Collection<Beacon> beacons, Region region) {
WritableMap map = new WritableNativeMap();
map.putString("identifier", region.getUniqueId());
map.putString("uuid", region.getId1() != null ? region.getId1().toString() : "");
WritableArray a = new WritableNativeArray();
for (Beacon beacon : beacons) {
WritableMap b = new WritableNativeMap();
b.putString("uuid", beacon.getId1().toString());
b.putInt("major", beacon.getId2().toInt());
b.putInt("minor", beacon.getId3().toInt());
b.putInt("rssi", beacon.getRssi());
b.putDouble("distance", beacon.getDistance());
b.putString("proximity", getProximity(beacon.getDistance()));
a.pushMap(b);
}
map.putArray("beacons", a);
return map;
}
示例2: getAvailableLocales
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
@ReactMethod
public void getAvailableLocales(Promise promise) {
if(notReady(promise)) return;
try {
WritableArray localeList = Arguments.createArray();
Locale[] localesArray = Locale.getAvailableLocales();
for(Locale locale: localesArray) {
int isAvailable = tts.isLanguageAvailable(locale);
if(isAvailable == TextToSpeech.LANG_COUNTRY_AVAILABLE) {
WritableMap newLocale = returnMapForLocale(locale);
localeList.pushMap(newLocale);
}
}
promise.resolve(localeList);
} catch(Exception e) {
promise.reject("error", "Unable to retrieve locales for getAvailableLocales()", e);
}
}
开发者ID:echo8795,项目名称:react-native-android-text-to-speech,代码行数:21,代码来源:RNAndroidTextToSpeechModule.java
示例3: getAvailableVoices
import com.facebook.react.bridge.WritableArray; //导入依赖的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
示例4: testStringWithMultibyteUTF8Characters
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
public void testStringWithMultibyteUTF8Characters() {
TestJavaToJSArgumentsModule jsModule = mInstance.getJSModule(TestJavaToJSArgumentsModule.class);
WritableNativeMap map = new WritableNativeMap();
map.putString("two-bytes", "\u00A2");
map.putString("three-bytes", "\u20AC");
map.putString("four-bytes", "\uD83D\uDE1C");
map.putString(
"mixed",
"\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107");
jsModule.receiveMapWithMultibyteUTF8CharacterString(map);
waitForBridgeAndUIIdle();
mAssertModule.verifyAssertsAndReset();
WritableArray array = new WritableNativeArray();
array.pushString("\u00A2");
array.pushString("\u20AC");
array.pushString("\uD83D\uDE1C");
array.pushString(
"\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107");
jsModule.receiveArrayWithMultibyteUTF8CharacterString(array);
waitForBridgeAndUIIdle();
mAssertModule.verifyAssertsAndReset();
}
示例5: mediaStreamTrackGetSources
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
@ReactMethod
public void mediaStreamTrackGetSources(Callback callback){
WritableArray array = Arguments.createArray();
String[] names = new String[Camera.getNumberOfCameras()];
for(int i = 0; i < Camera.getNumberOfCameras(); ++i) {
WritableMap info = getCameraInfo(i);
if (info != null) {
array.pushMap(info);
}
}
WritableMap audio = Arguments.createMap();
audio.putString("label", "Audio");
audio.putString("id", "audio-1");
audio.putString("facing", "");
audio.putString("kind", "audio");
array.pushMap(audio);
callback.invoke(array);
}
示例6: pushObject
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
public static void pushObject(WritableArray a, Object v) {
if (v == null) {
a.pushNull();
} else if (v instanceof String) {
a.pushString((String) v);
} else if (v instanceof Bundle) {
a.pushMap(fromBundle((Bundle) v));
} else if (v instanceof Byte) {
a.pushInt(((Byte) v) & 0xff);
} else if (v instanceof Integer) {
a.pushInt((Integer) v);
} else if (v instanceof Float) {
a.pushDouble((Float) v);
} else if (v instanceof Double) {
a.pushDouble((Double) v);
} else if (v instanceof Boolean) {
a.pushBoolean((Boolean) v);
} else {
throw new IllegalArgumentException("Unknown type " + v.getClass());
}
}
示例7: processDataSet
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
private void processDataSet(DataSet dataSet, WritableArray map) {
//Log.i(TAG, "Data returned for Data type: " + dataSet.getDataType().getName());
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
dateFormat.setTimeZone(TimeZone.getDefault());
WritableMap stepMap = Arguments.createMap();
for (DataPoint dp : dataSet.getDataPoints()) {
Log.i(TAG, "\tData point:");
Log.i(TAG, "\t\tType : " + dp.getDataType().getName());
Log.i(TAG, "\t\tStart: " + dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
Log.i(TAG, "\t\tEnd : " + dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));
for(Field field : dp.getDataType().getFields()) {
Log.i(TAG, "\t\tField: " + field.getName() +
" Value: " + dp.getValue(field));
stepMap.putDouble("startDate", dp.getStartTime(TimeUnit.MILLISECONDS));
stepMap.putDouble("endDate", dp.getEndTime(TimeUnit.MILLISECONDS));
stepMap.putDouble("steps", dp.getValue(field).asInt());
map.pushMap(stepMap);
}
}
}
示例8: processDataSet
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
private void processDataSet(DataSet dataSet, WritableArray map) {
//Log.i(TAG, "Data returned for Data type: " + dataSet.getDataType().getName());
Format formatter = new SimpleDateFormat("EEE");
WritableMap stepMap = Arguments.createMap();
for (DataPoint dp : dataSet.getDataPoints()) {
String day = formatter.format(new Date(dp.getStartTime(TimeUnit.MILLISECONDS)));
int i = 0;
for (Field field : dp.getDataType().getFields()) {
i++;
if (i > 1) continue; //Get only average instance
stepMap.putString("day", day);
stepMap.putDouble("startDate", dp.getStartTime(TimeUnit.MILLISECONDS));
stepMap.putDouble("endDate", dp.getEndTime(TimeUnit.MILLISECONDS));
stepMap.putDouble("value", dp.getValue(field).asFloat());
}
}
map.pushMap(stepMap);
}
示例9: getCarrierFrequencies
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
@ReactMethod
public void getCarrierFrequencies(Promise promise) {
try {
CarrierFrequencyRange[] carrierFrequencyRanges = manager.getCarrierFrequencies();
WritableArray carrierFrequencies = Arguments.createArray();
for (CarrierFrequencyRange carrierFrequencyRange : carrierFrequencyRanges) {
WritableMap carrierFrequency = Arguments.createMap();
carrierFrequency.putInt("minFrequency", carrierFrequencyRange.getMinFrequency());
carrierFrequency.putInt("maxFrequency", carrierFrequencyRange.getMaxFrequency());
carrierFrequencies.pushMap(carrierFrequency);
}
promise.resolve(carrierFrequencies);
} catch (Exception e) {
promise.reject(e);
}
}
示例10: getIpAddress
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
@ReactMethod
public void getIpAddress(Callback successCallback, Callback errorCallback) {
WritableArray ipList = Arguments.createArray();
try {
Enumeration<NetworkInterface> enumNetworkInterfaces = NetworkInterface.getNetworkInterfaces();
while (enumNetworkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = enumNetworkInterfaces.nextElement();
Enumeration<InetAddress> enumInetAddress = networkInterface.getInetAddresses();
while (enumInetAddress.hasMoreElements()) {
InetAddress inetAddress = enumInetAddress.nextElement();
if (inetAddress.isSiteLocalAddress()) {
ipList.pushString(inetAddress.getHostAddress());
}
}
}
} catch (SocketException e) {
Log.e(eTag, "getIpAddress SocketException", e);
errorCallback.invoke(e.getMessage());
}
successCallback.invoke(ipList);
}
示例11: addResponse
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
private void addResponse() {
final String key = "result";
Object value = getResponse();
if (value instanceof Boolean) promiseResponse.putBoolean(key, (Boolean)value);
else if (value instanceof String) promiseResponse.putString (key, (String)value);
else if (value instanceof Double) promiseResponse.putDouble (key, (Double)value);
else if (value instanceof Integer) promiseResponse.putInt (key, (Integer)value);
else if (value instanceof WritableMap) promiseResponse.putMap (key, (WritableMap) value);
else if (value instanceof WritableArray) promiseResponse.putArray (key, (WritableArray) value);
else if (value == null) promiseResponse.putNull(key);
if (promiseFailed) {
promiseResponse.putString("type", "reject");
} else {
promiseResponse.putString("type", "resolve");
}
}
示例12: getEnginesInfo
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
@ReactMethod
public void getEnginesInfo(Promise promise) {
if(notReady(promise)) return;
try {
WritableArray ttsInfo = Arguments.createArray();
List<TextToSpeech.EngineInfo> engineList = tts.getEngines();
Iterator iterator = engineList.iterator();
while(iterator.hasNext()) {
ttsInfo.pushString(iterator.next().toString());
}
promise.resolve(ttsInfo);
} catch(Exception e) {
promise.reject("error", "Unable to retrieve TTS Engine info for getEnginesInfo()", e);
}
}
开发者ID:echo8795,项目名称:react-native-android-text-to-speech,代码行数:19,代码来源:RNAndroidTextToSpeechModule.java
示例13: writeStaticNodesFile
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
protected void writeStaticNodesFile(String enodes) {
try {
File dir = new File(this.reactContext
.getFilesDir() + STATIC_NODES_FILES_PATH);
if (dir.exists() == false) dir.mkdirs();
File f = new File(dir, STATIC_NODES_FILES_NAME);
if (f.exists() == false) {
if (f.createNewFile() == true) {
WritableArray staticNodes = new WritableNativeArray();
staticNodes.pushString(enodes);
Writer output = new BufferedWriter(new FileWriter(f));
output.write(staticNodes.toString());
output.close();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例14: onReceive
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Logger.debug(TAG, "onReceive");
Bundle results = getResultExtras(true);
WritableMap data = Arguments.createMap();
if (results.containsKey(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE))
{
String languagePreference =
results.getString(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE);
data.putString("languagePreference", languagePreference);
}
if (results.containsKey(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES))
{
List<String> supportedLanguages =
results.getStringArrayList(
RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES);
WritableArray languages =
Arguments.fromArray(supportedLanguages.toArray(new String[0]));
data.putArray("supportedLanguages", languages);
}
emit(SUPPORTED_LOCALES, data);
}
示例15: onDataSend
import com.facebook.react.bridge.WritableArray; //导入依赖的package包/类
public static void onDataSend(
RCTDeviceEventEmitter eventEmitter,
int requestId,
long progress,
long total) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushInt((int) progress);
args.pushInt((int) total);
eventEmitter.emit("didSendNetworkData", args);
}