diff --git a/Libraries/ReactNative/UIManager.js b/Libraries/ReactNative/UIManager.js index d0fc85d4c..ed56fb626 100644 --- a/Libraries/ReactNative/UIManager.js +++ b/Libraries/ReactNative/UIManager.js @@ -79,13 +79,10 @@ if (Platform.OS === 'ios') { }); } }); -} else if ( - Platform.OS === 'android' && - UIManager.AndroidLazyViewManagersEnabled -) { +} else if (Platform.OS === 'android' && UIManager.ViewManagerNames) { UIManager.ViewManagerNames.forEach(viewManagerName => { defineLazyObjectProperty(UIManager, viewManagerName, { - get: () => NativeModules[viewManagerName.replace(/^(RCT|RK)/, '')], + get: () => UIManager.getConstantsForViewManager(viewManagerName), }); }); } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java index 180b35ba3..f5bf10746 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java @@ -86,7 +86,7 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe List viewManagers = Arrays.asList( new ReactViewManager()); final UIManagerModule mUIManager = - new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), false, 0); + new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0); UiThreadUtil.runOnUiThread( new Runnable() { @Override diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java index 6c0ef882a..6208e73a0 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java @@ -63,7 +63,7 @@ public class CatalystNativeJavaToJSArgumentsTestCase extends ReactIntegrationTes List viewManagers = Arrays.asList( new ReactViewManager()); final UIManagerModule mUIManager = - new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), false, 0); + new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0); UiThreadUtil.runOnUiThread( new Runnable() { @Override diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java index 7abce73a3..c47e8f261 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java @@ -113,7 +113,7 @@ public class CatalystNativeJavaToJSReturnValuesTestCase extends ReactIntegration final UIManagerModule mUIManager = new UIManagerModule( - getContext(), new ArrayList(), new UIImplementationProvider(), false, 0); + getContext(), new ArrayList(), new UIImplementationProvider(), 0); mAssertModule = new AssertModule(); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java index fba204bf0..c7de7b9ba 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java @@ -79,7 +79,7 @@ public class CatalystUIManagerTestCase extends ReactIntegrationTestCase { new ReactTextViewManager(), new ReactRawTextManager()); uiManager = - new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), false, 0); + new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0); UiThreadUtil.runOnUiThread(new Runnable() { @Override public void run() { diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java index d571438fb..7c87754e8 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java @@ -49,7 +49,6 @@ public class JSLocaleTest extends ReactIntegrationTestCase { getContext(), viewManagers, new UIImplementationProvider(), - false, 0); UiThreadUtil.runOnUiThread( new Runnable() { diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java index b4f1e5291..fdc03beaa 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java @@ -69,7 +69,7 @@ public class ProgressBarTestCase extends ReactIntegrationTestCase { new ReactViewManager(), new ReactProgressBarViewManager()); mUIManager = - new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), false, 0); + new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0); UiThreadUtil.runOnUiThread( new Runnable() { @Override diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java index 83119274f..42e0c75f0 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java @@ -50,7 +50,7 @@ public class ViewRenderingTestCase extends ReactIntegrationTestCase { List viewManagers = Arrays.asList(new ReactViewManager()); final UIManagerModule uiManager = - new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), false, 0); + new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0); UiThreadUtil.runOnUiThread( new Runnable() { @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java index e7695c8a5..2d9bdac57 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java @@ -9,23 +9,25 @@ package com.facebook.react; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; +import javax.annotation.Nullable; /** * {@code CompositeReactPackage} allows to create a single package composed of views and modules * from several other packages. */ -public class CompositeReactPackage extends ReactInstancePackage { +public class CompositeReactPackage extends ReactInstancePackage + implements ViewManagerOnDemandReactPackage { private final List mChildReactPackages = new ArrayList<>(); @@ -39,9 +41,7 @@ public class CompositeReactPackage extends ReactInstancePackage { mChildReactPackages.add(arg1); mChildReactPackages.add(arg2); - for (ReactPackage reactPackage: args) { - mChildReactPackages.add(reactPackage); - } + Collections.addAll(mChildReactPackages, args); } /** @@ -56,7 +56,7 @@ public class CompositeReactPackage extends ReactInstancePackage { moduleMap.put(nativeModule.getName(), nativeModule); } } - return new ArrayList(moduleMap.values()); + return new ArrayList<>(moduleMap.values()); } /** @@ -81,7 +81,7 @@ public class CompositeReactPackage extends ReactInstancePackage { moduleMap.put(nativeModule.getName(), nativeModule); } } - return new ArrayList(moduleMap.values()); + return new ArrayList<>(moduleMap.values()); } /** @@ -95,6 +95,44 @@ public class CompositeReactPackage extends ReactInstancePackage { viewManagerMap.put(viewManager.getName(), viewManager); } } - return new ArrayList(viewManagerMap.values()); + return new ArrayList<>(viewManagerMap.values()); + } + + /** + * {@inheritDoc} + */ + @Override + public List getViewManagerNames(ReactApplicationContext reactContext) { + Set uniqueNames = new HashSet<>(); + for (ReactPackage reactPackage : mChildReactPackages) { + if (reactPackage instanceof ViewManagerOnDemandReactPackage) { + List names = + ((ViewManagerOnDemandReactPackage) reactPackage).getViewManagerNames(reactContext); + if (names != null) { + uniqueNames.addAll(names); + } + } + } + return new ArrayList<>(uniqueNames); + } + + /** + * {@inheritDoc} + */ + @Override + public @Nullable ViewManager createViewManager( + ReactApplicationContext reactContext, String viewManagerName) { + ListIterator iterator = mChildReactPackages.listIterator(mChildReactPackages.size()); + while (iterator.hasPrevious()) { + ReactPackage reactPackage = iterator.previous(); + if (reactPackage instanceof ViewManagerOnDemandReactPackage) { + ViewManager viewManager = + ((ViewManagerOnDemandReactPackage) reactPackage).createViewManager(reactContext, viewManagerName); + if (viewManager != null) { + return viewManager; + } + } + } + return null; } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java index 56f823122..7f0386629 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java @@ -38,6 +38,7 @@ import com.facebook.react.uimanager.ViewManager; import com.facebook.systrace.Systrace; import java.util.ArrayList; import java.util.List; +import javax.annotation.Nullable; import javax.inject.Provider; /** * This module should be removed following the completion of an experiment into splitting this into @@ -183,18 +184,34 @@ import javax.inject.Provider; return LazyReactPackage.getReactModuleInfoProviderViaReflection(this); } - private UIManagerModule createUIManager(ReactApplicationContext reactContext) { + private UIManagerModule createUIManager(final ReactApplicationContext reactContext) { ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START); Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule"); try { - List viewManagersList = mReactInstanceManager.createAllViewManagers( - reactContext); - return new UIManagerModule( - reactContext, - viewManagersList, - mUIImplementationProvider, - mLazyViewManagersEnabled, - mMinTimeLeftInFrameForNonBatchedOperationMs); + if (mLazyViewManagersEnabled) { + UIManagerModule.ViewManagerResolver resolver = new UIManagerModule.ViewManagerResolver() { + @Override + public @Nullable ViewManager getViewManager(String viewManagerName) { + return mReactInstanceManager.createViewManager(viewManagerName); + } + @Override + public List getViewManagerNames() { + return mReactInstanceManager.getViewManagerNames(); + } + }; + + return new UIManagerModule( + reactContext, + resolver, + mUIImplementationProvider, + mMinTimeLeftInFrameForNonBatchedOperationMs); + } else { + return new UIManagerModule( + reactContext, + mReactInstanceManager.createAllViewManagers(reactContext), + mUIImplementationProvider, + mMinTimeLeftInFrameForNonBatchedOperationMs); + } } finally { Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END); diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 7d17f920c..c3328b4a4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -88,6 +88,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.annotation.Nullable; /** @@ -268,33 +269,32 @@ public class ReactInstanceManager { mMinTimeLeftInFrameForNonBatchedOperationMs = minTimeLeftInFrameForNonBatchedOperationMs; mUseSeparateUIBackgroundThread = useSeparateUIBackgroundThread; mMinNumShakes = minNumShakes; - - if (!splitPackagesEnabled) { - CoreModulesPackage coreModulesPackage = + synchronized (mPackages) { + if (!splitPackagesEnabled) { + CoreModulesPackage coreModulesPackage = new CoreModulesPackage( + this, + mBackBtnHandler, + mUIImplementationProvider, + mLazyViewManagersEnabled, + mMinTimeLeftInFrameForNonBatchedOperationMs); + mPackages.add(coreModulesPackage); + } else { + PrinterHolder.getPrinter().logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: Use Split Packages"); + mPackages.add(new BridgeCorePackage(this, mBackBtnHandler)); + if (mUseDeveloperSupport) { + mPackages.add(new DebugCorePackage()); + } + if (!useOnlyDefaultPackages) { + mPackages.add(new ReactNativeCorePackage( this, - mBackBtnHandler, mUIImplementationProvider, mLazyViewManagersEnabled, - mMinTimeLeftInFrameForNonBatchedOperationMs); - mPackages.add(coreModulesPackage); - } else { - PrinterHolder.getPrinter() - .logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: Use Split Packages"); - mPackages.add(new BridgeCorePackage(this, mBackBtnHandler)); - if (mUseDeveloperSupport) { - mPackages.add(new DebugCorePackage()); - } - if (!useOnlyDefaultPackages) { - mPackages.add( - new ReactNativeCorePackage( - this, - mUIImplementationProvider, - mLazyViewManagersEnabled, - mMinTimeLeftInFrameForNonBatchedOperationMs)); + mMinTimeLeftInFrameForNonBatchedOperationMs)); + } } + mPackages.addAll(packages); } - mPackages.addAll(packages); // Instantiate ReactChoreographer in UI thread. ReactChoreographer.initialize(); @@ -352,9 +352,11 @@ public class ReactInstanceManager { // CatalystInstance hasn't been created, so add packages for later evaluation if (!hasStartedCreatingInitialContext()) { - for (ReactPackage p : packages) { - if (!mPackages.contains(p)) { - mPackages.add(p); + synchronized (mPackages) { + for (ReactPackage p : packages) { + if (!mPackages.contains(p)) { + mPackages.add(p); + } } } return; @@ -771,17 +773,55 @@ public class ReactInstanceManager { ReactMarker.logMarker(CREATE_VIEW_MANAGERS_START); Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createAllViewManagers"); try { - List allViewManagers = new ArrayList<>(); - for (ReactPackage reactPackage : mPackages) { - allViewManagers.addAll(reactPackage.createViewManagers(catalystApplicationContext)); + synchronized (mPackages) { + List allViewManagers = new ArrayList<>(); + for (ReactPackage reactPackage : mPackages) { + allViewManagers.addAll(reactPackage.createViewManagers(catalystApplicationContext)); + } + return allViewManagers; } - return allViewManagers; } finally { Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); ReactMarker.logMarker(CREATE_VIEW_MANAGERS_END); } } + public @Nullable ViewManager createViewManager(String viewManagerName) { + ReactApplicationContext context = + Assertions.assertNotNull((ReactApplicationContext) getCurrentReactContext()); + synchronized (mPackages) { + for (ReactPackage reactPackage : mPackages) { + if (reactPackage instanceof ViewManagerOnDemandReactPackage) { + ViewManager viewManager = + ((ViewManagerOnDemandReactPackage) reactPackage) + .createViewManager(context, viewManagerName); + if (viewManager != null) { + return viewManager; + } + } + } + } + return null; + } + + public List getViewManagerNames() { + ReactApplicationContext context = + Assertions.assertNotNull((ReactApplicationContext) getCurrentReactContext()); + synchronized (mPackages) { + Set uniqueNames = new HashSet<>(); + for (ReactPackage reactPackage : mPackages) { + if (reactPackage instanceof ViewManagerOnDemandReactPackage) { + List names = + ((ViewManagerOnDemandReactPackage) reactPackage).getViewManagerNames(context); + if (names != null) { + uniqueNames.addAll(names); + } + } + } + return new ArrayList<>(uniqueNames); + } + } + /** * Add a listener to be notified of react instance events. */ @@ -1108,20 +1148,20 @@ public class ReactInstanceManager { ReactMarker.logMarker(PROCESS_PACKAGES_START); // TODO(6818138): Solve use-case of native modules overriding - for (ReactPackage reactPackage : packages) { - if (checkAndUpdatePackageMembership && mPackages.contains(reactPackage)) { - continue; - } - Systrace.beginSection( - TRACE_TAG_REACT_JAVA_BRIDGE, - "createAndProcessCustomReactPackage"); - try { - if (checkAndUpdatePackageMembership) { - mPackages.add(reactPackage); + synchronized (mPackages) { + for (ReactPackage reactPackage : packages) { + if (checkAndUpdatePackageMembership && mPackages.contains(reactPackage)) { + continue; + } + Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createAndProcessCustomReactPackage"); + try { + if (checkAndUpdatePackageMembership) { + mPackages.add(reactPackage); + } + processPackage(reactPackage, nativeModuleRegistryBuilder); + } finally { + Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); } - processPackage(reactPackage, nativeModuleRegistryBuilder); - } finally { - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); } } ReactMarker.logMarker(PROCESS_PACKAGES_END); diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactNativeCorePackage.java b/ReactAndroid/src/main/java/com/facebook/react/ReactNativeCorePackage.java index 20ecfabca..3149f1a7a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactNativeCorePackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactNativeCorePackage.java @@ -24,6 +24,7 @@ import com.facebook.react.uimanager.ViewManager; import com.facebook.systrace.Systrace; import java.util.ArrayList; import java.util.List; +import javax.annotation.Nullable; import javax.inject.Provider; /** @@ -77,18 +78,36 @@ public class ReactNativeCorePackage extends LazyReactPackage { return reactModuleInfoProvider; } - private UIManagerModule createUIManager(ReactApplicationContext reactContext) { + private UIManagerModule createUIManager(final ReactApplicationContext reactContext) { ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START); Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule"); try { - List viewManagersList = mReactInstanceManager.createAllViewManagers( - reactContext); - return new UIManagerModule( - reactContext, - viewManagersList, - mUIImplementationProvider, - mLazyViewManagersEnabled, - mMinTimeLeftInFrameForNonBatchedOperationMs); + if (mLazyViewManagersEnabled) { + UIManagerModule.ViewManagerResolver viewManagerResolver = + new UIManagerModule.ViewManagerResolver() { + @Override + public @Nullable ViewManager getViewManager(String viewManagerName) { + return mReactInstanceManager.createViewManager(viewManagerName); + } + + @Override + public List getViewManagerNames() { + return mReactInstanceManager.getViewManagerNames(); + } + }; + + return new UIManagerModule( + reactContext, + viewManagerResolver, + mUIImplementationProvider, + mMinTimeLeftInFrameForNonBatchedOperationMs); + } else { + return new UIManagerModule( + reactContext, + mReactInstanceManager.createAllViewManagers(reactContext), + mUIImplementationProvider, + mMinTimeLeftInFrameForNonBatchedOperationMs); + } } finally { Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END); diff --git a/ReactAndroid/src/main/java/com/facebook/react/ViewManagerOnDemandReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/ViewManagerOnDemandReactPackage.java new file mode 100644 index 000000000..0abf83568 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/ViewManagerOnDemandReactPackage.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +package com.facebook.react; + +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.uimanager.ViewManager; +import java.util.List; +import javax.annotation.Nullable; + +public interface ViewManagerOnDemandReactPackage { + /** + * Provides a list of names of ViewManagers with which these modules can be accessed from JS. + * Typically, this is ViewManager.getName(). + */ + List getViewManagerNames(ReactApplicationContext reactContext); + /** + * Creates and returns a ViewManager with a specific name {@param viewManagerName}. It's up to + * an implementing package how to interpret the name. + */ + @Nullable ViewManager createViewManager(ReactApplicationContext reactContext, String viewManagerName); +} diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementationProvider.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementationProvider.java index b533beceb..912d19f6d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementationProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementationProvider.java @@ -11,6 +11,7 @@ package com.facebook.react.flat; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.UIImplementationProvider; +import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.events.EventDispatcher; import java.util.List; @@ -43,4 +44,14 @@ public final class FlatUIImplementationProvider extends UIImplementationProvider mMemoryImprovementEnabled, minTimeLeftInFrameForNonBatchedOperationMs); } + + @Override + public FlatUIImplementation createUIImplementation( + ReactApplicationContext reactContext, + UIManagerModule.ViewManagerResolver viewManagerResolver, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + throw new UnsupportedOperationException( + "Lazy version of FlatUIImplementations are not supported"); + } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index 0a90afd38..8dc1f37c8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -55,6 +55,18 @@ public class UIImplementation { private long mLastCalculateLayoutTime = 0; + public UIImplementation( + ReactApplicationContext reactContext, + UIManagerModule.ViewManagerResolver viewManagerResolver, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + this( + reactContext, + new ViewManagerRegistry(viewManagerResolver), + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + } + public UIImplementation( ReactApplicationContext reactContext, List viewManagers, diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java index 520095bc7..305519af9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java @@ -18,10 +18,25 @@ import java.util.List; public class UIImplementationProvider { public UIImplementation createUIImplementation( ReactApplicationContext reactContext, - List viewManagers, + UIManagerModule.ViewManagerResolver viewManagerResolver, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) { return new UIImplementation( - reactContext, viewManagers, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs); + reactContext, + viewManagerResolver, + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + } + + public UIImplementation createUIImplementation( + ReactApplicationContext reactContext, + List viewManagerList, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + return new UIImplementation( + reactContext, + viewManagerList, + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 3a345dec1..f2982d892 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -17,7 +17,9 @@ import android.content.res.Configuration; import com.facebook.common.logging.FLog; import com.facebook.debug.holder.PrinterHolder; import com.facebook.debug.tags.ReactDebugOverlayTags; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.animation.Animation; +import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.GuardedRunnable; import com.facebook.react.bridge.LifecycleEventListener; @@ -29,6 +31,7 @@ import com.facebook.react.bridge.ReactMarker; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.bridge.WritableMap; import com.facebook.react.common.ReactConstants; import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener; @@ -72,6 +75,21 @@ import javax.annotation.Nullable; public class UIManagerModule extends ReactContextBaseJavaModule implements OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter { + /** + * Enables lazy discovery of a specific {@link ViewManager} by its name. + */ + public interface ViewManagerResolver { + /** + * {@class UIManagerModule} class uses this method to get a ViewManager by its name. + * This is the same name that comes from JS by {@code UIManager.ViewManagerName} call. + */ + @Nullable ViewManager getViewManager(String viewManagerName); + + /** + * Provides a list of view manager names to register in JS as {@code UIManager.ViewManagerName} + */ + List getViewManagerNames(); + } /** * Resolves a name coming from native side to a name of the event that is exposed to JS. @@ -90,6 +108,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements private final EventDispatcher mEventDispatcher; private final Map mModuleConstants; + private final Map mCustomDirectEvents; private final UIImplementation mUIImplementation; private final MemoryTrimCallback mMemoryTrimCallback = new MemoryTrimCallback(); @@ -97,24 +116,45 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements public UIManagerModule( ReactApplicationContext reactContext, - List viewManagerList, + ViewManagerResolver viewManagerResolver, UIImplementationProvider uiImplementationProvider, - boolean lazyViewManagersEnabled, int minTimeLeftInFrameForNonBatchedOperationMs) { super(reactContext); DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext); mEventDispatcher = new EventDispatcher(reactContext); - mModuleConstants = createConstants(viewManagerList, lazyViewManagersEnabled); + mModuleConstants = createConstants(viewManagerResolver); + mCustomDirectEvents = UIManagerModuleConstants.getDirectEventTypeConstants(); mUIImplementation = uiImplementationProvider.createUIImplementation( reactContext, - viewManagerList, + viewManagerResolver, mEventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs); reactContext.addLifecycleEventListener(this); } + public UIManagerModule( + ReactApplicationContext reactContext, + List viewManagersList, + UIImplementationProvider uiImplementationProvider, + int minTimeLeftInFrameForNonBatchedOperationMs) { + super(reactContext); + DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext); + mEventDispatcher = new EventDispatcher(reactContext); + mModuleConstants = createConstants(viewManagersList); + mCustomDirectEvents = + (Map) mModuleConstants.get( + UIManagerModuleConstantsHelper.CUSTOM_DIRECT_EVENTS_KEY); + mUIImplementation = + uiImplementationProvider.createUIImplementation( + reactContext, + viewManagersList, + mEventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + + reactContext.addLifecycleEventListener(this); + } /** * This method gives an access to the {@link UIImplementation} object that can be used to execute * operations on the view hierarchy. @@ -163,21 +203,55 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements ViewManagerPropertyUpdater.clear(); } - private static Map createConstants( - List viewManagerList, - boolean lazyViewManagersEnabled) { + private static Map createConstants(ViewManagerResolver viewManagerResolver) { ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START); Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants"); try { - return UIManagerModuleConstantsHelper.createConstants( - viewManagerList, - lazyViewManagersEnabled); + return UIManagerModuleConstantsHelper.createConstants(viewManagerResolver); } finally { Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END); } } + private static Map createConstants(List viewManagers) { + ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START); + Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants"); + try { + return UIManagerModuleConstantsHelper.createConstants(viewManagers); + } finally { + Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END); + } + } + + @DoNotStrip + @ReactMethod(isBlockingSynchronousMethod = true) + public @Nullable WritableMap getConstantsForViewManager(final String viewManagerName) { + ViewManager targetView = + viewManagerName != null ? mUIImplementation.resolveViewManager(viewManagerName) : null; + if (targetView == null) { + return null; + } + + SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "constants for ViewManager") + .arg("ViewManager", targetView.getName()) + .arg("Lazy", true) + .flush(); + try { + Map viewManagerConstants = + UIManagerModuleConstantsHelper.createConstantsForViewManager( + targetView, + UIManagerModuleConstants.getBubblingEventTypeConstants(), + UIManagerModuleConstants.getDirectEventTypeConstants(), + null, + mCustomDirectEvents); + return viewManagerConstants != null ? Arguments.makeNativeMap(viewManagerConstants) : null; + } finally { + SystraceMessage.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + } + } + /** * Resolves Direct Event name exposed to JS from the one known to the Native side. */ @@ -185,14 +259,10 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements return new CustomEventNamesResolver() { @Override public @Nullable String resolveCustomEventName(String eventName) { - Map directEventTypes = - (Map) getConstants().get( - UIManagerModuleConstantsHelper.CUSTOM_DIRECT_EVENT_TYPES_KEY); - if (directEventTypes != null) { - Map customEventType = (Map) directEventTypes.get(eventName); - if (customEventType != null) { - return customEventType.get("registrationName"); - } + Map customEventType = + (Map) mCustomDirectEvents.get(eventName); + if (customEventType != null) { + return customEventType.get("registrationName"); } return eventName; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java index 905b3f669..d9b742da0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java @@ -9,14 +9,14 @@ package com.facebook.react.uimanager; -import java.util.List; -import java.util.Map; +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; import com.facebook.react.common.MapBuilder; import com.facebook.systrace.Systrace; import com.facebook.systrace.SystraceMessage; - -import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; /** * Helps generate constants map for {@link UIManagerModule} by collecting and merging constants from @@ -24,8 +24,22 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; */ /* package */ class UIManagerModuleConstantsHelper { - /* package */ static final String CUSTOM_BUBBLING_EVENT_TYPES_KEY = "customBubblingEventTypes"; - /* package */ static final String CUSTOM_DIRECT_EVENT_TYPES_KEY = "customDirectEventTypes"; + /* package */ static final String CUSTOM_BUBBLING_EVENTS_KEY = "customBubblingEventTypes"; + /* package */ static final String CUSTOM_DIRECT_EVENTS_KEY = "customDirectEventTypes"; + + /** + * Generates a lazy discovery enabled version of {@link UIManagerModule} constants. It only + * contains a list of view manager names, so that JS side is aware of the managers there are. + * Actual ViewManager instantiation happens when {@code UIManager.SpecificViewManager} call happens. + * The View Manager is then registered on the JS side with the help of + * {@code UIManagerModule.getConstantsForViewManager}. + */ + /* package */ static Map createConstants( + UIManagerModule.ViewManagerResolver resolver) { + Map constants = UIManagerModuleConstants.getConstants(); + constants.put("ViewManagerNames", resolver.getViewManagerNames()); + return constants; + } /** * Generates map of constants that is then exposed by {@link UIManagerModule}. @@ -39,8 +53,7 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; * {@link UIManagerModuleConstants}. * TODO(6845124): Create a test for this */ - /* package */ static Map createConstants( - List viewManagers, boolean lazyViewManagersEnabled) { + /* package */ static Map createConstants(List viewManagers) { Map constants = UIManagerModuleConstants.getConstants(); // Generic/default event types: @@ -58,43 +71,22 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; allDirectEventTypes.putAll(genericDirectEventTypes); for (ViewManager viewManager : viewManagers) { + final String viewManagerName = viewManager.getName(); + SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "constants for ViewManager") - .arg("ViewManager", viewManager.getName()) - .flush(); + .arg("ViewManager", viewManagerName) + .arg("Lazy", false) + .flush(); + try { - Map viewManagerConstants = MapBuilder.newHashMap(); - Map viewManagerBubblingEvents = viewManager.getExportedCustomBubblingEventTypeConstants(); - if (viewManagerBubblingEvents != null) { - recursiveMerge(allBubblingEventTypes, viewManagerBubblingEvents); - recursiveMerge(viewManagerBubblingEvents, genericBubblingEventTypes); - } else { - viewManagerBubblingEvents = genericBubblingEventTypes; - } - viewManagerConstants.put("bubblingEventTypes", viewManagerBubblingEvents); - - Map viewManagerDirectEvents = viewManager.getExportedCustomDirectEventTypeConstants(); - if (viewManagerDirectEvents != null) { - recursiveMerge(allDirectEventTypes, viewManagerDirectEvents); - recursiveMerge(viewManagerDirectEvents, genericDirectEventTypes); - } else { - viewManagerDirectEvents = genericDirectEventTypes; - } - viewManagerConstants.put("directEventTypes", viewManagerDirectEvents); - - Map customViewConstants = viewManager.getExportedViewConstants(); - if (customViewConstants != null) { - viewManagerConstants.put("Constants", customViewConstants); - } - Map viewManagerCommands = viewManager.getCommandsMap(); - if (viewManagerCommands != null) { - viewManagerConstants.put("Commands", viewManagerCommands); - } - Map viewManagerNativeProps = viewManager.getNativeProps(); - if (!viewManagerNativeProps.isEmpty()) { - viewManagerConstants.put("NativeProps", viewManagerNativeProps); - } + Map viewManagerConstants = createConstantsForViewManager( + viewManager, + genericBubblingEventTypes, + genericDirectEventTypes, + allBubblingEventTypes, + allDirectEventTypes); if (!viewManagerConstants.isEmpty()) { - constants.put(viewManager.getName(), viewManagerConstants); + constants.put(viewManagerName, viewManagerConstants); } } finally { Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); @@ -102,13 +94,57 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; } // Used by https://fburl.com/6nskr82o - constants.put(CUSTOM_BUBBLING_EVENT_TYPES_KEY, allBubblingEventTypes); - constants.put(CUSTOM_DIRECT_EVENT_TYPES_KEY, allDirectEventTypes); - constants.put("AndroidLazyViewManagersEnabled", lazyViewManagersEnabled); - + constants.put(CUSTOM_BUBBLING_EVENTS_KEY, allBubblingEventTypes); + constants.put(CUSTOM_DIRECT_EVENTS_KEY, allDirectEventTypes); return constants; } + /* package */ static Map createConstantsForViewManager( + ViewManager viewManager, + Map defaultBubblingEvents, + Map defaultDirectEvents, + @Nullable Map cumulativeBubblingEventTypes, + @Nullable Map cumulativeDirectEventTypes) { + Map viewManagerConstants = MapBuilder.newHashMap(); + + Map viewManagerBubblingEvents = viewManager.getExportedCustomBubblingEventTypeConstants(); + if (viewManagerBubblingEvents != null) { + if (cumulativeBubblingEventTypes != null) { + recursiveMerge(cumulativeBubblingEventTypes, viewManagerBubblingEvents); + } + recursiveMerge(viewManagerBubblingEvents, defaultBubblingEvents); + } else { + viewManagerBubblingEvents = defaultBubblingEvents; + } + viewManagerConstants.put("bubblingEventTypes", viewManagerBubblingEvents); + + Map viewManagerDirectEvents = viewManager.getExportedCustomDirectEventTypeConstants(); + if (viewManagerDirectEvents != null) { + if (cumulativeDirectEventTypes != null) { + recursiveMerge(cumulativeDirectEventTypes, viewManagerBubblingEvents); + } + recursiveMerge(viewManagerDirectEvents, defaultDirectEvents); + } else { + viewManagerDirectEvents = defaultDirectEvents; + } + viewManagerConstants.put("directEventTypes", viewManagerDirectEvents); + + Map customViewConstants = viewManager.getExportedViewConstants(); + if (customViewConstants != null) { + viewManagerConstants.put("Constants", customViewConstants); + } + Map viewManagerCommands = viewManager.getCommandsMap(); + if (viewManagerCommands != null) { + viewManagerConstants.put("Commands", viewManagerCommands); + } + Map viewManagerNativeProps = viewManager.getNativeProps(); + if (!viewManagerNativeProps.isEmpty()) { + viewManagerConstants.put("NativeProps", viewManagerNativeProps); + } + + return viewManagerConstants; + } + /** * Merges {@param source} map into {@param dest} map recursively */ diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerRegistry.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerRegistry.java index e8eb822eb..66559f9e7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerRegistry.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerRegistry.java @@ -9,35 +9,53 @@ package com.facebook.react.uimanager; -import java.util.HashMap; +import com.facebook.react.common.MapBuilder; import java.util.List; import java.util.Map; +import javax.annotation.Nullable; /** * Class that stores the mapping between native view name used in JS and the corresponding instance * of {@link ViewManager}. */ -public class ViewManagerRegistry { +public final class ViewManagerRegistry { private final Map mViewManagers; + private final @Nullable UIManagerModule.ViewManagerResolver mViewManagerResolver; + + public ViewManagerRegistry(UIManagerModule.ViewManagerResolver viewManagerResolver) { + mViewManagers = MapBuilder.newHashMap(); + mViewManagerResolver = viewManagerResolver; + } public ViewManagerRegistry(List viewManagerList) { - mViewManagers = new HashMap<>(); + Map viewManagerMap = MapBuilder.newHashMap(); for (ViewManager viewManager : viewManagerList) { - mViewManagers.put(viewManager.getName(), viewManager); + viewManagerMap.put(viewManager.getName(), viewManager); } + + mViewManagers = viewManagerMap; + mViewManagerResolver = null; } public ViewManagerRegistry(Map viewManagerMap) { - mViewManagers = viewManagerMap; + mViewManagers = + viewManagerMap != null ? viewManagerMap : MapBuilder.newHashMap(); + mViewManagerResolver = null; } public ViewManager get(String className) { ViewManager viewManager = mViewManagers.get(className); if (viewManager != null) { return viewManager; - } else { - throw new IllegalViewOperationException("No ViewManager defined for class " + className); } + if (mViewManagerResolver != null) { + viewManager = mViewManagerResolver.getViewManager(className); + if (viewManager != null) { + mViewManagers.put(className, viewManager); + return viewManager; + } + } + throw new IllegalViewOperationException("No ViewManager defined for class " + className); } } diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java index 90c06a605..2c849051e 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java @@ -143,7 +143,7 @@ public class ReactPropConstantsTest { List viewManagers = Arrays.asList(new ViewManagerUnderTest()); ReactApplicationContext reactContext = new ReactApplicationContext(RuntimeEnvironment.application); UIManagerModule uiManagerModule = - new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), false, 0); + new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0); Map constants = (Map) valueAtPath(uiManagerModule.getConstants(), "SomeView", "NativeProps"); assertThat(constants).isEqualTo( diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java index 8e1e4596a..687440a1d 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java @@ -69,7 +69,7 @@ public class UIManagerModuleConstantsTest { public void testNoCustomConstants() { List viewManagers = Arrays.asList(mock(ViewManager.class)); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0); + new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); Map constants = uiManagerModule.getConstants(); assertThat(constants) .containsKey(CUSTOM_BUBBLING_EVENT_TYPES) @@ -84,7 +84,7 @@ public class UIManagerModuleConstantsTest { when(mockViewManager.getExportedCustomBubblingEventTypeConstants()) .thenReturn(MapBuilder.of("onTwirl", TWIRL_BUBBLING_EVENT_MAP)); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0); + new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); Map constants = uiManagerModule.getConstants(); assertThat((Map) constants.get(CUSTOM_BUBBLING_EVENT_TYPES)) .contains(MapEntry.entry("onTwirl", TWIRL_BUBBLING_EVENT_MAP)) @@ -98,7 +98,7 @@ public class UIManagerModuleConstantsTest { when(mockViewManager.getExportedCustomDirectEventTypeConstants()) .thenReturn(MapBuilder.of("onTwirl", TWIRL_DIRECT_EVENT_MAP)); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0); + new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); Map constants = uiManagerModule.getConstants(); assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES)) .contains(MapEntry.entry("onTwirl", TWIRL_DIRECT_EVENT_MAP)) @@ -113,7 +113,7 @@ public class UIManagerModuleConstantsTest { when(mockViewManager.getExportedViewConstants()) .thenReturn(MapBuilder.of("PhotoSizeType", MapBuilder.of("Small", 1, "Large", 2))); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0); + new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); Map constants = uiManagerModule.getConstants(); assertThat(constants).containsKey("RedPandaPhotoOfTheDayView"); assertThat((Map) constants.get("RedPandaPhotoOfTheDayView")).containsKey("Constants"); @@ -129,7 +129,7 @@ public class UIManagerModuleConstantsTest { when(mockViewManager.getNativeProps()) .thenReturn(MapBuilder.of("fooProp", "number")); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0); + new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); Map constants = uiManagerModule.getConstants(); assertThat((String) valueAtPath(constants, "SomeView", "NativeProps", "fooProp")) .isEqualTo("number"); @@ -161,7 +161,7 @@ public class UIManagerModuleConstantsTest { List viewManagers = Arrays.asList(managerX, managerY); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0); + new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); Map constants = uiManagerModule.getConstants(); assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES)).containsKey("onTwirl"); diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java index 0dc5a25ce..70bfac8f3 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java @@ -816,7 +816,7 @@ public class UIManagerModuleTest { new ReactTextViewManager(), new ReactRawTextManager()); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, new UIImplementationProvider(), false, 0); + new UIManagerModule(mReactContext, viewManagers, new UIImplementationProvider(), 0); uiManagerModule.onHostResume(); return uiManagerModule; } diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java index 49755d2cc..7e5765d06 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java @@ -430,7 +430,7 @@ public class ReactTextTest { new ReactRawTextManager(), }); UIManagerModule uiManagerModule = - new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), false, 0); + new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0); uiManagerModule.onHostResume(); return uiManagerModule; } diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java index 235bb875a..ae5a7d90f 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java @@ -180,7 +180,7 @@ public class TextInputTest { new ReactTextInputManager(), }); UIManagerModule uiManagerModule = - new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), false, 0); + new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0); uiManagerModule.onHostResume(); return uiManagerModule; }