Fix Nodes not having correct view managers externally

Reviewed By: ahmedre

Differential Revision: D4927963

fbshipit-source-id: f4993aa45f6313e814d03141f828d37eafade059
This commit is contained in:
Seth Kirby
2017-04-27 15:35:24 -07:00
committed by Facebook Github Bot
parent 6272ef87bc
commit c8bb422882
14 changed files with 207 additions and 143 deletions

View File

@@ -9,26 +9,26 @@
package com.facebook.react.flat;
import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaNode;
import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.views.art.ARTSurfaceView;
import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaNode;
public class FlatARTSurfaceViewManager extends
BaseViewManager<ARTSurfaceView, FlatARTSurfaceViewShadowNode> {
BaseViewManager<ARTSurfaceView, FlatARTSurfaceViewShadowNode> {
private static final String REACT_CLASS = "ARTSurfaceView";
/* package */ static final String REACT_CLASS = "ARTSurfaceView";
private static final YogaMeasureFunction MEASURE_FUNCTION = new YogaMeasureFunction() {
@Override
public long measure(
YogaNode node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode) {
YogaNode node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode) {
throw new IllegalStateException("SurfaceView should have explicit width and height set");
}
};

View File

@@ -9,11 +9,6 @@
package com.facebook.react.flat;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
@@ -28,6 +23,12 @@ import com.facebook.react.uimanager.ViewManagerRegistry;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.yoga.YogaDirection;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* FlatUIImplementation builds on top of UIImplementation and allows pre-creating everything
* required for drawing (DrawCommands) and touching (NodeRegions) views in background thread
@@ -35,15 +36,66 @@ import com.facebook.yoga.YogaDirection;
*/
public class FlatUIImplementation extends UIImplementation {
private static final Map<String, Class<? extends ViewManager>> flatManagerClassMap;
static {
flatManagerClassMap = new HashMap<>();
flatManagerClassMap.put(RCTViewManager.REACT_CLASS, RCTViewManager.class);
flatManagerClassMap.put(RCTTextManager.REACT_CLASS, RCTTextManager.class);
flatManagerClassMap.put(RCTRawTextManager.REACT_CLASS, RCTRawTextManager.class);
flatManagerClassMap.put(RCTVirtualTextManager.REACT_CLASS, RCTVirtualTextManager.class);
flatManagerClassMap.put(RCTTextInlineImageManager.REACT_CLASS, RCTTextInlineImageManager.class);
flatManagerClassMap.put(RCTImageViewManager.REACT_CLASS, RCTImageViewManager.class);
flatManagerClassMap.put(RCTTextInputManager.REACT_CLASS, RCTTextInputManager.class);
flatManagerClassMap.put(RCTViewPagerManager.REACT_CLASS, RCTViewPagerManager.class);
flatManagerClassMap.put(FlatARTSurfaceViewManager.REACT_CLASS, FlatARTSurfaceViewManager.class);
flatManagerClassMap.put(RCTModalHostManager.REACT_CLASS, RCTModalHostManager.class);
}
/**
* Build the map of view managers, checking that the managers FlatUI requires are correctly
* overriden.
*/
private static Map<String, ViewManager> buildViewManagerMap(List<ViewManager> viewManagers) {
Map<String, ViewManager> viewManagerMap = new HashMap<>();
for (ViewManager viewManager : viewManagers) {
viewManagerMap.put(viewManager.getName(), viewManager);
}
for (Map.Entry<String, Class<? extends ViewManager>> entry : flatManagerClassMap.entrySet()) {
String name = entry.getKey();
ViewManager maybeFlatViewManager = viewManagerMap.get(name);
if (maybeFlatViewManager == null) {
// We don't have a view manager for this name in the package, no need to add one.
continue;
}
Class<? extends ViewManager> flatClazz = entry.getValue();
if (maybeFlatViewManager.getClass() != flatClazz) {
// If we have instances that have flat equivalents, override them.
try {
viewManagerMap.put(name, flatClazz.newInstance());
} catch (IllegalAccessException e) {
throw new RuntimeException("Unable to access flat class for " + name, e);
} catch (InstantiationException e) {
throw new RuntimeException("Unable to instantiate flat class for " + name, e);
}
}
}
return viewManagerMap;
}
public static FlatUIImplementation createInstance(
ReactApplicationContext reactContext,
List<ViewManager> viewManagers,
EventDispatcher eventDispatcher,
boolean memoryImprovementEnabled) {
RCTImageViewManager rctImageViewManager = findRCTImageManager(viewManagers);
if (rctImageViewManager != null) {
Object callerContext = rctImageViewManager.getCallerContext();
Map<String, ViewManager> viewManagerMap = buildViewManagerMap(viewManagers);
RCTImageViewManager imageViewManager =
(RCTImageViewManager) viewManagerMap.get(RCTImageViewManager.REACT_CLASS);
if (imageViewManager != null) {
Object callerContext = imageViewManager.getCallerContext();
if (callerContext != null) {
RCTImageView.setCallerContext(callerContext);
}
@@ -52,15 +104,15 @@ public class FlatUIImplementation extends UIImplementation {
TypefaceCache.setAssetManager(reactContext.getAssets());
ViewManagerRegistry viewManagerRegistry = new ViewManagerRegistry(viewManagers);
ViewManagerRegistry viewManagerRegistry = new ViewManagerRegistry(viewManagerMap);
FlatNativeViewHierarchyManager nativeViewHierarchyManager = new FlatNativeViewHierarchyManager(
viewManagerRegistry);
viewManagerRegistry);
FlatUIViewOperationQueue operationsQueue = new FlatUIViewOperationQueue(
reactContext,
nativeViewHierarchyManager);
reactContext,
nativeViewHierarchyManager);
return new FlatUIImplementation(
reactContext,
rctImageViewManager,
imageViewManager,
viewManagerRegistry,
operationsQueue,
eventDispatcher,
@@ -126,9 +178,9 @@ public class FlatUIImplementation extends UIImplementation {
@Override
protected void handleCreateView(
ReactShadowNode cssNode,
int rootViewTag,
@Nullable ReactStylesDiffMap styles) {
ReactShadowNode cssNode,
int rootViewTag,
@Nullable ReactStylesDiffMap styles) {
if (cssNode instanceof FlatShadowNode) {
FlatShadowNode node = (FlatShadowNode) cssNode;
@@ -146,9 +198,9 @@ public class FlatUIImplementation extends UIImplementation {
@Override
protected void handleUpdateView(
ReactShadowNode cssNode,
String className,
ReactStylesDiffMap styles) {
ReactShadowNode cssNode,
String className,
ReactStylesDiffMap styles) {
if (cssNode instanceof FlatShadowNode) {
FlatShadowNode node = (FlatShadowNode) cssNode;
@@ -164,12 +216,12 @@ public class FlatUIImplementation extends UIImplementation {
@Override
public void manageChildren(
int viewTag,
@Nullable ReadableArray moveFrom,
@Nullable ReadableArray moveTo,
@Nullable ReadableArray addChildTags,
@Nullable ReadableArray addAtIndices,
@Nullable ReadableArray removeFrom) {
int viewTag,
@Nullable ReadableArray moveFrom,
@Nullable ReadableArray moveTo,
@Nullable ReadableArray addChildTags,
@Nullable ReadableArray addAtIndices,
@Nullable ReadableArray removeFrom) {
ReactShadowNode parentNode = resolveShadowNode(viewTag);
@@ -182,8 +234,8 @@ public class FlatUIImplementation extends UIImplementation {
@Override
public void setChildren(
int viewTag,
ReadableArray children) {
int viewTag,
ReadableArray children) {
ReactShadowNode parentNode = resolveShadowNode(viewTag);
@@ -244,13 +296,13 @@ public class FlatUIImplementation extends UIImplementation {
FlatUIViewOperationQueue operationsQueue = mStateBuilder.getOperationsQueue();
operationsQueue.enqueueMeasureVirtualView(
node.getReactTag(),
xInParent / parentWidth,
yInParent / parentHeight,
width / parentWidth,
height / parentHeight,
relativeToWindow,
callback);
node.getReactTag(),
xInParent / parentWidth,
yInParent / parentHeight,
width / parentWidth,
height / parentHeight,
relativeToWindow,
callback);
}
private void ensureMountsToViewAndBackingViewIsCreated(int reactTag) {
@@ -304,10 +356,10 @@ public class FlatUIImplementation extends UIImplementation {
* preparing elements in moveFrom to be re-added at proper index.
*/
private void removeChildren(
ReactShadowNode parentNode,
@Nullable ReadableArray moveFrom,
@Nullable ReadableArray moveTo,
@Nullable ReadableArray removeFrom) {
ReactShadowNode parentNode,
@Nullable ReadableArray moveFrom,
@Nullable ReadableArray moveTo,
@Nullable ReadableArray removeFrom) {
int prevIndex = Integer.MAX_VALUE;
@@ -388,7 +440,7 @@ public class FlatUIImplementation extends UIImplementation {
if (tmpNode instanceof FlatShadowNode) {
FlatShadowNode flatTmpNode = (FlatShadowNode) tmpNode;
if (flatTmpNode.mountsToView() && flatTmpNode.isBackingViewCreated() &&
flatTmpNode.getParent() != null) {
flatTmpNode.getParent() != null) {
tag = flatTmpNode.getReactTag();
break;
}
@@ -418,9 +470,9 @@ public class FlatUIImplementation extends UIImplementation {
* Adds all children from addChildTags and moveFrom/moveTo.
*/
private void addChildren(
ReactShadowNode parentNode,
@Nullable ReadableArray addChildTags,
@Nullable ReadableArray addAtIndices) {
ReactShadowNode parentNode,
@Nullable ReadableArray addChildTags,
@Nullable ReadableArray addAtIndices) {
int prevIndex = -1;
@@ -485,12 +537,12 @@ public class FlatUIImplementation extends UIImplementation {
* Removes a child from parent, verifying that we are removing in descending order.
*/
private static ReactShadowNode removeChildAt(
ReactShadowNode parentNode,
int index,
int prevIndex) {
ReactShadowNode parentNode,
int index,
int prevIndex) {
if (index >= prevIndex) {
throw new RuntimeException(
"Invariant failure, needs sorting! " + index + " >= " + prevIndex);
"Invariant failure, needs sorting! " + index + " >= " + prevIndex);
}
return parentNode.removeChildAt(index);
@@ -500,13 +552,13 @@ public class FlatUIImplementation extends UIImplementation {
* Adds a child to parent, verifying that we are adding in ascending order.
*/
private static void addChildAt(
ReactShadowNode parentNode,
ReactShadowNode childNode,
int index,
int prevIndex) {
ReactShadowNode parentNode,
ReactShadowNode childNode,
int index,
int prevIndex) {
if (index <= prevIndex) {
throw new RuntimeException(
"Invariant failure, needs sorting! " + index + " <= " + prevIndex);
"Invariant failure, needs sorting! " + index + " <= " + prevIndex);
}
parentNode.addChildAt(childNode, index);
@@ -520,9 +572,9 @@ public class FlatUIImplementation extends UIImplementation {
@Override
protected void applyUpdatesRecursive(
ReactShadowNode cssNode,
float absoluteX,
float absoluteY) {
ReactShadowNode cssNode,
float absoluteX,
float absoluteY) {
mStateBuilder.applyUpdates((FlatRootShadowNode) cssNode);
}
@@ -551,18 +603,8 @@ public class FlatUIImplementation extends UIImplementation {
FlatUIViewOperationQueue operationsQueue = mStateBuilder.getOperationsQueue();
operationsQueue.enqueueSetJSResponder(
node == null ? tag : node.getReactTag(),
possiblyVirtualReactTag,
blockNativeResponder);
}
private static @Nullable RCTImageViewManager findRCTImageManager(List<ViewManager> viewManagers) {
for (int i = 0, size = viewManagers.size(); i != size; ++i) {
if (viewManagers.get(i) instanceof RCTImageViewManager) {
return (RCTImageViewManager) viewManagers.get(i);
}
}
return null;
node == null ? tag : node.getReactTag(),
possiblyVirtualReactTag,
blockNativeResponder);
}
}

View File

@@ -9,21 +9,22 @@
package com.facebook.react.flat;
import javax.annotation.Nullable;
import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.ReactShadowNode;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIViewOperationQueue;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.yoga.YogaValue;
import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaUnit;
import com.facebook.yoga.YogaValue;
import javax.annotation.Nullable;
/* package */ final class NativeViewWrapper extends FlatShadowNode implements AndroidView {
@Nullable private final ReactShadowNode mReactShadowNode;
@Nullable
private final ReactShadowNode mReactShadowNode;
private final boolean mNeedsCustomLayoutForChildren;
private boolean mPaddingChanged = false;
private boolean mForceMountGrandChildrenToView;

View File

@@ -9,13 +9,15 @@
package com.facebook.react.flat;
import javax.annotation.Nullable;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.controller.AbstractDraweeControllerBuilder;
import javax.annotation.Nullable;
public final class RCTImageViewManager extends FlatViewManager {
/* package */ static final String REACT_CLASS = "RCTImageView";
private @Nullable AbstractDraweeControllerBuilder mDraweeControllerBuilder;
private final @Nullable Object mCallerContext;
@@ -32,7 +34,7 @@ public final class RCTImageViewManager extends FlatViewManager {
@Override
public String getName() {
return "RCTImageView";
return REACT_CLASS;
}
@Override

View File

@@ -14,6 +14,8 @@ import com.facebook.react.views.modal.ReactModalHostManager;
public class RCTModalHostManager extends ReactModalHostManager {
/* package */ static final String REACT_CLASS = ReactModalHostManager.REACT_CLASS;
@Override
public LayoutShadowNode createShadowNodeInstance() {
return new FlatReactModalShadowNode();

View File

@@ -14,9 +14,11 @@ package com.facebook.react.flat;
*/
public final class RCTRawTextManager extends VirtualViewManager<RCTRawText> {
/* package */ static final String REACT_CLASS = "RCTRawText";
@Override
public String getName() {
return "RCTRawText";
return REACT_CLASS;
}
@Override

View File

@@ -14,9 +14,11 @@ package com.facebook.react.flat;
*/
public final class RCTTextInlineImageManager extends VirtualViewManager<RCTTextInlineImage> {
/* package */ static final String REACT_CLASS = "RCTTextInlineImage";
@Override
public String getName() {
return "RCTTextInlineImage";
return REACT_CLASS;
}
@Override

View File

@@ -13,6 +13,8 @@ import com.facebook.react.views.textinput.ReactTextInputManager;
public class RCTTextInputManager extends ReactTextInputManager {
/* package */ static final String REACT_CLASS = ReactTextInputManager.REACT_CLASS;
@Override
public RCTTextInput createShadowNodeInstance() {
return new RCTTextInput();

View File

@@ -14,9 +14,11 @@ package com.facebook.react.flat;
*/
public final class RCTTextManager extends FlatViewManager {
/* package */ static final String REACT_CLASS = "RCTText";
@Override
public String getName() {
return "RCTText";
return REACT_CLASS;
}
@Override

View File

@@ -9,29 +9,29 @@
package com.facebook.react.flat;
import javax.annotation.Nullable;
import java.util.Map;
import android.graphics.Rect;
import android.os.Build;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.PointerEvents;
import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
import com.facebook.react.views.view.ReactDrawableHelper;
import javax.annotation.Nullable;
import java.util.Map;
/**
* ViewManager that creates instances of RCTView.
*/
public final class RCTViewManager extends FlatViewManager {
/* package */ static final String REACT_CLASS = ViewProps.VIEW_CLASS_NAME;
private static final int[] TMP_INT_ARRAY = new int[2];
private static final int CMD_HOTSPOT_UPDATE = 1;
@@ -39,7 +39,7 @@ public final class RCTViewManager extends FlatViewManager {
@Override
public String getName() {
return ViewProps.VIEW_CLASS_NAME;
return REACT_CLASS;
}
public Map<String, Integer> getCommandsMap() {
@@ -59,19 +59,19 @@ public final class RCTViewManager extends FlatViewManager {
@ReactProp(name = "nativeBackgroundAndroid")
public void setHotspot(FlatViewGroup view, @Nullable ReadableMap bg) {
view.setHotspot(bg == null ?
null : ReactDrawableHelper.createDrawableFromJSDescription(view.getContext(), bg));
null : ReactDrawableHelper.createDrawableFromJSDescription(view.getContext(), bg));
}
@Override
public void receiveCommand(
FlatViewGroup view,
int commandId,
@Nullable ReadableArray args) {
FlatViewGroup view,
int commandId,
@Nullable ReadableArray args) {
switch (commandId) {
case CMD_HOTSPOT_UPDATE: {
if (args == null || args.size() != 2) {
throw new JSApplicationIllegalArgumentException(
"Illegal number of arguments for 'updateHotspot' command");
"Illegal number of arguments for 'updateHotspot' command");
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.getLocationOnScreen(TMP_INT_ARRAY);
@@ -84,7 +84,7 @@ public final class RCTViewManager extends FlatViewManager {
case CMD_SET_PRESSED: {
if (args == null || args.size() != 1) {
throw new JSApplicationIllegalArgumentException(
"Illegal number of arguments for 'setPressed' command");
"Illegal number of arguments for 'setPressed' command");
}
view.setPressed(args.getBoolean(0));
break;
@@ -94,8 +94,8 @@ public final class RCTViewManager extends FlatViewManager {
@ReactProp(name = ViewProps.NEEDS_OFFSCREEN_ALPHA_COMPOSITING)
public void setNeedsOffscreenAlphaCompositing(
FlatViewGroup view,
boolean needsOffscreenAlphaCompositing) {
FlatViewGroup view,
boolean needsOffscreenAlphaCompositing) {
view.setNeedsOffscreenAlphaCompositing(needsOffscreenAlphaCompositing);
}
@@ -132,10 +132,10 @@ public final class RCTViewManager extends FlatViewManager {
view.setHitSlopRect(null);
} else {
view.setHitSlopRect(new Rect(
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("left")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("top")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("right")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("bottom"))
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("left")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("top")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("right")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("bottom"))
));
}
}

View File

@@ -9,15 +9,16 @@
package com.facebook.react.flat;
import java.util.List;
import android.view.View;
import com.facebook.react.views.viewpager.ReactViewPager;
import com.facebook.react.views.viewpager.ReactViewPagerManager;
import java.util.List;
public class RCTViewPagerManager extends ReactViewPagerManager {
/* package */ static final String REACT_CLASS = ReactViewPagerManager.REACT_CLASS;
@Override
public void addViews(ReactViewPager parent, List<View> views) {
parent.setViews(views);

View File

@@ -14,9 +14,11 @@ package com.facebook.react.flat;
*/
public final class RCTVirtualTextManager extends VirtualViewManager<RCTVirtualText> {
/* package */ static final String REACT_CLASS = "RCTVirtualText";
@Override
public String getName() {
return "RCTVirtualText";
return REACT_CLASS;
}
@Override

View File

@@ -9,16 +9,8 @@
package com.facebook.react.shell;
import javax.inject.Provider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.facebook.react.LazyReactPackage;
import com.facebook.react.animated.NativeAnimatedModule;
import com.facebook.react.bridge.JavaScriptModule;
@@ -83,6 +75,12 @@ import com.facebook.react.views.view.ReactViewManager;
import com.facebook.react.views.viewpager.ReactViewPagerManager;
import com.facebook.react.views.webview.ReactWebViewManager;
import javax.inject.Provider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Package defining basic modules and view managers.
*/
@@ -261,41 +259,44 @@ public class MainReactPackage extends LazyReactPackage {
viewManagers.add(ARTRenderableViewManager.createARTGroupViewManager());
viewManagers.add(ARTRenderableViewManager.createARTShapeViewManager());
viewManagers.add(ARTRenderableViewManager.createARTTextViewManager());
viewManagers.add(new ARTSurfaceViewManager());
viewManagers.add(new ReactDialogPickerManager());
viewManagers.add(new ReactDrawerLayoutManager());
viewManagers.add(new ReactDropdownPickerManager());
viewManagers.add(new ReactHorizontalScrollViewManager());
viewManagers.add(new ReactImageManager());
viewManagers.add(new ReactModalHostManager());
viewManagers.add(new ReactProgressBarViewManager());
viewManagers.add(new ReactRawTextManager());
viewManagers.add(new ReactScrollViewManager());
viewManagers.add(new ReactSliderManager());
viewManagers.add(new ReactSwitchManager());
viewManagers.add(new FrescoBasedReactTextInlineImageViewManager());
viewManagers.add(new ReactTextInputManager());
viewManagers.add(new ReactTextViewManager());
viewManagers.add(new ReactToolbarManager());
viewManagers.add(new ReactViewManager());
viewManagers.add(new ReactViewPagerManager());
viewManagers.add(new ReactVirtualTextViewManager());
viewManagers.add(new ReactWebViewManager());
viewManagers.add(new SwipeRefreshLayoutManager());
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(reactContext);
if (preferences.getBoolean("flat_uiimplementation", false)) {
viewManagers.addAll(Arrays.asList(
new RCTViewManager(),
new RCTTextManager(),
new RCTRawTextManager(),
new RCTVirtualTextManager(),
new RCTTextInlineImageManager(),
new RCTImageViewManager(),
new RCTTextInputManager(),
new RCTViewPagerManager(),
new FlatARTSurfaceViewManager(),
new RCTModalHostManager()));
boolean useFlatUi = preferences.getBoolean("flat_uiimplementation", false);
if (useFlatUi) {
// Flat managers
viewManagers.add(new FlatARTSurfaceViewManager());
viewManagers.add(new RCTTextInlineImageManager());
viewManagers.add(new RCTImageViewManager());
viewManagers.add(new RCTModalHostManager());
viewManagers.add(new RCTRawTextManager());
viewManagers.add(new RCTTextInputManager());
viewManagers.add(new RCTTextManager());
viewManagers.add(new RCTViewManager());
viewManagers.add(new RCTViewPagerManager());
viewManagers.add(new RCTVirtualTextManager());
} else {
// Native equivalents
viewManagers.add(new ARTSurfaceViewManager());
viewManagers.add(new FrescoBasedReactTextInlineImageViewManager());
viewManagers.add(new ReactImageManager());
viewManagers.add(new ReactModalHostManager());
viewManagers.add(new ReactRawTextManager());
viewManagers.add(new ReactTextInputManager());
viewManagers.add(new ReactTextViewManager());
viewManagers.add(new ReactViewManager());
viewManagers.add(new ReactViewPagerManager());
viewManagers.add(new ReactVirtualTextViewManager());
}
return viewManagers;

View File

@@ -19,14 +19,19 @@ import java.util.Map;
*/
public class ViewManagerRegistry {
private final Map<String, ViewManager> mViewManagers = new HashMap<>();
private final Map<String, ViewManager> mViewManagers;
public ViewManagerRegistry(List<ViewManager> viewManagerList) {
mViewManagers = new HashMap<>();
for (ViewManager viewManager : viewManagerList) {
mViewManagers.put(viewManager.getName(), viewManager);
}
}
public ViewManagerRegistry(Map<String, ViewManager> viewManagerMap) {
mViewManagers = viewManagerMap;
}
public ViewManager get(String className) {
ViewManager viewManager = mViewManagers.get(className);
if (viewManager != null) {