Refactor ReactDelegate to provide DevSupportManager (#43520)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43520

Refactor ReactDelegate to have a private `getDevSupportManager()` that can also be re-used  by `reload()`

This method conditionally provides the correct DevSupportManager in cases of Bridge & Bridgeless

Changelog:
[Internal] internal

Reviewed By: cortinico

Differential Revision: D54967130

fbshipit-source-id: 37d585de33a50b98d01803d3080c5693a8c494b9
This commit is contained in:
Arushi Kesarwani
2024-03-18 11:54:03 -07:00
committed by Facebook GitHub Bot
parent 43ffce9fb3
commit 6dd0cc99f8
@@ -81,6 +81,20 @@ public class ReactDelegate {
mReactNativeHost = reactNativeHost;
}
@Nullable
private DevSupportManager getDevSupportManager() {
if (ReactFeatureFlags.enableBridgelessArchitecture
&& mReactHost != null
&& mReactHost.getDevSupportManager() != null) {
return mReactHost.getDevSupportManager();
} else if (getReactNativeHost().hasInstance()
&& getReactNativeHost().getUseDeveloperSupport()) {
return getReactNativeHost().getReactInstanceManager().getDevSupportManager();
} else {
return null;
}
}
public void onHostResume() {
if (!(mActivity instanceof DefaultHardwareBackBtnHandler)) {
throw new ClassCastException(
@@ -258,15 +272,8 @@ public class ReactDelegate {
* application.
*/
public boolean shouldShowDevMenuOrReload(int keyCode, KeyEvent event) {
DevSupportManager devSupportManager = null;
if (ReactFeatureFlags.enableBridgelessArchitecture
&& mReactHost != null
&& mReactHost.getDevSupportManager() != null) {
devSupportManager = mReactHost.getDevSupportManager();
} else if (getReactNativeHost().hasInstance()
&& getReactNativeHost().getUseDeveloperSupport()) {
devSupportManager = getReactNativeHost().getReactInstanceManager().getDevSupportManager();
} else {
DevSupportManager devSupportManager = getDevSupportManager();
if (devSupportManager == null) {
return false;
}