mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Venice][Android] Migrate ReactModalHostView to use BridgelessReactContext
Summary: - Use ThemedReactContext explicitly to reduce confusion, "addLifecycleEventListener()" and "removeLifecycleEventListener" should be forced to call on ThemedReactContext - Migrate "getNativeModule" and "handleException" calls from ThemedReactContext to ThemedReactContext.getReactApplicationContext Changelog: [Android][Changed] - Use ThemedReactContext explicitly to reduce confusion Reviewed By: mdvacca Differential Revision: D42101979 fbshipit-source-id: be34b7397ccf4f58477bab6cfa8c58eedd99e225
This commit is contained in:
1 parent
e71b094b24
commit
9f78517d64
1 file changed
+11
-8
@@ -41,6 +41,7 @@ import com.facebook.react.uimanager.JSPointerDispatcher;
|
||||
import com.facebook.react.uimanager.JSTouchDispatcher;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
import com.facebook.react.uimanager.RootView;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.events.EventDispatcher;
|
||||
import com.facebook.react.views.common.ContextUtils;
|
||||
@@ -87,9 +88,9 @@ public class ReactModalHostView extends ViewGroup
|
||||
private @Nullable DialogInterface.OnShowListener mOnShowListener;
|
||||
private @Nullable OnRequestCloseListener mOnRequestCloseListener;
|
||||
|
||||
public ReactModalHostView(Context context) {
|
||||
public ReactModalHostView(ThemedReactContext context) {
|
||||
super(context);
|
||||
((ReactContext) context).addLifecycleEventListener(this);
|
||||
context.addLifecycleEventListener(this);
|
||||
|
||||
mHostView = new DialogRootViewGroup(context);
|
||||
}
|
||||
@@ -159,7 +160,7 @@ public class ReactModalHostView extends ViewGroup
|
||||
}
|
||||
|
||||
public void onDropInstance() {
|
||||
((ReactContext) getContext()).removeLifecycleEventListener(this);
|
||||
((ThemedReactContext) getContext()).removeLifecycleEventListener(this);
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@@ -237,7 +238,7 @@ public class ReactModalHostView extends ViewGroup
|
||||
}
|
||||
|
||||
private @Nullable Activity getCurrentActivity() {
|
||||
return ((ReactContext) getContext()).getCurrentActivity();
|
||||
return ((ThemedReactContext) getContext()).getCurrentActivity();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -460,7 +461,9 @@ public class ReactModalHostView extends ViewGroup
|
||||
@Override
|
||||
public void runGuarded() {
|
||||
UIManagerModule uiManager =
|
||||
(getReactContext()).getNativeModule(UIManagerModule.class);
|
||||
getReactContext()
|
||||
.getReactApplicationContext()
|
||||
.getNativeModule(UIManagerModule.class);
|
||||
|
||||
if (uiManager == null) {
|
||||
return;
|
||||
@@ -520,11 +523,11 @@ public class ReactModalHostView extends ViewGroup
|
||||
|
||||
@Override
|
||||
public void handleException(Throwable t) {
|
||||
getReactContext().handleException(new RuntimeException(t));
|
||||
getReactContext().getReactApplicationContext().handleException(new RuntimeException(t));
|
||||
}
|
||||
|
||||
private ReactContext getReactContext() {
|
||||
return (ReactContext) getContext();
|
||||
private ThemedReactContext getReactContext() {
|
||||
return (ThemedReactContext) getContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user