From 8702a75b961edc1c7ebbf500b5dc355ddd683181 Mon Sep 17 00:00:00 2001 From: Denis Koroskin Date: Fri, 12 Feb 2016 14:28:18 -0800 Subject: [PATCH] Don't wrap unknown virtual nodes with AndroidView Summary: Currently, we wrap all unknown shadow nodes with AndroidView. This works great, except when the shadow node is virtual, i.e. it *doesn't* mount to a View. In this case, we just need to keep it in the hierarchy as is. Fixes ARTSurfaceView not working correctly in groups. Reviewed By: ahmedre Differential Revision: D2933325 --- .../com/facebook/react/flat/AndroidView.java | 4 ++- .../react/flat/FlatUIImplementation.java | 34 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/AndroidView.java b/ReactAndroid/src/main/java/com/facebook/react/flat/AndroidView.java index 9aaccdaf8..a5e6e9ee3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/AndroidView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/AndroidView.java @@ -79,7 +79,9 @@ import com.facebook.react.uimanager.ViewManager; @Override public void addChildAt(CSSNode child, int i) { super.addChildAt(child, i); - ((FlatShadowNode) child).forceMountToView(); + if (child instanceof FlatShadowNode) { + ((FlatShadowNode) child).forceMountToView(); + } } @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java index ab7ac4512..1e9a64ef7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java @@ -110,7 +110,7 @@ public class FlatUIImplementation extends UIImplementation { @Override protected ReactShadowNode createShadowNode(String className) { ReactShadowNode cssNode = super.createShadowNode(className); - if (cssNode instanceof FlatShadowNode) { + if (cssNode instanceof FlatShadowNode || cssNode.isVirtual()) { return cssNode; } @@ -122,15 +122,19 @@ public class FlatUIImplementation extends UIImplementation { ReactShadowNode cssNode, int rootViewTag, @Nullable ReactStylesDiffMap styles) { - FlatShadowNode node = (FlatShadowNode) cssNode; + if (cssNode instanceof FlatShadowNode) { + FlatShadowNode node = (FlatShadowNode) cssNode; - if (styles != null) { - node.handleUpdateProperties(styles); - } + if (styles != null) { + node.handleUpdateProperties(styles); + } - if (node.mountsToView()) { - int tag = cssNode.getReactTag(); - mStateBuilder.ensureBackingViewIsCreated(node, tag, styles); + if (node.mountsToView()) { + int tag = cssNode.getReactTag(); + mStateBuilder.ensureBackingViewIsCreated(node, tag, styles); + } + } else { + super.handleCreateView(cssNode, rootViewTag, styles); } } @@ -139,13 +143,17 @@ public class FlatUIImplementation extends UIImplementation { ReactShadowNode cssNode, String className, ReactStylesDiffMap styles) { - FlatShadowNode node = (FlatShadowNode) cssNode; + if (cssNode instanceof FlatShadowNode) { + FlatShadowNode node = (FlatShadowNode) cssNode; - node.handleUpdateProperties(styles); + node.handleUpdateProperties(styles); - if (node.mountsToView()) { - int tag = cssNode.getReactTag(); - mStateBuilder.ensureBackingViewIsCreated(node, tag, styles); + if (node.mountsToView()) { + int tag = cssNode.getReactTag(); + mStateBuilder.ensureBackingViewIsCreated(node, tag, styles); + } + } else { + super.handleUpdateView(cssNode, className, styles); } }