Java Code Examples for com.facebook.react.bridge.WritableNativeMap.putString()

The following are Jave code examples for showing how to use putString() of the com.facebook.react.bridge.WritableNativeMap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: RNLearn_Project1   File: CatalystNativeJavaToJSArgumentsTestCase.java   Source Code and License Vote up 7 votes
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();
}
 
Example 2
Project: RNLearn_Project1   File: Arguments.java   Source Code and License Vote up 6 votes
private static void addEntry(WritableNativeMap nativeMap, String key, Object value) {
  value = makeNativeObject(value);
  if (value == null) {
    nativeMap.putNull(key);
  } else if (value instanceof Boolean) {
    nativeMap.putBoolean(key, (Boolean) value);
  } else if (value instanceof Integer) {
    nativeMap.putInt(key, (Integer) value);
  } else if (value instanceof Number) {
    nativeMap.putDouble(key, ((Number) value).doubleValue());
  } else if (value instanceof String) {
    nativeMap.putString(key, (String) value);
  } else if (value instanceof WritableNativeArray) {
    nativeMap.putArray(key, (WritableNativeArray) value);
  } else if (value instanceof WritableNativeMap) {
    nativeMap.putMap(key, (WritableNativeMap) value);
  } else {
    throw new IllegalArgumentException("Could not convert " + value.getClass());
  }
}
 
Example 3
Project: RNLearn_Project1   File: CatalystNativeJavaToJSArgumentsTestCase.java   Source Code and License Vote up 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 4
Project: RNLearn_Project1   File: Arguments.java   Source Code and License Vote up 6 votes
private static void addEntry(WritableNativeMap nativeMap, String key, Object value) {
  value = makeNativeObject(value);
  if (value == null) {
    nativeMap.putNull(key);
  } else if (value instanceof Boolean) {
    nativeMap.putBoolean(key, (Boolean) value);
  } else if (value instanceof Integer) {
    nativeMap.putInt(key, (Integer) value);
  } else if (value instanceof Number) {
    nativeMap.putDouble(key, ((Number) value).doubleValue());
  } else if (value instanceof String) {
    nativeMap.putString(key, (String) value);
  } else if (value instanceof WritableNativeArray) {
    nativeMap.putArray(key, (WritableNativeArray) value);
  } else if (value instanceof WritableNativeMap) {
    nativeMap.putMap(key, (WritableNativeMap) value);
  } else {
    throw new IllegalArgumentException("Could not convert " + value.getClass());
  }
}
 
Example 5
Project: RNLearn_Project1   File: CatalystNativeJavaToJSArgumentsTestCase.java   Source Code and License Vote up 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 6
Project: RNLearn_Project1   File: CatalystNativeJavaToJSArgumentsTestCase.java   Source Code and License Vote up 6 votes
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();
}
 
Example 7
Project: react-native-tensorflow   File: OutputConverter.java   Source Code and License Vote up 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 8
Project: RNLearn_Project1   File: CatalystNativeJavaToJSArgumentsTestCase.java   Source Code and License Vote up 5 votes
public void testArrayWithMaps() {
  WritableNativeMap m1 = new WritableNativeMap();
  WritableNativeMap m2 = new WritableNativeMap();
  m1.putString("m1k1", "m1v1");
  m1.putString("m1k2", "m1v2");
  m2.putString("m2k1", "m2v1");

  WritableNativeArray array = new WritableNativeArray();
  array.pushMap(m1);
  array.pushMap(m2);
  mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveArrayWithMaps(array);
  waitForBridgeAndUIIdle();
  mAssertModule.verifyAssertsAndReset();
}
 
Example 9
Project: RNLearn_Project1   File: CatalystNativeJavaToJSArgumentsTestCase.java   Source Code and License Vote up 5 votes
public void testMapWithBasicTypes() {
  WritableNativeMap map = new WritableNativeMap();
  map.putString("stringKey", "stringValue");
  map.putDouble("doubleKey", 3.14);
  map.putBoolean("booleanKey", true);
  map.putNull("nullKey");

  mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveMapWithBasicTypes(map);
  waitForBridgeAndUIIdle();
  mAssertModule.verifyAssertsAndReset();
}
 
Example 10
Project: RNLearn_Project1   File: CatalystNativeJavaToJSArgumentsTestCase.java   Source Code and License Vote up 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 11
Project: RNLearn_Project1   File: CatalystNativeJavaToJSArgumentsTestCase.java   Source Code and License Vote up 5 votes
public void testArrayWithMaps() {
  WritableNativeMap m1 = new WritableNativeMap();
  WritableNativeMap m2 = new WritableNativeMap();
  m1.putString("m1k1", "m1v1");
  m1.putString("m1k2", "m1v2");
  m2.putString("m2k1", "m2v1");

  WritableNativeArray array = new WritableNativeArray();
  array.pushMap(m1);
  array.pushMap(m2);
  mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveArrayWithMaps(array);
  waitForBridgeAndUIIdle();
  mAssertModule.verifyAssertsAndReset();
}
 
Example 12
Project: RNLearn_Project1   File: CatalystNativeJavaToJSArgumentsTestCase.java   Source Code and License Vote up 5 votes
public void testMapWithBasicTypes() {
  WritableNativeMap map = new WritableNativeMap();
  map.putString("stringKey", "stringValue");
  map.putDouble("doubleKey", 3.14);
  map.putBoolean("booleanKey", true);
  map.putNull("nullKey");

  mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveMapWithBasicTypes(map);
  waitForBridgeAndUIIdle();
  mAssertModule.verifyAssertsAndReset();
}
 
Example 13
Project: RNLearn_Project1   File: CatalystNativeJavaToJSArgumentsTestCase.java   Source Code and License Vote up 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();
}