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

The following are Jave code examples for showing how to use putDouble() 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: ReactInstanceManager.java   Source Code and License Vote up 6 votes
private void attachMeasuredRootViewToInstance(
    ReactRootView rootView,
    CatalystInstance catalystInstance) {
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachMeasuredRootViewToInstance");
  UiThreadUtil.assertOnUiThread();

  // Reset view content as it's going to be populated by the application content from JS
  rootView.removeAllViews();
  rootView.setId(View.NO_ID);

  UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
  int rootTag = uiManagerModule.addMeasuredRootView(rootView);
  rootView.setRootViewTag(rootTag);
  @Nullable Bundle launchOptions = rootView.getLaunchOptions();
  WritableMap initialProps = Arguments.makeNativeMap(launchOptions);
  String jsAppModuleName = rootView.getJSModuleName();

  WritableNativeMap appParams = new WritableNativeMap();
  appParams.putDouble("rootTag", rootTag);
  appParams.putMap("initialProps", initialProps);
  catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
  rootView.onAttachedToReactInstance();
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
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: ReactInstanceManager.java   Source Code and License Vote up 6 votes
private void attachMeasuredRootViewToInstance(
    ReactRootView rootView,
    CatalystInstance catalystInstance) {
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachMeasuredRootViewToInstance");
  UiThreadUtil.assertOnUiThread();

  // Reset view content as it's going to be populated by the application content from JS
  rootView.removeAllViews();
  rootView.setId(View.NO_ID);

  UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
  int rootTag = uiManagerModule.addMeasuredRootView(rootView);
  rootView.setRootViewTag(rootTag);
  @Nullable Bundle launchOptions = rootView.getLaunchOptions();
  WritableMap initialProps = Arguments.makeNativeMap(launchOptions);
  String jsAppModuleName = rootView.getJSModuleName();

  WritableNativeMap appParams = new WritableNativeMap();
  appParams.putDouble("rootTag", rootTag);
  appParams.putMap("initialProps", initialProps);
  catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
  rootView.onAttachedToReactInstance();
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
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 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 6
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();
}