|
15 | 15 | import androidx.annotation.NonNull;
|
16 | 16 | import androidx.annotation.Nullable;
|
17 | 17 | import com.facebook.infer.annotation.Assertions;
|
| 18 | +import com.facebook.react.bridge.UiThreadUtil; |
18 | 19 | import com.facebook.react.config.ReactFeatureFlags;
|
19 | 20 | import com.facebook.react.devsupport.DisabledDevSupportManager;
|
20 | 21 | import com.facebook.react.devsupport.DoubleTapReloadRecognizer;
|
@@ -99,7 +100,7 @@ private DevSupportManager getDevSupportManager() {
|
99 | 100 | && mReactHost.getDevSupportManager() != null) {
|
100 | 101 | return mReactHost.getDevSupportManager();
|
101 | 102 | } else if (getReactNativeHost().hasInstance()
|
102 |
| - && getReactNativeHost().getUseDeveloperSupport()) { |
| 103 | + && getReactNativeHost().getReactInstanceManager() != null) { |
103 | 104 | return getReactNativeHost().getReactInstanceManager().getDevSupportManager();
|
104 | 105 | } else {
|
105 | 106 | return null;
|
@@ -241,17 +242,31 @@ public boolean onKeyLongPress(int keyCode) {
|
241 | 242 |
|
242 | 243 | public void reload() {
|
243 | 244 | DevSupportManager devSupportManager = getDevSupportManager();
|
244 |
| - if (devSupportManager != null) { |
245 |
| - // With Bridgeless enabled, reload in RELEASE mode |
246 |
| - if (devSupportManager instanceof DisabledDevSupportManager |
247 |
| - && ReactFeatureFlags.enableBridgelessArchitecture |
248 |
| - && mReactHost != null) { |
249 |
| - // Do not reload the bundle from JS as there is no bundler running in release mode. |
250 |
| - mReactHost.reload("ReactDelegate.reload()"); |
| 245 | + if (devSupportManager == null) { |
| 246 | + return; |
| 247 | + } |
| 248 | + |
| 249 | + // Reload in RELEASE mode |
| 250 | + if (devSupportManager instanceof ReleaseDevSupportManager) { |
| 251 | + // Do not reload the bundle from JS as there is no bundler running in release mode. |
| 252 | + if (ReactFeatureFlags.enableBridgelessArchitecture) { |
| 253 | + if (mReactHost != null) { |
| 254 | + mReactHost.reload("ReactDelegate.reload()"); |
| 255 | + } |
251 | 256 | } else {
|
252 |
| - devSupportManager.handleReloadJS(); |
| 257 | + UiThreadUtil.runOnUiThread( |
| 258 | + () -> { |
| 259 | + if (mReactNativeHost.hasInstance() |
| 260 | + && mReactNativeHost.getReactInstanceManager() != null) { |
| 261 | + mReactNativeHost.getReactInstanceManager().recreateReactContextInBackground(); |
| 262 | + } |
| 263 | + }); |
253 | 264 | }
|
| 265 | + return; |
254 | 266 | }
|
| 267 | + |
| 268 | + // Reload in DEBUG mode |
| 269 | + devSupportManager.handleReloadJS(); |
255 | 270 | }
|
256 | 271 |
|
257 | 272 | public void loadApp() {
|
|
0 commit comments