Java Code Examples for com.facebook.react.bridge.WritableNativeArray#pushArray()

The following examples show how to use com.facebook.react.bridge.WritableNativeArray#pushArray() . 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 vote down vote up
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: JSONEncoder.java    From react-native-google-fitness with MIT License 5 votes vote down vote up
public static WritableNativeArray convertDataSets(List<DataSet> dataSets) {
    WritableNativeArray jsonDataSets = new WritableNativeArray();
    for (DataSet dataSet : dataSets) {
        jsonDataSets.pushArray(convertDataSet(dataSet));
    }
    return jsonDataSets;
}
 
Example 3
Source File: CatalystNativeJavaToJSArgumentsTestCase.java    From react-native-GPay with MIT License 5 votes vote down vote up
public void testNestedArray() {
  WritableNativeArray level1 = new WritableNativeArray();
  WritableNativeArray level2 = new WritableNativeArray();
  WritableNativeArray level3 = new WritableNativeArray();
  level3.pushString("level3");
  level2.pushString("level2");
  level2.pushArray(level3);
  level1.pushString("level1");
  level1.pushArray(level2);

  mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveNestedArray(level1);
  waitForBridgeAndUIIdle();
  mAssertModule.verifyAssertsAndReset();
}
 
Example 4
Source File: CatalystNativeJavaToJSArgumentsTestCase.java    From react-native-GPay with MIT License 5 votes vote down vote up
public void testThrowWhenArrayReusedInArray() {
  boolean gotException = false;
  try {
    WritableNativeArray array1 = new WritableNativeArray();
    WritableNativeArray array2 = new WritableNativeArray();
    WritableNativeArray child = new WritableNativeArray();
    array1.pushArray(child);
    array2.pushArray(child);
  } catch (ObjectAlreadyConsumedException e) {
    gotException = true;
  }
  assertTrue(gotException);
}