Make NativeModules TurboModule-compatible

Summary:
All these NativeModules are now: (1) type-safe, (2) TurboModule-compatible.

**Note:** We still need to update `{Catalyst,Work,Fb4a}TurboModuleManagerDelegate` to understand these TurboModules. I'll most likely write up that diff and stack this one on top of it.

Changelog:
[Android][Added] - Make NativeModules TurboModule-compatible

Reviewed By: mdvacca

Differential Revision: D18888735

fbshipit-source-id: 34df64dc70e3f3a0a0303c049861205f9d3fd2ed
This commit is contained in:
Ramanpreet Nara
2019-12-15 16:56:53 -08:00
committed by Facebook Github Bot
parent 80bc51195e
commit 96a6ffb3e8
28 changed files with 342 additions and 222 deletions
@@ -10,16 +10,15 @@ package com.facebook.react.devsupport;
import android.util.Pair;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.fbreact.specs.NativeJSDevSupportSpec;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.module.annotations.ReactModule;
import java.util.HashMap;
import java.util.Map;
@ReactModule(name = JSDevSupport.MODULE_NAME)
public class JSDevSupport extends ReactContextBaseJavaModule {
public class JSDevSupport extends NativeJSDevSupportSpec {
public static final String MODULE_NAME = "JSDevSupport";
public static final int ERROR_CODE_EXCEPTION = 0;
@@ -72,7 +71,7 @@ public class JSDevSupport extends ReactContextBaseJavaModule {
}
@SuppressWarnings("unused")
@ReactMethod
@Override
public synchronized void onSuccess(String data) {
if (mCurrentCallback != null) {
mCurrentCallback.onSuccess(data);
@@ -80,15 +79,17 @@ public class JSDevSupport extends ReactContextBaseJavaModule {
}
@SuppressWarnings("unused")
@ReactMethod
public synchronized void onFailure(int errorCode, String error) {
@Override
public synchronized void onFailure(double errorCodeDouble, String error) {
int errorCode = (int) errorCodeDouble;
if (mCurrentCallback != null) {
mCurrentCallback.onFailure(errorCode, new RuntimeException(error));
}
}
@Override
public Map<String, Object> getConstants() {
public Map<String, Object> getTypedExportedConstants() {
HashMap<String, Object> constants = new HashMap<>();
constants.put("ERROR_CODE_EXCEPTION", ERROR_CODE_EXCEPTION);
constants.put("ERROR_CODE_VIEW_NOT_FOUND", ERROR_CODE_VIEW_NOT_FOUND);