Skip to content

Commit

Permalink
Integrate DevSupportManager into activity lifecycle (#47531)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
RSNara authored and facebook-github-bot committed Nov 11, 2024
1 parent a2959a9 commit 16eb53b
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public void onHostResume(final @Nullable Activity activity) {
setCurrentActivity(activity);
ReactContext currentContext = getCurrentReactContext();

// TODO(T137233065): Enable DevSupportManager here
maybeEnableDevSupport(true);
mReactLifecycleStateManager.moveToOnHostResume(currentContext, getCurrentActivity());
}

Expand Down Expand Up @@ -354,7 +354,7 @@ public void onHostPause(final @Nullable Activity activity) {
+ activityClass);
}

// TODO(T137233065): Disable DevSupportManager here
maybeEnableDevSupport(false);
mDefaultHardwareBackBtnHandler = null;
mReactLifecycleStateManager.moveToOnHostPause(currentContext, currentActivity);
}
Expand All @@ -368,7 +368,7 @@ public void onHostPause() {

ReactContext currentContext = getCurrentReactContext();

// TODO(T137233065): Disable DevSupportManager here
maybeEnableDevSupport(false);
mDefaultHardwareBackBtnHandler = null;
mReactLifecycleStateManager.moveToOnHostPause(currentContext, getCurrentActivity());
}
Expand All @@ -380,7 +380,7 @@ public void onHostDestroy() {
final String method = "onHostDestroy()";
log(method);

// TODO(T137233065): Disable DevSupportManager here
maybeEnableDevSupport(false);
moveToHostDestroy(getCurrentReactContext());
}

Expand All @@ -392,12 +392,18 @@ public void onHostDestroy(@Nullable Activity activity) {

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.
*
Expand Down

0 comments on commit 16eb53b

Please sign in to comment.