From fe498096b6a4d08d6839f4b937b6ae9e4998cab6 Mon Sep 17 00:00:00 2001 From: Ram N Date: Thu, 8 Nov 2018 12:27:12 -0800 Subject: [PATCH] Replace String with constants for Module names in Fb4aCoreInfraPackage Summary: Using constants is safer than using strings. More details at D12843649 Reviewed By: sahrens Differential Revision: D8226521 fbshipit-source-id: 4c78c8dfe0bd658f46c8f81e50ceae9299fc6f3c --- .../java/com/facebook/react/devsupport/JSDevSupport.java | 2 +- .../react/modules/i18nmanager/I18nManagerModule.java | 6 ++++-- .../facebook/react/modules/websocket/WebSocketModule.java | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java index f2b0e937b74f3f..9e98a6415ecf59 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java @@ -20,7 +20,7 @@ @ReactModule(name = JSDevSupport.MODULE_NAME) public class JSDevSupport extends ReactContextBaseJavaModule { - static final String MODULE_NAME = "JSDevSupport"; + public static final String MODULE_NAME = "JSDevSupport"; public static final int ERROR_CODE_EXCEPTION = 0; public static final int ERROR_CODE_VIEW_NOT_FOUND = 1; diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java index 0d491160b39363..9e15606235ccf2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java @@ -19,9 +19,11 @@ /** * {@link NativeModule} that allows JS to set allowRTL and get isRTL status. */ -@ReactModule(name = "I18nManager") +@ReactModule(name = I18nManagerModule.NAME) public class I18nManagerModule extends ContextBaseJavaModule { + public static final String NAME = "I18nManager"; + private final I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance(); public I18nManagerModule(Context context) { @@ -30,7 +32,7 @@ public I18nManagerModule(Context context) { @Override public String getName() { - return "I18nManager"; + return NAME; } @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java index 4095c8e5998720..33d8644eeabff7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java @@ -25,10 +25,10 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import java.util.concurrent.ConcurrentHashMap; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; import okhttp3.OkHttpClient; @@ -38,9 +38,9 @@ import okhttp3.WebSocketListener; import okio.ByteString; -@ReactModule(name = "WebSocketModule", hasConstants = false) +@ReactModule(name = WebSocketModule.NAME, hasConstants = false) public final class WebSocketModule extends ReactContextBaseJavaModule { - + public static final String NAME="WebSocketModule"; public interface ContentHandler { void onMessage(String text, WritableMap params); @@ -67,7 +67,7 @@ private void sendEvent(String eventName, WritableMap params) { @Override public String getName() { - return "WebSocketModule"; + return NAME; } public void setContentHandler(final int id, final ContentHandler contentHandler) {