mirror of
https://github.com/facebook/react-native.git
synced 2024-11-21 22:10:14 +00:00
Integrate DevSupportManager into activity lifecycle (#47531)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47531 When the activity is paused, or destroyed, we should disable the devsupportmanager. (This performs cleanup). When the activity is resumed, we should re-enable devsupportmanager. (This performs re-initialization). Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D65689053 fbshipit-source-id: 99de0906b8cdc84f56b4d334ac0eeecc7b436dd5
This commit is contained in:
parent
a2959a915c
commit
16eb53befa
@ -316,7 +316,7 @@ public class ReactHostImpl implements ReactHost {
|
||||
setCurrentActivity(activity);
|
||||
ReactContext currentContext = getCurrentReactContext();
|
||||
|
||||
// TODO(T137233065): Enable DevSupportManager here
|
||||
maybeEnableDevSupport(true);
|
||||
mReactLifecycleStateManager.moveToOnHostResume(currentContext, getCurrentActivity());
|
||||
}
|
||||
|
||||
@ -354,7 +354,7 @@ public class ReactHostImpl implements ReactHost {
|
||||
+ activityClass);
|
||||
}
|
||||
|
||||
// TODO(T137233065): Disable DevSupportManager here
|
||||
maybeEnableDevSupport(false);
|
||||
mDefaultHardwareBackBtnHandler = null;
|
||||
mReactLifecycleStateManager.moveToOnHostPause(currentContext, currentActivity);
|
||||
}
|
||||
@ -368,7 +368,7 @@ public class ReactHostImpl implements ReactHost {
|
||||
|
||||
ReactContext currentContext = getCurrentReactContext();
|
||||
|
||||
// TODO(T137233065): Disable DevSupportManager here
|
||||
maybeEnableDevSupport(false);
|
||||
mDefaultHardwareBackBtnHandler = null;
|
||||
mReactLifecycleStateManager.moveToOnHostPause(currentContext, getCurrentActivity());
|
||||
}
|
||||
@ -380,7 +380,7 @@ public class ReactHostImpl implements ReactHost {
|
||||
final String method = "onHostDestroy()";
|
||||
log(method);
|
||||
|
||||
// TODO(T137233065): Disable DevSupportManager here
|
||||
maybeEnableDevSupport(false);
|
||||
moveToHostDestroy(getCurrentReactContext());
|
||||
}
|
||||
|
||||
@ -392,12 +392,18 @@ public class ReactHostImpl implements ReactHost {
|
||||
|
||||
Activity currentActivity = getCurrentActivity();
|
||||
|
||||
// TODO(T137233065): Disable DevSupportManager here
|
||||
maybeEnableDevSupport(false);
|
||||
if (currentActivity == activity) {
|
||||
moveToHostDestroy(getCurrentReactContext());
|
||||
}
|
||||
}
|
||||
|
||||
private void maybeEnableDevSupport(boolean enabled) {
|
||||
if (mUseDevSupport) {
|
||||
mDevSupportManager.setDevSupportEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current ReactContext which could be nullable if ReactInstance hasn't been created.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user