Java Code Examples for com.facebook.react.bridge.JavaOnlyMap#putDouble()

The following examples show how to use com.facebook.react.bridge.JavaOnlyMap#putDouble() . 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: StyleAnimatedNode.java    From react-native-GPay with MIT License 5 votes vote down vote up
public void collectViewUpdates(JavaOnlyMap propsMap) {
  for (Map.Entry<String, Integer> entry : mPropMapping.entrySet()) {
    @Nullable AnimatedNode node = mNativeAnimatedNodesManager.getNodeById(entry.getValue());
    if (node == null) {
      throw new IllegalArgumentException("Mapped style node does not exists");
    } else if (node instanceof TransformAnimatedNode) {
      ((TransformAnimatedNode) node).collectViewUpdates(propsMap);
    } else if (node instanceof ValueAnimatedNode) {
      propsMap.putDouble(entry.getKey(), ((ValueAnimatedNode) node).getValue());
    } else {
      throw new IllegalArgumentException("Unsupported type of node used in property node " +
        node.getClass());
    }
  }
}
 
Example 2
Source File: JSONParserTest.java    From react-native-navigation with MIT License 5 votes vote down vote up
@Test
public void parsesMap() throws Exception {
    JavaOnlyMap input = new JavaOnlyMap();
    input.putString("keyString", "stringValue");
    input.putInt("keyInt", 123);
    input.putDouble("keyDouble", 123.456);
    input.putBoolean("keyBoolean", true);
    input.putArray("keyArray", new JavaOnlyArray());
    input.putMap("keyMap", new JavaOnlyMap());
    input.putNull("bla");

    JSONObject result = new JSONParser().parse(input);


    assertThat(result.keys()).containsOnly(
            "keyString",
            "keyInt",
            "keyDouble",
            "keyBoolean",
            "keyMap",
            "keyArray");

    assertThat(result.get("keyString")).isEqualTo("stringValue");
    assertThat(result.get("keyInt")).isEqualTo(123);
    assertThat(result.get("keyDouble")).isEqualTo(123.456);
    assertThat(result.get("keyBoolean")).isEqualTo(true);
    assertThat(result.getJSONObject("keyMap").keys()).isEmpty();
    assertThat(result.getJSONArray("keyArray").length()).isZero();
}