mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Support onWindowFocusChange in Bridgeless (#43398)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43398 Implement onWindowFocusChange in Bridgeless by adding it to the ReactHostImpl Changelog: [Android][Breaking] Implement onWindowFocusChange in Bridgeless Reviewed By: javache Differential Revision: D54670119 fbshipit-source-id: 71f560e5a3bf0e853ac06955e67b8035f1ec0468
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9af98ccd71
commit
7b40c8ee5f
@@ -153,6 +153,7 @@ public class com/facebook/react/ReactDelegate {
|
||||
public fun onHostDestroy ()V
|
||||
public fun onHostPause ()V
|
||||
public fun onHostResume ()V
|
||||
public fun onWindowFocusChanged (Z)V
|
||||
public fun shouldShowDevMenuOrReload (ILandroid/view/KeyEvent;)Z
|
||||
}
|
||||
|
||||
@@ -203,6 +204,7 @@ public abstract interface class com/facebook/react/ReactHost {
|
||||
public abstract fun onHostPause (Landroid/app/Activity;)V
|
||||
public abstract fun onHostResume (Landroid/app/Activity;)V
|
||||
public abstract fun onHostResume (Landroid/app/Activity;Lcom/facebook/react/modules/core/DefaultHardwareBackBtnHandler;)V
|
||||
public abstract fun onWindowFocusChange (Z)V
|
||||
public abstract fun reload (Ljava/lang/String;)Lcom/facebook/react/interfaces/TaskInterface;
|
||||
public abstract fun removeBeforeDestroyListener (Lkotlin/jvm/functions/Function0;)V
|
||||
public abstract fun setJsEngineResolutionAlgorithm (Lcom/facebook/react/JSEngineResolutionAlgorithm;)V
|
||||
@@ -3641,6 +3643,7 @@ public class com/facebook/react/runtime/ReactHostImpl : com/facebook/react/React
|
||||
public fun onHostPause (Landroid/app/Activity;)V
|
||||
public fun onHostResume (Landroid/app/Activity;)V
|
||||
public fun onHostResume (Landroid/app/Activity;Lcom/facebook/react/modules/core/DefaultHardwareBackBtnHandler;)V
|
||||
public fun onWindowFocusChange (Z)V
|
||||
public fun reload (Ljava/lang/String;)Lcom/facebook/react/interfaces/TaskInterface;
|
||||
public fun removeBeforeDestroyListener (Lkotlin/jvm/functions/Function0;)V
|
||||
public fun removeReactInstanceEventListener (Lcom/facebook/react/ReactInstanceEventListener;)V
|
||||
|
||||
+1
-7
@@ -195,13 +195,7 @@ public class ReactActivityDelegate {
|
||||
}
|
||||
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
if (ReactFeatureFlags.enableBridgelessArchitecture) {
|
||||
// TODO T156475655: support onWindowFocusChanged
|
||||
} else {
|
||||
if (getReactNativeHost().hasInstance()) {
|
||||
getReactNativeHost().getReactInstanceManager().onWindowFocusChange(hasFocus);
|
||||
}
|
||||
}
|
||||
mReactDelegate.onWindowFocusChanged(hasFocus);
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
|
||||
+10
@@ -148,6 +148,16 @@ public class ReactDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
if (ReactFeatureFlags.enableBridgelessArchitecture) {
|
||||
mReactHost.onWindowFocusChange(hasFocus);
|
||||
} else {
|
||||
if (getReactNativeHost().hasInstance()) {
|
||||
getReactNativeHost().getReactInstanceManager().onWindowFocusChange(hasFocus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadApp() {
|
||||
loadApp(mMainComponentName);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,9 @@ public interface ReactHost {
|
||||
data: Intent?,
|
||||
)
|
||||
|
||||
/* To be called when focus has changed for the hosting window. */
|
||||
public fun onWindowFocusChange(hasFocus: Boolean)
|
||||
|
||||
public fun addBeforeDestroyListener(onBeforeDestroy: () -> Unit)
|
||||
|
||||
public fun removeBeforeDestroyListener(onBeforeDestroy: () -> Unit)
|
||||
|
||||
+17
@@ -650,6 +650,23 @@ public class ReactHostImpl implements ReactHost {
|
||||
"Tried to access onActivityResult while context is not ready"));
|
||||
}
|
||||
|
||||
/* To be called when focus has changed for the hosting window. */
|
||||
@ThreadConfined(UI)
|
||||
@Override
|
||||
public void onWindowFocusChange(boolean hasFocus) {
|
||||
final String method = "onWindowFocusChange(hasFocus = \"" + hasFocus + "\")";
|
||||
log(method);
|
||||
|
||||
ReactContext currentContext = getCurrentReactContext();
|
||||
if (currentContext != null) {
|
||||
currentContext.onWindowFocusChange(hasFocus);
|
||||
}
|
||||
ReactSoftExceptionLogger.logSoftException(
|
||||
TAG,
|
||||
new ReactNoCrashSoftException(
|
||||
"Tried to access onWindowFocusChange while context is not ready"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
JavaScriptContextHolder getJavaScriptContextHolder() {
|
||||
final ReactInstance reactInstance = mReactInstanceTaskRef.get().getResult();
|
||||
|
||||
Reference in New Issue
Block a user