Skip to content

Commit 9da485b

Browse files
cortinicofacebook-github-bot
authored andcommitted
Migrate to Kotlin - DevSupportManagerBase.kt (#50559)
Summary: Pull Request resolved: #50559 This diff migrates the following file to Kotlin - DevSupportManagerBase.kt as part of our ongoing effort of migrating the codebase to Kotlin This file was 1000LOC+ so its migration is quite involved. I had to look into nullability of various parameters. Most notably the `Array<StackFrame?>` -> `Array<StackFrame>`. This also is the last file left in the devsupport package that needs to be migrated to Kotlin. Changelog: [Android] [Breaking] - DevSupportManagerBase is now converted to Kotlin. If you're subclassing this class, you will have to adjust some of the parameters as types have changed during the migration. Reviewed By: javache, mdvacca Differential Revision: D72637098 fbshipit-source-id: b87d5f17e30d69fe9c09ec9b49f96818df34ea3b
1 parent dd0cd07 commit 9da485b

File tree

6 files changed

+996
-1232
lines changed

6 files changed

+996
-1232
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,35 +1996,35 @@ public abstract interface class com/facebook/react/devsupport/DevServerHelper$Pa
19961996
}
19971997

19981998
public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/facebook/react/devsupport/interfaces/DevSupportManager {
1999-
protected final field mReactInstanceDevHelper Lcom/facebook/react/devsupport/ReactInstanceDevHelper;
1999+
public static final field Companion Lcom/facebook/react/devsupport/DevSupportManagerBase$Companion;
20002000
public fun <init> (Landroid/content/Context;Lcom/facebook/react/devsupport/ReactInstanceDevHelper;Ljava/lang/String;ZLcom/facebook/react/devsupport/interfaces/RedBoxHandler;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;ILjava/util/Map;Lcom/facebook/react/common/SurfaceDelegateFactory;Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;Lcom/facebook/react/devsupport/interfaces/PausedInDebuggerOverlayManager;)V
20012001
public fun addCustomDevOption (Ljava/lang/String;Lcom/facebook/react/devsupport/interfaces/DevOptionHandler;)V
20022002
public fun createRootView (Ljava/lang/String;)Landroid/view/View;
20032003
public fun createSurfaceDelegate (Ljava/lang/String;)Lcom/facebook/react/common/SurfaceDelegate;
20042004
public fun destroyRootView (Landroid/view/View;)V
20052005
public fun downloadBundleResourceFromUrlSync (Ljava/lang/String;Ljava/io/File;)Ljava/io/File;
2006-
public fun fetchSplitBundleAndCreateBundleLoader (Ljava/lang/String;Lcom/facebook/react/devsupport/DevSupportManagerBase$CallbackWithBundleLoader;)V
2007-
protected fun getApplicationContext ()Landroid/content/Context;
2006+
public final fun fetchSplitBundleAndCreateBundleLoader (Ljava/lang/String;Lcom/facebook/react/devsupport/DevSupportManagerBase$CallbackWithBundleLoader;)V
2007+
protected final fun getApplicationContext ()Landroid/content/Context;
20082008
public fun getCurrentActivity ()Landroid/app/Activity;
2009-
public fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
2010-
public fun getDevLoadingViewManager ()Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;
2011-
public fun getDevServerHelper ()Lcom/facebook/react/devsupport/DevServerHelper;
2012-
public fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
2013-
public fun getDevSupportEnabled ()Z
2009+
public final fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
2010+
public final fun getDevLoadingViewManager ()Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;
2011+
public final fun getDevServerHelper ()Lcom/facebook/react/devsupport/DevServerHelper;
2012+
public final fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
2013+
public final fun getDevSupportEnabled ()Z
20142014
public fun getDownloadedJSBundleFile ()Ljava/lang/String;
2015-
public fun getJSAppBundleName ()Ljava/lang/String;
2016-
public fun getLastErrorCookie ()I
2017-
public fun getLastErrorStack ()[Lcom/facebook/react/devsupport/interfaces/StackFrame;
2018-
public fun getLastErrorTitle ()Ljava/lang/String;
2019-
public fun getLastErrorType ()Lcom/facebook/react/devsupport/interfaces/ErrorType;
2020-
public fun getReactInstanceDevHelper ()Lcom/facebook/react/devsupport/ReactInstanceDevHelper;
2015+
public final fun getJSAppBundleName ()Ljava/lang/String;
2016+
public final fun getLastErrorCookie ()I
2017+
public final fun getLastErrorStack ()[Lcom/facebook/react/devsupport/interfaces/StackFrame;
2018+
public final fun getLastErrorTitle ()Ljava/lang/String;
2019+
public final fun getLastErrorType ()Lcom/facebook/react/devsupport/interfaces/ErrorType;
2020+
public final fun getReactInstanceDevHelper ()Lcom/facebook/react/devsupport/ReactInstanceDevHelper;
20212021
public fun getRedBoxHandler ()Lcom/facebook/react/devsupport/interfaces/RedBoxHandler;
20222022
public fun getSourceMapUrl ()Ljava/lang/String;
20232023
public fun getSourceUrl ()Ljava/lang/String;
20242024
protected abstract fun getUniqueTag ()Ljava/lang/String;
20252025
public fun handleException (Ljava/lang/Exception;)V
20262026
public fun hasUpToDateJSBundleInCache ()Z
2027-
protected fun hideDevLoadingView ()V
2027+
protected final fun hideDevLoadingView ()V
20282028
public fun hidePausedInDebuggerOverlay ()V
20292029
public fun hideRedboxDialog ()V
20302030
public fun isPackagerRunning (Lcom/facebook/react/devsupport/interfaces/PackagerStatusCallback;)V
@@ -2036,11 +2036,16 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
20362036
public fun reloadJSFromServer (Ljava/lang/String;Lcom/facebook/react/devsupport/interfaces/BundleLoadCallback;)V
20372037
public fun reloadSettings ()V
20382038
public fun setAdditionalOptionForPackager (Ljava/lang/String;Ljava/lang/String;)V
2039-
public fun setDevSupportEnabled (Z)V
2039+
public final fun setDevLoadingViewManager (Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;)V
2040+
public final fun setDevSupportEnabled (Z)V
20402041
public fun setFpsDebugEnabled (Z)V
20412042
public fun setHotModuleReplacementEnabled (Z)V
2043+
public final fun setLastErrorCookie (I)V
2044+
public final fun setLastErrorStack ([Lcom/facebook/react/devsupport/interfaces/StackFrame;)V
2045+
public final fun setLastErrorTitle (Ljava/lang/String;)V
2046+
public final fun setLastErrorType (Lcom/facebook/react/devsupport/interfaces/ErrorType;)V
20422047
public fun setPackagerLocationCustomizer (Lcom/facebook/react/devsupport/interfaces/DevSupportManager$PackagerLocationCustomizer;)V
2043-
protected fun showDevLoadingViewForRemoteJSEnabled ()V
2048+
protected final fun showDevLoadingViewForRemoteJSEnabled ()V
20442049
public fun showDevOptionsDialog ()V
20452050
public fun showNewJSError (Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;I)V
20462051
public fun showNewJavaError (Ljava/lang/String;Ljava/lang/Throwable;)V
@@ -2055,6 +2060,9 @@ public abstract interface class com/facebook/react/devsupport/DevSupportManagerB
20552060
public abstract fun onSuccess (Lcom/facebook/react/bridge/JSBundleLoader;)V
20562061
}
20572062

2063+
public final class com/facebook/react/devsupport/DevSupportManagerBase$Companion {
2064+
}
2065+
20582066
public abstract interface class com/facebook/react/devsupport/DevSupportManagerFactory {
20592067
public abstract fun create (Landroid/content/Context;Lcom/facebook/react/devsupport/ReactInstanceDevHelper;Ljava/lang/String;ZLcom/facebook/react/devsupport/interfaces/RedBoxHandler;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;ILjava/util/Map;Lcom/facebook/react/common/SurfaceDelegateFactory;Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;Lcom/facebook/react/devsupport/interfaces/PausedInDebuggerOverlayManager;)Lcom/facebook/react/devsupport/interfaces/DevSupportManager;
20602068
public abstract fun create (Landroid/content/Context;Lcom/facebook/react/devsupport/ReactInstanceDevHelper;Ljava/lang/String;ZLcom/facebook/react/devsupport/interfaces/RedBoxHandler;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;ILjava/util/Map;Lcom/facebook/react/common/SurfaceDelegateFactory;Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;Lcom/facebook/react/devsupport/interfaces/PausedInDebuggerOverlayManager;Z)Lcom/facebook/react/devsupport/interfaces/DevSupportManager;

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class BridgeDevSupportManager(
5656
redBoxHandler: RedBoxHandler?,
5757
devBundleDownloadListener: DevBundleDownloadListener?,
5858
minNumShakes: Int,
59-
customPackagerCommandHandlers: Map<String?, RequestHandler?>?,
59+
customPackagerCommandHandlers: Map<String, RequestHandler>?,
6060
surfaceDelegateFactory: SurfaceDelegateFactory?,
6161
devLoadingViewManager: DevLoadingViewManager?,
6262
pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?
@@ -74,7 +74,8 @@ public class BridgeDevSupportManager(
7474
devLoadingViewManager,
7575
pausedInDebuggerOverlayManager) {
7676

77-
override fun getUniqueTag(): String = "Bridge"
77+
override val uniqueTag: String
78+
get() = "Bridge"
7879

7980
override fun loadSplitBundleFromServer(bundlePath: String, callback: DevSplitBundleCallback) {
8081
fetchSplitBundleAndCreateBundleLoader(

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgelessDevSupportManager.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,18 @@ internal class BridgelessDevSupportManager(
7171
devLoadingViewManager = null,
7272
pausedInDebuggerOverlayManager = null)
7373

74-
override fun getUniqueTag(): String = "Bridgeless"
74+
override val uniqueTag: String
75+
get() = "Bridgeless"
7576

7677
override fun loadSplitBundleFromServer(bundlePath: String, callback: DevSplitBundleCallback) {
7778
fetchSplitBundleAndCreateBundleLoader(
7879
bundlePath,
7980
object : CallbackWithBundleLoader {
8081
override fun onSuccess(bundleLoader: JSBundleLoader) {
8182
try {
82-
mReactInstanceDevHelper.loadBundle(bundleLoader).waitForCompletion()
83+
reactInstanceDevHelper.loadBundle(bundleLoader).waitForCompletion()
8384
val bundleURL = devServerHelper.getDevServerSplitBundleURL(bundlePath)
84-
val reactContext = mReactInstanceDevHelper.currentReactContext
85+
val reactContext = reactInstanceDevHelper.currentReactContext
8586
reactContext?.getJSModule(HMRClient::class.java)?.registerBundle(bundleURL)
8687
callback.onSuccess()
8788
} catch (e: InterruptedException) {
@@ -99,6 +100,6 @@ internal class BridgelessDevSupportManager(
99100
UiThreadUtil.assertOnUiThread()
100101
// dismiss redbox if exists
101102
hideRedboxDialog()
102-
mReactInstanceDevHelper.reload("BridgelessDevSupportManager.handleReloadJS()")
103+
reactInstanceDevHelper.reload("BridgelessDevSupportManager.handleReloadJS()")
103104
}
104105
}

0 commit comments

Comments
 (0)