mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Create UIManager interface and extract common classes in uimanager/common
Reviewed By: achen1 Differential Revision: D7102674 fbshipit-source-id: e14b6782ad102ec1c3d37988df4bbd4190511f09
This commit is contained in:
committed by
Facebook Github Bot
parent
b181b7797f
commit
6b45fb2cb1
@@ -58,6 +58,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReactMarker;
|
||||
import com.facebook.react.bridge.ReactMarkerConstants;
|
||||
import com.facebook.react.bridge.UIManager;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
|
||||
import com.facebook.react.common.LifecycleState;
|
||||
@@ -328,40 +329,6 @@ public class ReactInstanceManager {
|
||||
recreateReactContextInBackgroundInner();
|
||||
}
|
||||
|
||||
@ThreadConfined(UI)
|
||||
public void registerAdditionalPackages(List<ReactPackage> packages) {
|
||||
if (packages == null || packages.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// CatalystInstance hasn't been created, so add packages for later evaluation
|
||||
if (!hasStartedCreatingInitialContext()) {
|
||||
synchronized (mPackages) {
|
||||
for (ReactPackage p : packages) {
|
||||
if (!mPackages.contains(p)) {
|
||||
mPackages.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ReactContext context = getCurrentReactContext();
|
||||
CatalystInstance catalystInstance = context != null ? context.getCatalystInstance() : null;
|
||||
|
||||
Assertions.assertNotNull(catalystInstance, "CatalystInstance null after hasStartedCreatingInitialContext true.");
|
||||
|
||||
final ReactApplicationContext reactContext = getReactApplicationContext();
|
||||
|
||||
NativeModuleRegistry nativeModuleRegistry = processPackages(reactContext, packages, true);
|
||||
catalystInstance.extendNativeModules(nativeModuleRegistry);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public @Nullable ReactApplicationContext getReactApplicationContext() {
|
||||
return new ReactApplicationContext(mApplicationContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recreate the react application and context. This should be called if configuration has changed
|
||||
* or the developer has requested the app to be reloaded. It should only be called after an
|
||||
@@ -1040,8 +1007,7 @@ public class ReactInstanceManager {
|
||||
CatalystInstance catalystInstance) {
|
||||
Log.d(ReactConstants.TAG, "ReactInstanceManager.attachRootViewToInstance()");
|
||||
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachRootViewToInstance");
|
||||
UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
|
||||
final int rootTag = uiManagerModule.addRootView(rootView);
|
||||
final int rootTag = catalystInstance.getNativeModule(UIManagerModule.class).addRootView(rootView);
|
||||
rootView.setRootViewTag(rootTag);
|
||||
rootView.invokeJSEntryPoint();
|
||||
Systrace.beginAsyncSection(
|
||||
@@ -1097,7 +1063,7 @@ public class ReactInstanceManager {
|
||||
JSBundleLoader jsBundleLoader) {
|
||||
Log.d(ReactConstants.TAG, "ReactInstanceManager.createReactContext()");
|
||||
ReactMarker.logMarker(CREATE_REACT_CONTEXT_START);
|
||||
final ReactApplicationContext reactContext = getReactApplicationContext();
|
||||
final ReactApplicationContext reactContext = new ReactApplicationContext(mApplicationContext);
|
||||
|
||||
if (mUseDeveloperSupport) {
|
||||
reactContext.setNativeModuleCallExceptionHandler(mDevSupportManager);
|
||||
@@ -1113,8 +1079,7 @@ public class ReactInstanceManager {
|
||||
.setJSExecutor(jsExecutor)
|
||||
.setRegistry(nativeModuleRegistry)
|
||||
.setJSBundleLoader(jsBundleLoader)
|
||||
.setNativeModuleCallExceptionHandler(exceptionHandler)
|
||||
.setBridgeListener(mBridgeListener);
|
||||
.setNativeModuleCallExceptionHandler(exceptionHandler);
|
||||
|
||||
ReactMarker.logMarker(CREATE_CATALYST_INSTANCE_START);
|
||||
// CREATE_CATALYST_INSTANCE_END is in JSCExecutor.cpp
|
||||
@@ -1126,6 +1091,9 @@ public class ReactInstanceManager {
|
||||
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
ReactMarker.logMarker(CREATE_CATALYST_INSTANCE_END);
|
||||
}
|
||||
if (mBridgeListener != null) {
|
||||
mBridgeListener.onBridgeStarted(reactContext, catalystInstance);
|
||||
}
|
||||
|
||||
if (mBridgeIdleDebugListener != null) {
|
||||
catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener);
|
||||
|
||||
Reference in New Issue
Block a user