本文整理汇总了Java中com.facebook.react.bridge.WritableArray.pushMap方法的典型用法代码示例。如果您正苦于以下问题:Java WritableArray.pushMap方法的具体用法?Java WritableArray.pushMap怎么用?Java WritableArray.pushMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.react.bridge.WritableArray
的用法示例。
在下文中一共展示了WritableArray.pushMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
示例2: 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);
}
示例3: 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());
}
}
示例4: 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);
}
示例5: 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);
}
}
示例6: convertJsonToArray
import com.facebook.react.bridge.WritableArray; //导入方法依赖的package包/类
private static WritableArray convertJsonToArray(JSONArray jsonArray) throws JSONException {
WritableArray array = new WritableNativeArray();
for (int i = 0; i < jsonArray.length(); i++) {
Object value = jsonArray.get(i);
if (value instanceof JSONObject) {
array.pushMap(convertJsonToMap((JSONObject) value));
} else if (value instanceof JSONArray) {
array.pushArray(convertJsonToArray((JSONArray) value));
} else if (value instanceof Boolean) {
array.pushBoolean((Boolean) value);
} else if (value instanceof Integer) {
array.pushInt((Integer) value);
} else if (value instanceof Double) {
array.pushDouble((Double) value);
} else if (value instanceof String) {
array.pushString((String) value);
} else {
array.pushString(value.toString());
}
}
return array;
}
示例7: onResponseReceived
import com.facebook.react.bridge.WritableArray; //导入方法依赖的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);
}
示例8: getRangedRegions
import com.facebook.react.bridge.WritableArray; //导入方法依赖的package包/类
@ReactMethod
public void getRangedRegions(Callback callback) {
WritableArray array = new WritableNativeArray();
for (Region region: mBeaconManager.getRangedRegions()) {
WritableMap map = new WritableNativeMap();
map.putString("region", region.getUniqueId());
map.putString("uuid", region.getId1().toString());
array.pushMap(map);
}
callback.invoke(array);
}
示例9: transformQueryResults
import com.facebook.react.bridge.WritableArray; //导入方法依赖的package包/类
private ReadableArray transformQueryResults(Cursor cursor) {
WritableArray result = Arguments.createArray();
while(cursor.moveToNext()) {
WritableMap row = Arguments.createMap();
for (int i = 0; i < cursor.getColumnCount(); i++) {
row.putString(cursor.getColumnName(i), cursor.getString(i));
}
result.pushMap(row);
}
cursor.close();
return result;
}
示例10: 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 = DateFormat.getDateInstance();
DateFormat timeFormat = DateFormat.getTimeInstance();
Format formatter = new SimpleDateFormat("EEE");
WritableMap stepMap = Arguments.createMap();
for (DataPoint dp : dataSet.getDataPoints()) {
Log.i(TAG, "Data point:");
Log.i(TAG, "\tType: " + dp.getDataType().getName());
Log.i(TAG, "\tStart: " + dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)) + " " + timeFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
Log.i(TAG, "\tEnd: " + dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)) + " " + timeFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
String day = formatter.format(new Date(dp.getStartTime(TimeUnit.MILLISECONDS)));
Log.i(TAG, "Day: " + day);
for(Field field : dp.getDataType().getFields()) {
Log.i("History", "\tField: " + field.getName() +
" Value: " + dp.getValue(field));
stepMap.putString("day", day);
stepMap.putDouble("startDate", dp.getStartTime(TimeUnit.MILLISECONDS));
stepMap.putDouble("endDate", dp.getEndTime(TimeUnit.MILLISECONDS));
float basal = 0;
try {
basal = getBasalAVG(dp.getEndTime(TimeUnit.MILLISECONDS));
} catch (Exception e) {
e.printStackTrace();
}
stepMap.putDouble("calorie", dp.getValue(field).asFloat() - basal);
map.pushMap(stepMap);
}
}
}
示例11: didScan
import com.facebook.react.bridge.WritableArray; //导入方法依赖的package包/类
public void didScan(ScanSession scanSession) {
List<Barcode> newBarcodes = scanSession.getNewlyRecognizedCodes();
WritableArray newlyRecognizedCodes = Arguments.createArray();
for (Barcode barcode: newBarcodes) {
newlyRecognizedCodes.pushMap(ScanditBarcodeHelpers.barcodeToWritableMap(barcode));
}
WritableMap event = Arguments.createMap();
event.putArray(NEWLY_RECOGNIZED_CODES, newlyRecognizedCodes);
eventDispatcher.dispatchEvent(new DidScanEvent(picker.getId(), event));
}
示例12: Channels
import com.facebook.react.bridge.WritableArray; //导入方法依赖的package包/类
public static WritableArray Channels(ArrayList<Channel> channels) {
WritableArray array = Arguments.createArray();
for (Channel c : channels) {
array.pushMap(Channel(c));
}
return array;
}
示例13: putEdges
import com.facebook.react.bridge.WritableArray; //导入方法依赖的package包/类
private static void putEdges(
ContentResolver resolver,
Cursor photos,
WritableMap response,
int limit) {
WritableArray edges = new WritableNativeArray();
photos.moveToFirst();
int idIndex = photos.getColumnIndex(Images.Media._ID);
int mimeTypeIndex = photos.getColumnIndex(Images.Media.MIME_TYPE);
int groupNameIndex = photos.getColumnIndex(Images.Media.BUCKET_DISPLAY_NAME);
int dateTakenIndex = photos.getColumnIndex(Images.Media.DATE_TAKEN);
int widthIndex = IS_JELLY_BEAN_OR_LATER ? photos.getColumnIndex(Images.Media.WIDTH) : -1;
int heightIndex = IS_JELLY_BEAN_OR_LATER ? photos.getColumnIndex(Images.Media.HEIGHT) : -1;
int longitudeIndex = photos.getColumnIndex(Images.Media.LONGITUDE);
int latitudeIndex = photos.getColumnIndex(Images.Media.LATITUDE);
for (int i = 0; i < limit && !photos.isAfterLast(); i++) {
WritableMap edge = new WritableNativeMap();
WritableMap node = new WritableNativeMap();
boolean imageInfoSuccess =
putImageInfo(resolver, photos, node, idIndex, widthIndex, heightIndex);
if (imageInfoSuccess) {
putBasicNodeInfo(photos, node, mimeTypeIndex, groupNameIndex, dateTakenIndex);
putLocationInfo(photos, node, longitudeIndex, latitudeIndex);
edge.putMap("node", node);
edges.pushMap(edge);
} else {
// we skipped an image because we couldn't get its details (e.g. width/height), so we
// decrement i in order to correctly reach the limit, if the cursor has enough rows
i--;
}
photos.moveToNext();
}
response.putArray("edges", edges);
}
示例14: createsPointersArray
import com.facebook.react.bridge.WritableArray; //导入方法依赖的package包/类
/**
* Creates catalyst pointers array in format that is expected by RCTEventEmitter JS module from
* given {@param event} instance. This method use {@param reactTarget} parameter to set as a
* target view id associated with current gesture.
*/
private static WritableArray createsPointersArray(int reactTarget, TouchEvent event) {
WritableArray touches = Arguments.createArray();
MotionEvent motionEvent = event.getMotionEvent();
// Calculate the coordinates for the target view.
// The MotionEvent contains the X,Y of the touch in the coordinate space of the root view
// The TouchEvent contains the X,Y of the touch in the coordinate space of the target view
// Subtracting them allows us to get the coordinates of the target view's top left corner
// We then use this when computing the view specific touches below
// Since only one view is actually handling even multiple touches, the values are all relative
// to this one target view.
float targetViewCoordinateX = motionEvent.getX() - event.getViewX();
float targetViewCoordinateY = motionEvent.getY() - event.getViewY();
for (int index = 0; index < motionEvent.getPointerCount(); index++) {
WritableMap touch = Arguments.createMap();
// pageX,Y values are relative to the RootReactView
// the motionEvent already contains coordinates in that view
touch.putDouble(PAGE_X_KEY, PixelUtil.toDIPFromPixel(motionEvent.getX(index)));
touch.putDouble(PAGE_Y_KEY, PixelUtil.toDIPFromPixel(motionEvent.getY(index)));
// locationX,Y values are relative to the target view
// To compute the values for the view, we subtract that views location from the event X,Y
float locationX = motionEvent.getX(index) - targetViewCoordinateX;
float locationY = motionEvent.getY(index) - targetViewCoordinateY;
touch.putDouble(LOCATION_X_KEY, PixelUtil.toDIPFromPixel(locationX));
touch.putDouble(LOCATION_Y_KEY, PixelUtil.toDIPFromPixel(locationY));
touch.putInt(TARGET_KEY, reactTarget);
touch.putDouble(TIMESTAMP_KEY, event.getTimestampMs());
touch.putDouble(POINTER_IDENTIFIER_KEY, motionEvent.getPointerId(index));
touches.pushMap(touch);
}
return touches;
}
示例15: toWritableArray
import com.facebook.react.bridge.WritableArray; //导入方法依赖的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;
}