Fix appendChild
Reviewed By: mdvacca Differential Revision: D7128443 fbshipit-source-id: 4eedea4df2b636eb9589cbe5e84c5c6a8aa33539
This commit is contained in:
parent
6404529b76
commit
78b30659bc
|
@ -22,6 +22,7 @@ import com.facebook.react.uimanager.ReactShadowNodeImpl;
|
|||
import com.facebook.react.uimanager.ReactStylesDiffMap;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.UIViewOperationQueue;
|
||||
import com.facebook.react.uimanager.ViewAtIndex;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.facebook.react.uimanager.ViewManagerRegistry;
|
||||
import com.facebook.react.uimanager.common.MeasureSpecProvider;
|
||||
|
@ -179,8 +180,16 @@ public class FabricUIManagerModule implements UIManager {
|
|||
@Nullable
|
||||
public void appendChild(ReactShadowNode parent, ReactShadowNode child) {
|
||||
try {
|
||||
parent.addChildAt(child, parent.getChildCount());
|
||||
addChild(parent.getReactTag(), child.getReactTag());
|
||||
int childIndex = parent.getChildCount();
|
||||
parent.addChildAt(child, childIndex);
|
||||
ViewAtIndex[] viewsToAdd =
|
||||
new ViewAtIndex[]{new ViewAtIndex(child.getReactTag(), childIndex)};
|
||||
mUIViewOperationQueue.enqueueManageChildren(
|
||||
parent.getReactTag(),
|
||||
null,
|
||||
viewsToAdd,
|
||||
null
|
||||
);
|
||||
} catch (Exception e) {
|
||||
handleException(parent.getThemedContext(), e);
|
||||
}
|
||||
|
@ -209,8 +218,7 @@ public class FabricUIManagerModule implements UIManager {
|
|||
"Root view with tag " + rootTag + " must be added before completeRoot is called");
|
||||
for (int i = 0; i < childList.size(); i++) {
|
||||
ReactShadowNode child = childList.get(i);
|
||||
rootNode.addChildAt(child, i);
|
||||
addChild(rootTag, child.getReactTag());
|
||||
appendChild(rootNode, child);
|
||||
}
|
||||
|
||||
calculateRootLayout(rootNode);
|
||||
|
@ -222,15 +230,6 @@ public class FabricUIManagerModule implements UIManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void addChild(int parent, int child) {
|
||||
JavaOnlyArray childrenTags = new JavaOnlyArray();
|
||||
childrenTags.pushInt(child);
|
||||
mUIViewOperationQueue.enqueueSetChildren(
|
||||
parent,
|
||||
childrenTags
|
||||
);
|
||||
}
|
||||
|
||||
private void calculateRootLayout(ReactShadowNode cssRoot) {
|
||||
cssRoot.calculateLayout();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Comparator;
|
|||
* Data structure that couples view tag to it's index in parent view. Used for managing children
|
||||
* operation.
|
||||
*/
|
||||
/* package */ class ViewAtIndex {
|
||||
public class ViewAtIndex {
|
||||
public static Comparator<ViewAtIndex> COMPARATOR = new Comparator<ViewAtIndex>() {
|
||||
@Override
|
||||
public int compare(ViewAtIndex lhs, ViewAtIndex rhs) {
|
||||
|
|
Loading…
Reference in New Issue