本文整理汇总了Java中com.facebook.react.bridge.Arguments.createArray方法的典型用法代码示例。如果您正苦于以下问题:Java Arguments.createArray方法的具体用法?Java Arguments.createArray怎么用?Java Arguments.createArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.react.bridge.Arguments
的用法示例。
在下文中一共展示了Arguments.createArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAvailableLocales
import com.facebook.react.bridge.Arguments; //导入方法依赖的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
示例2: jsonToReact
import com.facebook.react.bridge.Arguments; //导入方法依赖的package包/类
public static WritableArray jsonToReact(JSONArray jsonArray) throws JSONException {
WritableArray writableArray = Arguments.createArray();
for(int i=0; i < jsonArray.length(); i++) {
Object value = jsonArray.get(i);
if (value instanceof Float || value instanceof Double) {
writableArray.pushDouble(jsonArray.getDouble(i));
} else if (value instanceof Number) {
writableArray.pushInt(jsonArray.getInt(i));
} else if (value instanceof String) {
writableArray.pushString(jsonArray.getString(i));
} else if (value instanceof JSONObject) {
writableArray.pushMap(jsonToReact(jsonArray.getJSONObject(i)));
} else if (value instanceof JSONArray){
writableArray.pushArray(jsonToReact(jsonArray.getJSONArray(i)));
} else if (value == JSONObject.NULL){
writableArray.pushNull();
}
}
return writableArray;
}
示例3: getCarrierFrequencies
import com.facebook.react.bridge.Arguments; //导入方法依赖的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);
}
}
示例4: getIpAddress
import com.facebook.react.bridge.Arguments; //导入方法依赖的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);
}
示例5: getEnginesInfo
import com.facebook.react.bridge.Arguments; //导入方法依赖的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
示例6: onResponseReceived
import com.facebook.react.bridge.Arguments; //导入方法依赖的package包/类
private void onResponseReceived(int requestId, int code, WritableMap headers) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushInt(code);
args.pushMap(headers);
getEventEmitter().emit("didReceiveNetworkResponse", args);
}
示例7: removeSubviewsFromContainerWithID
import com.facebook.react.bridge.Arguments; //导入方法依赖的package包/类
/**
* Method which takes a container tag and then releases all subviews for that container upon
* receipt.
* TODO: The method name is incorrect and will be renamed, #6033872
* @param containerTag the tag of the container for which the subviews must be removed
*/
public void removeSubviewsFromContainerWithID(int containerTag) {
ReactShadowNode containerNode = mShadowNodeRegistry.getNode(containerTag);
if (containerNode == null) {
throw new IllegalViewOperationException(
"Trying to remove subviews of an unknown view tag: " + containerTag);
}
WritableArray indicesToRemove = Arguments.createArray();
for (int childIndex = 0; childIndex < containerNode.getChildCount(); childIndex++) {
indicesToRemove.pushInt(childIndex);
}
manageChildren(containerTag, null, null, null, null, indicesToRemove);
}
示例8: onDataReceivedProgress
import com.facebook.react.bridge.Arguments; //导入方法依赖的package包/类
public static void onDataReceivedProgress(
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("didReceiveNetworkDataProgress", args);
}
示例9: toWritableArray
import com.facebook.react.bridge.Arguments; //导入方法依赖的package包/类
public static WritableArray toWritableArray(Object[] array) {
WritableArray writableArray = Arguments.createArray();
for (int i = 0; i < array.length; i++) {
Object value = array[i];
if (value == null) {
writableArray.pushNull();
}
if (value instanceof Boolean) {
writableArray.pushBoolean((Boolean) value);
}
if (value instanceof Double) {
writableArray.pushDouble((Double) value);
}
if (value instanceof Integer) {
writableArray.pushInt((Integer) value);
}
if (value instanceof String) {
writableArray.pushString((String) value);
}
if (value instanceof Map) {
writableArray.pushMap(MapUtil.toWritableMap((Map<String, Object>) value));
}
if (value.getClass().isArray()) {
writableArray.pushArray(ArrayUtil.toWritableArray((Object[]) value));
}
}
return writableArray;
}
示例10: Channels
import com.facebook.react.bridge.Arguments; //导入方法依赖的package包/类
public static WritableArray Channels(ArrayList<Channel> channels) {
WritableArray array = Arguments.createArray();
for (Channel c : channels) {
array.pushMap(Channel(c));
}
return array;
}
示例11: replaceExistingNonRootView
import com.facebook.react.bridge.Arguments; //导入方法依赖的package包/类
/**
* Replaces the View specified by oldTag with the View specified by newTag within oldTag's parent.
*/
public void replaceExistingNonRootView(int oldTag, int newTag) {
if (mShadowNodeRegistry.isRootNode(oldTag) || mShadowNodeRegistry.isRootNode(newTag)) {
throw new IllegalViewOperationException("Trying to add or replace a root tag!");
}
ReactShadowNode oldNode = mShadowNodeRegistry.getNode(oldTag);
if (oldNode == null) {
throw new IllegalViewOperationException("Trying to replace unknown view tag: " + oldTag);
}
ReactShadowNode parent = oldNode.getParent();
if (parent == null) {
throw new IllegalViewOperationException("Node is not attached to a parent: " + oldTag);
}
int oldIndex = parent.indexOf(oldNode);
if (oldIndex < 0) {
throw new IllegalStateException("Didn't find child tag in parent");
}
WritableArray tagsToAdd = Arguments.createArray();
tagsToAdd.pushInt(newTag);
WritableArray addAtIndices = Arguments.createArray();
addAtIndices.pushInt(oldIndex);
WritableArray indicesToRemove = Arguments.createArray();
indicesToRemove.pushInt(oldIndex);
manageChildren(parent.getReactTag(), null, null, tagsToAdd, addAtIndices, indicesToRemove);
}
示例12: onResponseReceived
import com.facebook.react.bridge.Arguments; //导入方法依赖的package包/类
public static void onResponseReceived(
RCTDeviceEventEmitter eventEmitter,
int requestId,
int statusCode,
WritableMap headers,
String url) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushInt(statusCode);
args.pushMap(headers);
args.pushString(url);
eventEmitter.emit("didReceiveNetworkResponse", args);
}
示例13: sendTouchEvent
import com.facebook.react.bridge.Arguments; //导入方法依赖的package包/类
/**
* Generate and send touch event to RCTEventEmitter JS module associated with the given
* {@param context}. Touch event can encode multiple concurrent touches (pointers).
*
* @param rctEventEmitter Event emitter used to execute JS module call
* @param type type of the touch event (see {@link TouchEventType})
* @param reactTarget target view react id associated with this gesture
* @param touchEvent native touch event to read pointers count and coordinates from
*/
public static void sendTouchEvent(
RCTEventEmitter rctEventEmitter,
TouchEventType type,
int reactTarget,
TouchEvent touchEvent) {
WritableArray pointers = createsPointersArray(reactTarget, touchEvent);
MotionEvent motionEvent = touchEvent.getMotionEvent();
// For START and END events send only index of the pointer that is associated with that event
// For MOVE and CANCEL events 'changedIndices' array should contain all the pointers indices
WritableArray changedIndices = Arguments.createArray();
if (type == TouchEventType.MOVE || type == TouchEventType.CANCEL) {
for (int i = 0; i < motionEvent.getPointerCount(); i++) {
changedIndices.pushInt(i);
}
} else if (type == TouchEventType.START || type == TouchEventType.END) {
changedIndices.pushInt(motionEvent.getActionIndex());
} else {
throw new RuntimeException("Unknown touch type: " + type);
}
rctEventEmitter.receiveTouches(
type.getJSEventName(),
pointers,
changedIndices);
}
示例14: toWritableArray
import com.facebook.react.bridge.Arguments; //导入方法依赖的package包/类
public static WritableArray toWritableArray(Object[] array) {
WritableArray writableArray = Arguments.createArray();
for (int i = 0; i < array.length; i++) {
Object value = array[i];
if (value == null) {
writableArray.pushNull();
}
if (value instanceof Boolean) {
writableArray.pushBoolean((Boolean) value);
}
if (value instanceof Double) {
writableArray.pushDouble((Double) value);
}
if (value instanceof Integer) {
writableArray.pushInt((Integer) value);
}
if (value instanceof String) {
writableArray.pushString((String) value);
}
if (value instanceof Map) {
writableArray.pushMap(MapUtil.toWritableMap((Map<String, Object>) value));
}
if (value.getClass().isArray()) {
writableArray.pushArray(ArrayUtil.toWritableArray((Object[]) value));
}
}
return writableArray;
}
示例15: onIncrementalDataReceived
import com.facebook.react.bridge.Arguments; //导入方法依赖的package包/类
public static void onIncrementalDataReceived(
RCTDeviceEventEmitter eventEmitter,
int requestId,
String data,
long progress,
long total) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushString(data);
args.pushInt((int) progress);
args.pushInt((int) total);
eventEmitter.emit("didReceiveNetworkIncrementalData", args);
}