mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 19:44:13 +00:00
Fix removal of virtual nodes in FabricReconciler
Reviewed By: mdvacca Differential Revision: D7338949 fbshipit-source-id: 31263c138689f9b3f59deb26851132df04b8a823
This commit is contained in:
parent
cf036dbc7a
commit
c0d27de37e
@ -89,12 +89,11 @@ public class FabricReconciler {
|
||||
// If a View is not re-ordered, then the ReactTag is deleted (ReactShadowNode and native View
|
||||
// are released from memory)
|
||||
List<Integer> tagsToDelete = new LinkedList<>();
|
||||
int[] indicesToRemove = new int[prevList.size() - firstRemovedOrAddedViewIndex];
|
||||
int indicesToRemoveIndex = 0;
|
||||
for (int j = firstRemovedOrAddedViewIndex; j < prevList.size(); j++) {
|
||||
List<Integer> indicesToRemove = new LinkedList<>();
|
||||
for (int j = prevList.size() - 1; j >= firstRemovedOrAddedViewIndex; j--) {
|
||||
ReactShadowNode nodeToRemove = prevList.get(j);
|
||||
if (nodeToRemove.isVirtual()) continue;
|
||||
indicesToRemove[indicesToRemoveIndex++] = j;
|
||||
indicesToRemove.add(0, j);
|
||||
if (!addedTags.contains(nodeToRemove.getReactTag())) {
|
||||
tagsToDelete.add(nodeToRemove.getReactTag());
|
||||
// TODO: T26729293 since we are not cloning ReactShadowNode's we need to "manually" remove
|
||||
@ -103,21 +102,21 @@ public class FabricReconciler {
|
||||
}
|
||||
}
|
||||
|
||||
int[] tagsToDeleteArray = ArrayUtils.copyListToArray(tagsToDelete);
|
||||
ViewAtIndex[] viewsToAddArray = viewsToAdd.toArray(new ViewAtIndex[viewsToAdd.size()]);
|
||||
|
||||
// TODO (t27180994): Mutate views synchronously on main thread
|
||||
if (indicesToRemove.length > 0 || viewsToAddArray.length > 0 || tagsToDeleteArray.length > 0) {
|
||||
if (!(indicesToRemove.isEmpty() && viewsToAdd.isEmpty() && tagsToDelete.isEmpty())) {
|
||||
int[] indicesToRemoveArray = ArrayUtils.copyListToArray(indicesToRemove);
|
||||
ViewAtIndex[] viewsToAddArray = viewsToAdd.toArray(new ViewAtIndex[viewsToAdd.size()]);
|
||||
int[] tagsToDeleteArray = ArrayUtils.copyListToArray(tagsToDelete);
|
||||
if (DEBUG) {
|
||||
Log.d(
|
||||
TAG,
|
||||
"manageChildren.enqueueManageChildren parent: " + parent.getReactTag() +
|
||||
"\n\tIndices2Remove: " + Arrays.toString(indicesToRemove) +
|
||||
"\n\tIndices2Remove: " + Arrays.toString(indicesToRemoveArray) +
|
||||
"\n\tViews2Add: " + Arrays.toString(viewsToAddArray) +
|
||||
"\n\tTags2Delete: " + Arrays.toString(tagsToDeleteArray));
|
||||
}
|
||||
uiViewOperationQueue.enqueueManageChildren(
|
||||
parent.getReactTag(), indicesToRemove, viewsToAddArray, tagsToDeleteArray);
|
||||
parent.getReactTag(), indicesToRemoveArray, viewsToAddArray, tagsToDeleteArray);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,17 @@ public class ViewAtIndex {
|
||||
mIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || obj.getClass() != getClass()) {
|
||||
return false;
|
||||
}
|
||||
ViewAtIndex other = (ViewAtIndex) obj;
|
||||
return mIndex == other.mIndex && mTag == other.mTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + mIndex + ", " + mTag + "]";
|
||||
return "[" + mTag + ", " + mIndex + "]";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user