Skip to content

Commit

Permalink
Remove UIImplementationProvider class and refactor UIManagerModule
Browse files Browse the repository at this point in the history
Summary:
@public
This diff deprecates and deletes the UIImplementationProvider class.

It is not required to create an UIImplementation provider anymore, from now on the UIImplementation is created inside the UIManagerModule.

If you are using the UIImplementationProvider to create a ReactInstanceManager
e.g.:

```
    ReactInstanceManager =
        getReactInstanceManagerBuilder()
            ...
            .setUIImplementationProvider(...)
            ...
            .build();
```

Then you should just remove that line:
```
    ReactInstanceManager =
        getReactInstanceManagerBuilder()
            .set.....
            .build();
```

Reviewed By: achen1

Differential Revision: D8650376

fbshipit-source-id: 8d883295d8bf6578a99685edf6a2a84c6d0df0cf
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jun 27, 2018
1 parent a373bf7 commit 506f920
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@
import com.facebook.react.shell.MainReactPackage;
import com.facebook.react.testing.idledetection.ReactBridgeIdleSignaler;
import com.facebook.react.testing.idledetection.ReactIdleDetectionUtil;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.uimanager.ViewManagerRegistry;
import com.facebook.react.uimanager.events.EventDispatcher;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -139,16 +138,11 @@ public void loadApp(String appKey, ReactInstanceSpecForTest spec, boolean enable
loadApp(appKey, spec, null, DEFAULT_BUNDLE_NAME, enableDevSupport);
}

public void loadApp(String appKey, ReactInstanceSpecForTest spec, String bundleName) {
loadApp(appKey, spec, null, bundleName, false /* = useDevSupport */);
}

public void loadApp(
String appKey,
ReactInstanceSpecForTest spec,
String bundleName,
UIImplementationProvider uiImplementationProvider) {
loadApp(appKey, spec, null, bundleName, false /* = useDevSupport */, uiImplementationProvider);
String bundleName) {
loadApp(appKey, spec, null, bundleName, false /* = useDevSupport */);
}

public void resetRootViewForScreenshotTests() {
Expand All @@ -165,23 +159,13 @@ public void resetRootViewForScreenshotTests() {
mScreenshotingFrameLayout.addView(mReactRootView);
}

public void loadApp(
String appKey,
ReactInstanceSpecForTest spec,
@Nullable Bundle initialProps,
String bundleName,
boolean useDevSupport) {
loadApp(appKey, spec, initialProps, bundleName, useDevSupport, null);
}

public void loadApp(
String appKey,
ReactInstanceSpecForTest spec,
@Nullable Bundle initialProps,
String bundleName,
boolean useDevSupport,
UIImplementationProvider uiImplementationProvider) {
loadBundle(spec, bundleName, useDevSupport, uiImplementationProvider);
boolean useDevSupport) {
loadBundle(spec, bundleName, useDevSupport);
renderComponent(appKey, initialProps);
}

Expand Down Expand Up @@ -217,14 +201,6 @@ public void loadBundle(
ReactInstanceSpecForTest spec,
String bundleName,
boolean useDevSupport) {
loadBundle(spec, bundleName, useDevSupport, null);
}

public void loadBundle(
ReactInstanceSpecForTest spec,
String bundleName,
boolean useDevSupport,
UIImplementationProvider uiImplementationProvider) {

mBridgeIdleSignaler = new ReactBridgeIdleSignaler();

Expand Down Expand Up @@ -277,8 +253,7 @@ public FabricUIManager get() {
};
}
});
}})
.setUIImplementationProvider(uiImplementationProvider);
}});

final CountDownLatch latch = new CountDownLatch(1);
runOnUiThread(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactIntegrationTestCase;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.view.ReactViewManager;
Expand Down Expand Up @@ -85,7 +84,7 @@ protected void setUp() throws Exception {
List<ViewManager> viewManagers = Arrays.<ViewManager>asList(
new ReactViewManager());
final UIManagerModule mUIManager =
new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0);
new UIManagerModule(getContext(), viewManagers, 0);
UiThreadUtil.runOnUiThread(
new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactIntegrationTestCase;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.view.ReactViewManager;
Expand Down Expand Up @@ -62,7 +61,7 @@ protected void setUp() throws Exception {
List<ViewManager> viewManagers = Arrays.<ViewManager>asList(
new ReactViewManager());
final UIManagerModule mUIManager =
new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0);
new UIManagerModule(getContext(), viewManagers, 0);
UiThreadUtil.runOnUiThread(
new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactIntegrationTestCase;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
Expand Down Expand Up @@ -112,7 +111,7 @@ protected void setUp() throws Exception {

final UIManagerModule mUIManager =
new UIManagerModule(
getContext(), new ArrayList<ViewManager>(), new UIImplementationProvider(), 0);
getContext(), new ArrayList<ViewManager>(), 0);

mAssertModule = new AssertModule();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.facebook.react.testing.ReactIntegrationTestCase;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.text.ReactRawTextManager;
Expand Down Expand Up @@ -77,7 +76,7 @@ protected void setUp() throws Exception {
new ReactTextViewManager(),
new ReactRawTextManager());
uiManager =
new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0);
new UIManagerModule(getContext(), viewManagers, 0);
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@

package com.facebook.react.tests;

import java.util.Arrays;
import java.util.List;

import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactIntegrationTestCase;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.testing.StringRecordingModule;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.modules.appstate.AppStateModule;
import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactIntegrationTestCase;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.testing.StringRecordingModule;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.view.ReactViewManager;
import java.util.Arrays;
import java.util.List;

/**
* Test locale-based functionality of JS VM
Expand All @@ -47,7 +45,6 @@ protected void setUp() throws Exception {
final UIManagerModule mUIManager = new UIManagerModule(
getContext(),
viewManagers,
new UIImplementationProvider(),
0);
UiThreadUtil.runOnUiThread(
new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactIntegrationTestCase;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.progressbar.ReactProgressBarViewManager;
Expand Down Expand Up @@ -68,7 +67,7 @@ protected void setUp() throws Exception {
new ReactViewManager(),
new ReactProgressBarViewManager());
mUIManager =
new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0);
new UIManagerModule(getContext(), viewManagers, 0);
UiThreadUtil.runOnUiThread(
new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.facebook.react.testing.ReactIntegrationTestCase;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.view.ReactViewGroup;
Expand Down Expand Up @@ -49,7 +48,7 @@ protected void setUp() throws Exception {

List<ViewManager> viewManagers = Arrays.<ViewManager>asList(new ReactViewManager());
final UIManagerModule uiManager =
new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0);
new UIManagerModule(getContext(), viewManagers, 0);
UiThreadUtil.runOnUiThread(
new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.facebook.react.modules.debug.SourceCodeModule;
import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
import com.facebook.react.modules.systeminfo.AndroidInfoModule;
import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.systrace.Systrace;
Expand Down Expand Up @@ -54,19 +53,16 @@

private final ReactInstanceManager mReactInstanceManager;
private final DefaultHardwareBackBtnHandler mHardwareBackBtnHandler;
private final UIImplementationProvider mUIImplementationProvider;
private final boolean mLazyViewManagersEnabled;
private final int mMinTimeLeftInFrameForNonBatchedOperationMs;

CoreModulesPackage(
ReactInstanceManager reactInstanceManager,
DefaultHardwareBackBtnHandler hardwareBackBtnHandler,
UIImplementationProvider uiImplementationProvider,
boolean lazyViewManagersEnabled,
int minTimeLeftInFrameForNonBatchedOperationMs) {
mReactInstanceManager = reactInstanceManager;
mHardwareBackBtnHandler = hardwareBackBtnHandler;
mUIImplementationProvider = uiImplementationProvider;
mLazyViewManagersEnabled = lazyViewManagersEnabled;
mMinTimeLeftInFrameForNonBatchedOperationMs = minTimeLeftInFrameForNonBatchedOperationMs;
}
Expand Down Expand Up @@ -165,13 +161,11 @@ public List<String> getViewManagerNames() {
return new UIManagerModule(
reactContext,
resolver,
mUIImplementationProvider,
mMinTimeLeftInFrameForNonBatchedOperationMs);
} else {
return new UIManagerModule(
reactContext,
mReactInstanceManager.getOrCreateViewManagers(reactContext),
mUIImplementationProvider,
mMinTimeLeftInFrameForNonBatchedOperationMs);
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@
import com.facebook.react.modules.debug.interfaces.DeveloperSettings;
import com.facebook.react.modules.fabric.ReactFabric;
import com.facebook.react.uimanager.DisplayMetricsHolder;
import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
import com.facebook.soloader.SoLoader;
import com.facebook.systrace.Systrace;
Expand Down Expand Up @@ -200,7 +198,6 @@ public static ReactInstanceManagerBuilder builder() {
boolean useDeveloperSupport,
@Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
LifecycleState initialLifecycleState,
UIImplementationProvider uiImplementationProvider,
NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
@Nullable RedBoxHandler redBoxHandler,
boolean lazyNativeModulesEnabled,
Expand Down Expand Up @@ -248,7 +245,6 @@ public void invokeDefaultOnBackPressed() {
ReactInstanceManager.this.invokeDefaultOnBackPressed();
}
},
uiImplementationProvider,
lazyViewManagersEnabled,
minTimeLeftInFrameForNonBatchedOperationMs));
if (mUseDeveloperSupport) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import android.app.Activity;
import android.app.Application;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.JSIModulePackage;
import com.facebook.react.bridge.JSBundleLoader;
import com.facebook.react.bridge.JSCJavaScriptExecutorFactory;
import com.facebook.react.bridge.JSIModulePackage;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener;
Expand All @@ -21,7 +21,6 @@
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.uimanager.UIImplementationProvider;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
Expand All @@ -40,7 +39,6 @@ public class ReactInstanceManagerBuilder {
private @Nullable Application mApplication;
private boolean mUseDeveloperSupport;
private @Nullable LifecycleState mInitialLifecycleState;
private @Nullable UIImplementationProvider mUIImplementationProvider;
private @Nullable NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler;
private @Nullable Activity mCurrentActivity;
private @Nullable DefaultHardwareBackBtnHandler mDefaultHardwareBackBtnHandler;
Expand All @@ -56,16 +54,6 @@ public class ReactInstanceManagerBuilder {
/* package protected */ ReactInstanceManagerBuilder() {
}

/**
* Sets a provider of {@link UIImplementation}.
* Uses default provider if null is passed.
*/
public ReactInstanceManagerBuilder setUIImplementationProvider(
@Nullable UIImplementationProvider uiImplementationProvider) {
mUIImplementationProvider = uiImplementationProvider;
return this;
}

public ReactInstanceManagerBuilder setJSIModulesPackage(
@Nullable JSIModulePackage jsiModulePackage) {
mJSIModulesPackage = jsiModulePackage;
Expand Down Expand Up @@ -251,11 +239,6 @@ public ReactInstanceManager build() {
mJSMainModulePath != null || mJSBundleAssetUrl != null || mJSBundleLoader != null,
"Either MainModulePath or JS Bundle File needs to be provided");

if (mUIImplementationProvider == null) {
// create default UIImplementationProvider if the provided one is null.
mUIImplementationProvider = new UIImplementationProvider();
}

// We use the name of the device and the app for debugging & metrics
String appName = mApplication.getPackageName();
String deviceName = getFriendlyDeviceName();
Expand All @@ -276,14 +259,13 @@ public ReactInstanceManager build() {
mUseDeveloperSupport,
mBridgeIdleDebugListener,
Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"),
mUIImplementationProvider,
mNativeModuleCallExceptionHandler,
mRedBoxHandler,
mLazyNativeModulesEnabled,
mLazyViewManagersEnabled,
mDevBundleDownloadListener,
mMinNumShakes,
mMinTimeLeftInFrameForNonBatchedOperationMs,
mJSIModulesPackage);
mJSIModulesPackage);
}
}
Loading

0 comments on commit 506f920

Please sign in to comment.