From e51ff0b6e693010c4a078e133f3ff31336d116ec Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 15 Jun 2023 22:34:36 -0700 Subject: [PATCH] Refactor ReactHost to implement ReactHostInterface Summary: Refactor ReactHost to implement ReactHostInterface bypass-github-export-checks changelog: [internal] internal Reviewed By: cortinico Differential Revision: D46770421 fbshipit-source-id: d7d6dc361ef89b3478e882a3334059c6440f1edf --- .../com/facebook/react/bridgeless/ReactHost.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/ReactHost.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/ReactHost.java index 88dd19ed429..608b58e9f84 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/ReactHost.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/ReactHost.java @@ -48,6 +48,7 @@ import com.facebook.react.devsupport.DisabledDevSupportManager; import com.facebook.react.devsupport.interfaces.DevSupportManager; import com.facebook.react.fabric.ComponentFactory; import com.facebook.react.fabric.FabricUIManager; +import com.facebook.react.interfaces.ReactHostInterface; import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; import com.facebook.react.modules.core.DeviceEventManagerModule; import com.facebook.react.uimanager.UIManagerModule; @@ -77,7 +78,7 @@ import java.util.concurrent.atomic.AtomicReference; */ @ThreadSafe @Nullsafe(Nullsafe.Mode.LOCAL) -public class ReactHost { +public class ReactHost implements ReactHostInterface { // TODO T61403233 Make this configurable by product code private static final boolean DEV = ReactBuildConfig.DEBUG; @@ -183,6 +184,7 @@ public class ReactHost { }; } + @Override public LifecycleState getLifecycleState() { return mReactLifecycleStateManager.getLifecycleState(); } @@ -322,6 +324,7 @@ public class ReactHost { * @param activity The host activity */ @ThreadConfined(UI) + @Override public void onHostResume( final @Nullable Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) { mDefaultHardwareBackBtnHandler = defaultBackButtonImpl; @@ -329,6 +332,7 @@ public class ReactHost { } @ThreadConfined(UI) + @Override public void onHostResume(final @Nullable Activity activity) { final String method = "onHostResume(activity)"; log(method); @@ -341,6 +345,7 @@ public class ReactHost { } @ThreadConfined(UI) + @Override public void onHostPause(final @Nullable Activity activity) { final String method = "onHostPause(activity)"; log(method); @@ -368,6 +373,7 @@ public class ReactHost { /** To be called when the host activity is paused. */ @ThreadConfined(UI) + @Override public void onHostPause() { final String method = "onHostPause()"; log(method); @@ -381,6 +387,7 @@ public class ReactHost { /** To be called when the host activity is destroyed. */ @ThreadConfined(UI) + @Override public void onHostDestroy() { final String method = "onHostDestroy()"; log(method); @@ -390,6 +397,7 @@ public class ReactHost { } @ThreadConfined(UI) + @Override public void onHostDestroy(@Nullable Activity activity) { final String method = "onHostDestroy(activity)"; log(method); @@ -413,10 +421,12 @@ public class ReactHost { * * @return The {@link BridgelessReactContext} associated with ReactInstance. */ + @Override public @Nullable ReactContext getCurrentReactContext() { return mBridgelessReactContextRef.getNullable(); } + @Override public DevSupportManager getDevSupportManager() { return assertNotNull(mDevSupportManager); } @@ -503,6 +513,7 @@ public class ReactHost { } @ThreadConfined(UI) + @Override public boolean onBackPressed() { UiThreadUtil.assertOnUiThread(); final ReactInstance reactInstance = mReactInstanceTaskRef.get().getResult();