mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
Remove UIImplementationProvider class and refactor UIManagerModule
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
This commit is contained in:
parent
a373bf705d
commit
506f920838
@ -37,11 +37,10 @@ import com.facebook.react.modules.core.PermissionListener;
|
||||
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;
|
||||
@ -139,16 +138,11 @@ public class ReactAppTestActivity extends FragmentActivity
|
||||
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() {
|
||||
@ -165,23 +159,13 @@ public class ReactAppTestActivity extends FragmentActivity
|
||||
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);
|
||||
}
|
||||
|
||||
@ -217,14 +201,6 @@ public class ReactAppTestActivity extends FragmentActivity
|
||||
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();
|
||||
|
||||
@ -277,8 +253,7 @@ public class ReactAppTestActivity extends FragmentActivity
|
||||
};
|
||||
}
|
||||
});
|
||||
}})
|
||||
.setUIImplementationProvider(uiImplementationProvider);
|
||||
}});
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
runOnUiThread(new Runnable() {
|
||||
|
@ -29,7 +29,6 @@ import com.facebook.react.modules.systeminfo.AndroidInfoModule;
|
||||
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;
|
||||
@ -85,7 +84,7 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe
|
||||
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
|
||||
|
@ -21,7 +21,6 @@ import com.facebook.react.testing.AssertModule;
|
||||
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;
|
||||
@ -62,7 +61,7 @@ public class CatalystNativeJavaToJSArgumentsTestCase extends ReactIntegrationTes
|
||||
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
|
||||
|
@ -22,7 +22,6 @@ import com.facebook.react.testing.AssertModule;
|
||||
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;
|
||||
@ -112,7 +111,7 @@ public class CatalystNativeJavaToJSReturnValuesTestCase extends ReactIntegration
|
||||
|
||||
final UIManagerModule mUIManager =
|
||||
new UIManagerModule(
|
||||
getContext(), new ArrayList<ViewManager>(), new UIImplementationProvider(), 0);
|
||||
getContext(), new ArrayList<ViewManager>(), 0);
|
||||
|
||||
mAssertModule = new AssertModule();
|
||||
|
||||
|
@ -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.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;
|
||||
@ -77,7 +76,7 @@ public class CatalystUIManagerTestCase extends ReactIntegrationTestCase {
|
||||
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() {
|
||||
|
@ -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
|
||||
@ -47,7 +45,6 @@ public class JSLocaleTest extends ReactIntegrationTestCase {
|
||||
final UIManagerModule mUIManager = new UIManagerModule(
|
||||
getContext(),
|
||||
viewManagers,
|
||||
new UIImplementationProvider(),
|
||||
0);
|
||||
UiThreadUtil.runOnUiThread(
|
||||
new Runnable() {
|
||||
|
@ -24,7 +24,6 @@ import com.facebook.react.modules.systeminfo.AndroidInfoModule;
|
||||
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;
|
||||
@ -68,7 +67,7 @@ public class ProgressBarTestCase extends ReactIntegrationTestCase {
|
||||
new ReactViewManager(),
|
||||
new ReactProgressBarViewManager());
|
||||
mUIManager =
|
||||
new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0);
|
||||
new UIManagerModule(getContext(), viewManagers, 0);
|
||||
UiThreadUtil.runOnUiThread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
|
@ -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.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;
|
||||
@ -49,7 +48,7 @@ public class ViewRenderingTestCase extends ReactIntegrationTestCase {
|
||||
|
||||
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
|
||||
|
@ -26,7 +26,6 @@ import com.facebook.react.modules.core.Timing;
|
||||
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;
|
||||
@ -54,19 +53,16 @@ import javax.inject.Provider;
|
||||
|
||||
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;
|
||||
}
|
||||
@ -165,13 +161,11 @@ import javax.inject.Provider;
|
||||
return new UIManagerModule(
|
||||
reactContext,
|
||||
resolver,
|
||||
mUIImplementationProvider,
|
||||
mMinTimeLeftInFrameForNonBatchedOperationMs);
|
||||
} else {
|
||||
return new UIManagerModule(
|
||||
reactContext,
|
||||
mReactInstanceManager.getOrCreateViewManagers(reactContext),
|
||||
mUIImplementationProvider,
|
||||
mMinTimeLeftInFrameForNonBatchedOperationMs);
|
||||
}
|
||||
} finally {
|
||||
|
@ -79,10 +79,8 @@ import com.facebook.react.modules.core.ReactChoreographer;
|
||||
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;
|
||||
@ -200,7 +198,6 @@ public class ReactInstanceManager {
|
||||
boolean useDeveloperSupport,
|
||||
@Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
|
||||
LifecycleState initialLifecycleState,
|
||||
UIImplementationProvider uiImplementationProvider,
|
||||
NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
|
||||
@Nullable RedBoxHandler redBoxHandler,
|
||||
boolean lazyNativeModulesEnabled,
|
||||
@ -248,7 +245,6 @@ public class ReactInstanceManager {
|
||||
ReactInstanceManager.this.invokeDefaultOnBackPressed();
|
||||
}
|
||||
},
|
||||
uiImplementationProvider,
|
||||
lazyViewManagersEnabled,
|
||||
minTimeLeftInFrameForNonBatchedOperationMs));
|
||||
if (mUseDeveloperSupport) {
|
||||
|
@ -10,9 +10,9 @@ import static com.facebook.react.modules.systeminfo.AndroidInfoHelpers.getFriend
|
||||
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;
|
||||
@ -21,7 +21,6 @@ import com.facebook.react.devsupport.RedBoxHandler;
|
||||
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;
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -251,11 +239,6 @@ public class ReactInstanceManagerBuilder {
|
||||
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();
|
||||
@ -276,7 +259,6 @@ public class ReactInstanceManagerBuilder {
|
||||
mUseDeveloperSupport,
|
||||
mBridgeIdleDebugListener,
|
||||
Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"),
|
||||
mUIImplementationProvider,
|
||||
mNativeModuleCallExceptionHandler,
|
||||
mRedBoxHandler,
|
||||
mLazyNativeModulesEnabled,
|
||||
@ -284,6 +266,6 @@ public class ReactInstanceManagerBuilder {
|
||||
mDevBundleDownloadListener,
|
||||
mMinNumShakes,
|
||||
mMinTimeLeftInFrameForNonBatchedOperationMs,
|
||||
mJSIModulesPackage);
|
||||
mJSIModulesPackage);
|
||||
}
|
||||
}
|
||||
|
@ -7,20 +7,16 @@
|
||||
|
||||
package com.facebook.react;
|
||||
|
||||
import com.facebook.react.bridge.JSIModulePackage;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.JSIModulePackage;
|
||||
import com.facebook.react.bridge.JavaScriptExecutorFactory;
|
||||
import com.facebook.react.bridge.ReactMarker;
|
||||
import com.facebook.react.bridge.ReactMarkerConstants;
|
||||
import com.facebook.react.common.LifecycleState;
|
||||
import com.facebook.react.devsupport.RedBoxHandler;
|
||||
import com.facebook.react.uimanager.UIImplementationProvider;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Simple class that holds an instance of {@link ReactInstanceManager}. This can be used in your
|
||||
@ -74,7 +70,6 @@ public abstract class ReactNativeHost {
|
||||
.setUseDeveloperSupport(getUseDeveloperSupport())
|
||||
.setRedBoxHandler(getRedBoxHandler())
|
||||
.setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
|
||||
.setUIImplementationProvider(getUIImplementationProvider())
|
||||
.setJSIModulesPackage(getJSIModulePackage())
|
||||
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE);
|
||||
|
||||
@ -112,16 +107,6 @@ public abstract class ReactNativeHost {
|
||||
return mApplication;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link UIImplementationProvider} to use. Override this method if you want to use a
|
||||
* custom UI implementation.
|
||||
*
|
||||
* Note: this is very advanced functionality, in 99% of cases you don't need to override this.
|
||||
*/
|
||||
protected UIImplementationProvider getUIImplementationProvider() {
|
||||
return new UIImplementationProvider();
|
||||
}
|
||||
|
||||
protected @Nullable
|
||||
JSIModulePackage getJSIModulePackage() {
|
||||
return null;
|
||||
|
@ -1,40 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.events.EventDispatcher;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Provides UIImplementation to use in {@link UIManagerModule}.
|
||||
*/
|
||||
public class UIImplementationProvider {
|
||||
public UIImplementation createUIImplementation(
|
||||
ReactApplicationContext reactContext,
|
||||
UIManagerModule.ViewManagerResolver viewManagerResolver,
|
||||
EventDispatcher eventDispatcher,
|
||||
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
||||
return new UIImplementation(
|
||||
reactContext,
|
||||
viewManagerResolver,
|
||||
eventDispatcher,
|
||||
minTimeLeftInFrameForNonBatchedOperationMs);
|
||||
}
|
||||
|
||||
public UIImplementation createUIImplementation(
|
||||
ReactApplicationContext reactContext,
|
||||
List<ViewManager> viewManagerList,
|
||||
EventDispatcher eventDispatcher,
|
||||
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
||||
return new UIImplementation(
|
||||
reactContext,
|
||||
viewManagerList,
|
||||
eventDispatcher,
|
||||
minTimeLeftInFrameForNonBatchedOperationMs);
|
||||
}
|
||||
}
|
@ -124,7 +124,6 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
|
||||
public UIManagerModule(
|
||||
ReactApplicationContext reactContext,
|
||||
ViewManagerResolver viewManagerResolver,
|
||||
UIImplementationProvider uiImplementationProvider,
|
||||
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
||||
super(reactContext);
|
||||
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext);
|
||||
@ -132,7 +131,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
|
||||
mModuleConstants = createConstants(viewManagerResolver);
|
||||
mCustomDirectEvents = UIManagerModuleConstants.getDirectEventTypeConstants();
|
||||
mUIImplementation =
|
||||
uiImplementationProvider.createUIImplementation(
|
||||
new UIImplementation(
|
||||
reactContext,
|
||||
viewManagerResolver,
|
||||
mEventDispatcher,
|
||||
@ -144,7 +143,6 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
|
||||
public UIManagerModule(
|
||||
ReactApplicationContext reactContext,
|
||||
List<ViewManager> viewManagersList,
|
||||
UIImplementationProvider uiImplementationProvider,
|
||||
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
||||
super(reactContext);
|
||||
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext);
|
||||
@ -152,7 +150,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
|
||||
mCustomDirectEvents = MapBuilder.newHashMap();
|
||||
mModuleConstants = createConstants(viewManagersList, null, mCustomDirectEvents);
|
||||
mUIImplementation =
|
||||
uiImplementationProvider.createUIImplementation(
|
||||
new UIImplementation(
|
||||
reactContext,
|
||||
viewManagersList,
|
||||
mEventDispatcher,
|
||||
|
@ -141,7 +141,7 @@ public class ReactPropConstantsTest {
|
||||
List<ViewManager> viewManagers = Arrays.<ViewManager>asList(new ViewManagerUnderTest());
|
||||
ReactApplicationContext reactContext = new ReactApplicationContext(RuntimeEnvironment.application);
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0);
|
||||
new UIManagerModule(reactContext, viewManagers, 0);
|
||||
Map<String, String> constants =
|
||||
(Map) valueAtPath(uiManagerModule.getConstants(), "SomeView", "NativeProps");
|
||||
assertThat(constants).isEqualTo(
|
||||
|
@ -8,14 +8,11 @@
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.uimanager.events.EventDispatcher;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -49,25 +46,17 @@ public class UIManagerModuleConstantsTest {
|
||||
private static final Map TWIRL_DIRECT_EVENT_MAP = MapBuilder.of("registrationName", "onTwirl");
|
||||
|
||||
private ReactApplicationContext mReactContext;
|
||||
private UIImplementationProvider mUIImplementationProvider;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mReactContext = new ReactApplicationContext(RuntimeEnvironment.application);
|
||||
mUIImplementationProvider = mock(UIImplementationProvider.class);
|
||||
when(mUIImplementationProvider.createUIImplementation(
|
||||
any(ReactApplicationContext.class),
|
||||
any(List.class),
|
||||
any(EventDispatcher.class),
|
||||
anyInt()))
|
||||
.thenReturn(mock(UIImplementation.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCustomConstants() {
|
||||
List<ViewManager> viewManagers = Arrays.asList(mock(ViewManager.class));
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat(constants)
|
||||
.containsKey(CUSTOM_BUBBLING_EVENT_TYPES)
|
||||
@ -82,7 +71,7 @@ public class UIManagerModuleConstantsTest {
|
||||
when(mockViewManager.getExportedCustomBubblingEventTypeConstants())
|
||||
.thenReturn(MapBuilder.of("onTwirl", TWIRL_BUBBLING_EVENT_MAP));
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat((Map) constants.get(CUSTOM_BUBBLING_EVENT_TYPES))
|
||||
.contains(MapEntry.entry("onTwirl", TWIRL_BUBBLING_EVENT_MAP))
|
||||
@ -96,7 +85,7 @@ public class UIManagerModuleConstantsTest {
|
||||
when(mockViewManager.getExportedCustomDirectEventTypeConstants())
|
||||
.thenReturn(MapBuilder.of("onTwirl", TWIRL_DIRECT_EVENT_MAP));
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES))
|
||||
.contains(MapEntry.entry("onTwirl", TWIRL_DIRECT_EVENT_MAP))
|
||||
@ -111,7 +100,7 @@ public class UIManagerModuleConstantsTest {
|
||||
when(mockViewManager.getExportedViewConstants())
|
||||
.thenReturn(MapBuilder.of("PhotoSizeType", MapBuilder.of("Small", 1, "Large", 2)));
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat(constants).containsKey("RedPandaPhotoOfTheDayView");
|
||||
assertThat((Map) constants.get("RedPandaPhotoOfTheDayView")).containsKey("Constants");
|
||||
@ -127,7 +116,7 @@ public class UIManagerModuleConstantsTest {
|
||||
when(mockViewManager.getNativeProps())
|
||||
.thenReturn(MapBuilder.of("fooProp", "number"));
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat((String) valueAtPath(constants, "SomeView", "NativeProps", "fooProp"))
|
||||
.isEqualTo("number");
|
||||
@ -159,7 +148,7 @@ public class UIManagerModuleConstantsTest {
|
||||
|
||||
List<ViewManager> viewManagers = Arrays.asList(managerX, managerY);
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES)).containsKey("onTwirl");
|
||||
|
||||
|
@ -814,7 +814,7 @@ public class UIManagerModuleTest {
|
||||
new ReactTextViewManager(),
|
||||
new ReactRawTextManager());
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, new UIImplementationProvider(), 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
uiManagerModule.onHostResume();
|
||||
return uiManagerModule;
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactTestHelper;
|
||||
import com.facebook.react.modules.core.ChoreographerCompat;
|
||||
import com.facebook.react.modules.core.ReactChoreographer;
|
||||
import com.facebook.react.uimanager.UIImplementationProvider;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.facebook.react.uimanager.ViewProps;
|
||||
@ -428,7 +427,7 @@ public class ReactTextTest {
|
||||
new ReactRawTextManager(),
|
||||
});
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0);
|
||||
new UIManagerModule(reactContext, viewManagers, 0);
|
||||
uiManagerModule.onHostResume();
|
||||
return uiManagerModule;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactTestHelper;
|
||||
import com.facebook.react.modules.core.ChoreographerCompat;
|
||||
import com.facebook.react.modules.core.ReactChoreographer;
|
||||
import com.facebook.react.uimanager.UIImplementationProvider;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.facebook.react.uimanager.ViewProps;
|
||||
@ -178,7 +177,7 @@ public class TextInputTest {
|
||||
new ReactTextInputManager(),
|
||||
});
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0);
|
||||
new UIManagerModule(reactContext, viewManagers, 0);
|
||||
uiManagerModule.onHostResume();
|
||||
return uiManagerModule;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user