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

The following examples show how to use com.facebook.react.bridge.WritableNativeMap#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: Login.java    From imsdk-android with MIT License 6 votes vote down vote up
@ReactMethod
public void getLoginInfo(
        Callback successCallback,
        Callback errorCallback) {
    try {
        WritableNativeMap map = new WritableNativeMap();
        map.putString("userid", CurrentPreference.getInstance().getUserid());

        map.putString("token", CurrentPreference.getInstance().getToken());
        map.putString("q_auth", CurrentPreference.getInstance().getVerifyKey() == null ? "404" : CurrentPreference.getInstance().getVerifyKey());
        map.putString("c_key", getCKey());
        map.putDouble("timestamp", System.currentTimeMillis());

        successCallback.invoke(map);
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}
 
Example 2
Source File: QimRNBModule.java    From imsdk-android with MIT License 5 votes vote down vote up
@ReactMethod
    public void getTOTP(final Callback callback) {
//
        if (TextUtils.isEmpty(CurrentPreference.getInstance().getVerifyKey())) {
            WritableNativeMap map = new WritableNativeMap();
            map.putString("totp", "000000");
            map.putInt("time", 0);
            callback.invoke(map);
            return;
        }
        String seret = String.format("u=%s&k=%s", CurrentPreference.getInstance().getPreferenceUserId(), CurrentPreference.getInstance().getVerifyKey());
        long timeStampSec = System.currentTimeMillis() - CurrentPreference.getInstance().getServerTimeDiff();
        long timestamp = Long.parseLong(String.format("%010d", timeStampSec));
        OtpProvider otp = new OtpProvider();
        String totp = "";
        try {
            totp = otp.computePin(seret, timestamp, null);
        } catch (Exception e) {
            totp = "000000";
            e.printStackTrace();
        }
        WritableNativeMap success = new WritableNativeMap();
        success.putString("totp", totp);
        success.putDouble("time", timestamp);
        callback.invoke(success);


    }
 
Example 3
Source File: ReactRootView.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * 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 4
Source File: DisplayMetricsHolder.java    From react-native-GPay with MIT License 5 votes vote down vote up
private static WritableNativeMap getPhysicalPixelsNativeMap(DisplayMetrics displayMetrics, double fontScale) {
  final WritableNativeMap result = new WritableNativeMap();
  result.putInt("width", displayMetrics.widthPixels);
  result.putInt("height", displayMetrics.heightPixels);
  result.putDouble("scale", displayMetrics.density);
  result.putDouble("fontScale", fontScale);
  result.putDouble("densityDpi", displayMetrics.densityDpi);
  return result;
}
 
Example 5
Source File: CatalystNativeJavaToJSArgumentsTestCase.java    From react-native-GPay with MIT License 5 votes vote down vote up
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();
}