Java Code Examples for com.facebook.react.bridge.WritableNativeMap#putMap()
The following examples show how to use
com.facebook.react.bridge.WritableNativeMap#putMap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CatalystNativeJavaToJSArgumentsTestCase.java From react-native-GPay with MIT License | 6 votes |
public void testMapWithNullStringValue() { WritableNativeMap map = new WritableNativeMap(); map.putString("string", null); map.putArray("array", null); map.putMap("map", null); WritableNativeArray array = new WritableNativeArray(); array.pushString(null); array.pushArray(null); array.pushMap(null); mInstance.getJSModule(TestJavaToJSArgumentsModule.class) .receiveMapAndArrayWithNullValues(map, array); waitForBridgeAndUIIdle(); mAssertModule.verifyAssertsAndReset(); }
Example 2
Source File: ReactRootView.java From react-native-GPay with MIT License | 5 votes |
/** * Calls into JS to start the React application. Can be called multiple times with the * same rootTag, which will re-render the application from the root. */ /* package */ void runApplication() { Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.runApplication"); try { if (mReactInstanceManager == null || !mIsAttachedToInstance) { return; } ReactContext reactContext = mReactInstanceManager.getCurrentReactContext(); if (reactContext == null) { return; } CatalystInstance catalystInstance = reactContext.getCatalystInstance(); WritableNativeMap appParams = new WritableNativeMap(); appParams.putDouble("rootTag", getRootViewTag()); @Nullable Bundle appProperties = getAppProperties(); if (appProperties != null) { appParams.putMap("initialProps", Arguments.fromBundle(appProperties)); } if (getUIManagerType() == FABRIC) { appParams.putBoolean("fabric", true); } mShouldLogContentAppeared = true; String jsAppModuleName = getJSModuleName(); catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams); } finally { Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); } }
Example 3
Source File: DisplayMetricsHolder.java From react-native-GPay with MIT License | 5 votes |
public static WritableNativeMap getDisplayMetricsNativeMap(double fontScale) { Assertions.assertNotNull( sWindowDisplayMetrics != null || sScreenDisplayMetrics != null, "DisplayMetricsHolder must be initialized with initDisplayMetricsIfNotInitialized or initDisplayMetrics"); final WritableNativeMap result = new WritableNativeMap(); result.putMap("windowPhysicalPixels", getPhysicalPixelsNativeMap(sWindowDisplayMetrics, fontScale)); result.putMap("screenPhysicalPixels", getPhysicalPixelsNativeMap(sScreenDisplayMetrics, fontScale)); return result; }
Example 4
Source File: CatalystNativeJavaToJSArgumentsTestCase.java From react-native-GPay with MIT License | 5 votes |
public void testNestedMap() { WritableNativeMap map = new WritableNativeMap(); WritableNativeMap nestedMap = new WritableNativeMap(); nestedMap.putString("animals", "foxes"); map.putMap("nestedMap", nestedMap); mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveNestedMap(map); waitForBridgeAndUIIdle(); mAssertModule.verifyAssertsAndReset(); }
Example 5
Source File: CatalystNativeJavaToJSArgumentsTestCase.java From react-native-GPay with MIT License | 5 votes |
public void testThrowWhenMapReusedInMap() { boolean gotException = false; try { WritableNativeMap map1 = new WritableNativeMap(); WritableNativeMap map2 = new WritableNativeMap(); WritableNativeMap child = new WritableNativeMap(); map1.putMap("child", child); map2.putMap("child", child); } catch (ObjectAlreadyConsumedException e) { gotException = true; } assertTrue(gotException); }
Example 6
Source File: OutputConverter.java From react-native-tensorflow with Apache License 2.0 | 5 votes |
public static WritableMap convert(Output output) { WritableNativeMap shapeMap = new WritableNativeMap(); shapeMap.putInt("numDimensions", output.shape().numDimensions()); WritableNativeMap map = new WritableNativeMap(); map.putInt("index", output.index()); map.putString("dataType", output.dataType().name()); map.putMap("shape", shapeMap); return map; }
Example 7
Source File: ReactOrientationControllerModule.java From react-native-orientation-controller with MIT License | 5 votes |
public WritableNativeMap getDataMap(){ WritableNativeMap data = new WritableNativeMap(); data.putString("deviceOrientation",getDeviceOrientationAsString()); data.putString("applicationOrientation", getApplicationOrientation()); data.putString("device", getModel()); final int width = getDimension()[0]; final int height = getDimension()[1]; data.putMap("size",new WritableNativeMap(){{putInt("width",width);putInt("height",height);}}); return data; }
Example 8
Source File: QimRNBModule.java From imsdk-android with MIT License | 4 votes |
/** * 查询用户的行车根据 整月查询 * * @param params * @param callback */ @ReactMethod public void selectUserTripByDate(ReadableMap params, Callback callback) { String date = params.getString("showDate"); List<CalendarTrip.DataBean.TripsBean> list = IMDatabaseManager.getInstance().SelectTripByYearMonth(date); Collections.sort(list, new Comparator<CalendarTrip.DataBean.TripsBean>() { @Override public int compare(CalendarTrip.DataBean.TripsBean lhs, CalendarTrip.DataBean.TripsBean rhs) { try { if (DateUtil.string2Time(lhs.getBeginTime()).getTime() > DateUtil.string2Time(rhs.getBeginTime()).getTime()) { return 1; } if (DateUtil.string2Time(lhs.getBeginTime()).getTime() < DateUtil.string2Time(rhs.getBeginTime()).getTime()) { return -1; } } catch (Exception e) { e.printStackTrace(); } return 0; } }); WritableNativeMap map = new WritableNativeMap(); WritableNativeMap dataMap = new WritableNativeMap(); WritableNativeMap.setUseNativeAccessor(true); WritableNativeArray.setUseNativeAccessor(true); Map<String, List<WritableNativeMap>> localMap = new HashMap<>(); // map.putBoolean("ok", true); for (int i = 0; i < list.size(); i++) { CalendarTrip.DataBean.TripsBean bean = list.get(i); if (!localMap.containsKey(bean.getTripDate())) { // WritableNativeArray newArray = new WritableNativeArray(); List<WritableNativeMap> newArray = new ArrayList<>(); newArray.add(getRNDataByTrip(bean)); localMap.put(bean.getTripDate(), newArray); } else { List<WritableNativeMap> lastArray = localMap.get(bean.getTripDate()); lastArray.add(getRNDataByTrip(bean)); localMap.put(bean.getTripDate(), lastArray); } } for (Map.Entry<String, List<WritableNativeMap>> entry : localMap.entrySet()) { WritableNativeArray array = new WritableNativeArray(); for (int i = 0; i < entry.getValue().size(); i++) { array.pushMap(entry.getValue().get(i)); } dataMap.putArray(entry.getKey(), array); } map.putBoolean("ok", true); map.putMap("data", dataMap); callback.invoke(map); }