Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -3504,7 +3504,6 @@ public class com/facebook/react/uimanager/NativeViewHierarchyManager {
public fun findTargetTagForTouch (IFF)I
public fun getInstanceHandle (I)J
public fun getRootViewNum ()I
public fun manageChildren (I[I[Lcom/facebook/react/uimanager/ViewAtIndex;[I)V
public fun measure (I[I)V
public fun measureInWindow (I[I)V
public fun removeRootView (I)V
Expand All @@ -3526,7 +3525,6 @@ public class com/facebook/react/uimanager/NativeViewHierarchyOptimizer {
public static fun assertNodeSupportedWithoutOptimizer (Lcom/facebook/react/uimanager/ReactShadowNode;)V
public fun handleCreateView (Lcom/facebook/react/uimanager/ReactShadowNode;Lcom/facebook/react/uimanager/ThemedReactContext;Lcom/facebook/react/uimanager/ReactStylesDiffMap;)V
public fun handleForceViewToBeNonLayoutOnly (Lcom/facebook/react/uimanager/ReactShadowNode;)V
public fun handleManageChildren (Lcom/facebook/react/uimanager/ReactShadowNode;[I[I[Lcom/facebook/react/uimanager/ViewAtIndex;[I)V
public static fun handleRemoveNode (Lcom/facebook/react/uimanager/ReactShadowNode;)V
public fun handleSetChildren (Lcom/facebook/react/uimanager/ReactShadowNode;Lcom/facebook/react/bridge/ReadableArray;)V
public fun handleUpdateLayout (Lcom/facebook/react/uimanager/ReactShadowNode;)V
Expand Down Expand Up @@ -4272,7 +4270,6 @@ public class com/facebook/react/uimanager/UIImplementation {
public fun getRootViewNum ()I
protected fun handleCreateView (Lcom/facebook/react/uimanager/ReactShadowNode;ILcom/facebook/react/uimanager/ReactStylesDiffMap;)V
protected fun handleUpdateView (Lcom/facebook/react/uimanager/ReactShadowNode;Ljava/lang/String;Lcom/facebook/react/uimanager/ReactStylesDiffMap;)V
public fun manageChildren (ILcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/ReadableArray;)V
public fun measure (ILcom/facebook/react/bridge/Callback;)V
public fun measureInWindow (ILcom/facebook/react/bridge/Callback;)V
public fun measureLayout (IILcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/Callback;)V
Expand All @@ -4288,7 +4285,6 @@ public class com/facebook/react/uimanager/UIImplementation {
public fun removeRootShadowNode (I)V
public fun removeRootView (I)V
protected final fun removeShadowNode (Lcom/facebook/react/uimanager/ReactShadowNode;)V
public fun replaceExistingNonRootView (II)V
public fun resolveRootTagFromReactTag (I)I
public final fun resolveShadowNode (I)Lcom/facebook/react/uimanager/ReactShadowNode;
protected final fun resolveViewManager (Ljava/lang/String;)Lcom/facebook/react/uimanager/ViewManager;
Expand Down Expand Up @@ -4358,7 +4354,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
public fun initialize ()V
public fun invalidate ()V
public fun invalidateNodeLayout (I)V
public fun manageChildren (ILcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/ReadableArray;)V
public fun markActiveTouchForTag (II)V
public fun measure (ILcom/facebook/react/bridge/Callback;)V
public fun measureInWindow (ILcom/facebook/react/bridge/Callback;)V
Expand Down Expand Up @@ -4407,7 +4402,6 @@ public class com/facebook/react/uimanager/UIViewOperationQueue {
public fun enqueueDispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun enqueueFindTargetForTouch (IFFLcom/facebook/react/bridge/Callback;)V
public fun enqueueLayoutUpdateFinished (Lcom/facebook/react/uimanager/ReactShadowNode;Lcom/facebook/react/uimanager/UIImplementation$LayoutUpdateListener;)V
public fun enqueueManageChildren (I[I[Lcom/facebook/react/uimanager/ViewAtIndex;[I)V
public fun enqueueMeasure (ILcom/facebook/react/bridge/Callback;)V
public fun enqueueMeasureInWindow (ILcom/facebook/react/bridge/Callback;)V
public fun enqueueRemoveRootView (I)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,79 +297,6 @@ public synchronized void createView(
}
}

private static String constructManageChildrenErrorMessage(
ViewGroup viewToManage,
ViewGroupManager viewManager,
@Nullable int[] indicesToRemove,
@Nullable ViewAtIndex[] viewsToAdd,
@Nullable int[] tagsToDelete) {
StringBuilder stringBuilder = new StringBuilder();

if (null != viewToManage) {
stringBuilder.append(
"View tag:"
+ viewToManage.getId()
+ " View Type:"
+ viewToManage.getClass().toString()
+ "\n");
stringBuilder.append(" children(" + viewManager.getChildCount(viewToManage) + "): [\n");
for (int index = 0; viewManager.getChildAt(viewToManage, index) != null; index += 16) {
for (int innerOffset = 0;
viewManager.getChildAt(viewToManage, index + innerOffset) != null && innerOffset < 16;
innerOffset++) {
stringBuilder.append(
viewManager.getChildAt(viewToManage, index + innerOffset).getId() + ",");
}
stringBuilder.append("\n");
}
stringBuilder.append(" ],\n");
}

if (indicesToRemove != null) {
stringBuilder.append(" indicesToRemove(" + indicesToRemove.length + "): [\n");
for (int index = 0; index < indicesToRemove.length; index += 16) {
for (int innerOffset = 0;
((index + innerOffset) < indicesToRemove.length) && innerOffset < 16;
innerOffset++) {
stringBuilder.append(indicesToRemove[index + innerOffset] + ",");
}
stringBuilder.append("\n");
}
stringBuilder.append(" ],\n");
}
if (viewsToAdd != null) {
stringBuilder.append(" viewsToAdd(" + viewsToAdd.length + "): [\n");
for (int index = 0; index < viewsToAdd.length; index += 16) {
for (int innerOffset = 0;
((index + innerOffset) < viewsToAdd.length) && innerOffset < 16;
innerOffset++) {
stringBuilder.append(
"["
+ viewsToAdd[index + innerOffset].mIndex
+ ","
+ viewsToAdd[index + innerOffset].mTag
+ "],");
}
stringBuilder.append("\n");
}
stringBuilder.append(" ],\n");
}
if (tagsToDelete != null) {
stringBuilder.append(" tagsToDelete(" + tagsToDelete.length + "): [\n");
for (int index = 0; index < tagsToDelete.length; index += 16) {
for (int innerOffset = 0;
((index + innerOffset) < tagsToDelete.length) && innerOffset < 16;
innerOffset++) {
stringBuilder.append(tagsToDelete[index + innerOffset] + ",");
}
stringBuilder.append("\n");
}
stringBuilder.append(" ]\n");
}

return stringBuilder.toString();
}

private Set<Integer> getPendingDeletionsForTag(int tag) {
if (mPendingDeletionsForTag == null) {
mPendingDeletionsForTag = new HashMap<>();
Expand All @@ -382,147 +309,6 @@ private Set<Integer> getPendingDeletionsForTag(int tag) {
return mPendingDeletionsForTag.get(tag);
}

/**
* @param tag react tag of the node we want to manage
* @param indicesToRemove ordered (asc) list of indices at which view should be removed
* @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent
* a view which should be added at the specified index
* @param tagsToDelete list of tags corresponding to views that should be removed
*/
public synchronized void manageChildren(
final int tag,
@Nullable int[] indicesToRemove,
@Nullable ViewAtIndex[] viewsToAdd,
@Nullable int[] tagsToDelete) {
if (DEBUG_MODE) {
FLog.d(
TAG,
"createView[%d]: %s %s %s",
tag,
(indicesToRemove != null ? indicesToRemove.toString() : "<null>"),
(viewsToAdd != null ? viewsToAdd.toString() : "<null>"),
(tagsToDelete != null ? tagsToDelete.toString() : "<null>"));
}
UiThreadUtil.assertOnUiThread();

final Set<Integer> pendingDeletionTags = getPendingDeletionsForTag(tag);
final ViewGroup viewToManage = (ViewGroup) mTagsToViews.get(tag);
final ViewGroupManager viewManager = (ViewGroupManager) resolveViewManager(tag);
if (viewToManage == null) {
throw new IllegalViewOperationException(
"Trying to manageChildren view with tag "
+ tag
+ " which doesn't exist\n detail: "
+ constructManageChildrenErrorMessage(
viewToManage, viewManager, indicesToRemove, viewsToAdd, tagsToDelete));
}

int lastIndexToRemove = viewManager.getChildCount(viewToManage);

if (indicesToRemove != null) {
for (int i = indicesToRemove.length - 1; i >= 0; i--) {
int indexToRemove = indicesToRemove[i];
if (indexToRemove < 0) {
throw new IllegalViewOperationException(
"Trying to remove a negative view index:"
+ indexToRemove
+ " view tag: "
+ tag
+ "\n detail: "
+ constructManageChildrenErrorMessage(
viewToManage, viewManager, indicesToRemove, viewsToAdd, tagsToDelete));
}
if (viewManager.getChildAt(viewToManage, indexToRemove) == null) {
if (mRootTags.get(tag) && viewManager.getChildCount(viewToManage) == 0) {
// This root node has already been removed (likely due to a threading issue caused by
// async js execution). Ignore this root removal.
return;
}
throw new IllegalViewOperationException(
"Trying to remove a view index above child "
+ "count "
+ indexToRemove
+ " view tag: "
+ tag
+ "\n detail: "
+ constructManageChildrenErrorMessage(
viewToManage, viewManager, indicesToRemove, viewsToAdd, tagsToDelete));
}
if (indexToRemove >= lastIndexToRemove) {
throw new IllegalViewOperationException(
"Trying to remove an out of order view index:"
+ indexToRemove
+ " view tag: "
+ tag
+ "\n detail: "
+ constructManageChildrenErrorMessage(
viewToManage, viewManager, indicesToRemove, viewsToAdd, tagsToDelete));
}

if (!mLayoutAnimationEnabled) {
viewManager.removeViewAt(viewToManage, indexToRemove);
}

lastIndexToRemove = indexToRemove;
}
}

if (tagsToDelete != null) {
for (int i = 0; i < tagsToDelete.length; i++) {
int tagToDelete = tagsToDelete[i];
final View viewToDestroy = mTagsToViews.get(tagToDelete);
if (viewToDestroy == null) {
throw new IllegalViewOperationException(
"Trying to destroy unknown view tag: "
+ tagToDelete
+ "\n detail: "
+ constructManageChildrenErrorMessage(
viewToManage, viewManager, indicesToRemove, viewsToAdd, tagsToDelete));
}

if (!mLayoutAnimationEnabled) {
dropView(viewToDestroy);
}
}
}

if (viewsToAdd != null) {
for (int i = 0; i < viewsToAdd.length; i++) {
ViewAtIndex viewAtIndex = viewsToAdd[i];
View viewToAdd = mTagsToViews.get(viewAtIndex.mTag);
if (viewToAdd == null) {
throw new IllegalViewOperationException(
"Trying to add unknown view tag: "
+ viewAtIndex.mTag
+ "\n detail: "
+ constructManageChildrenErrorMessage(
viewToManage, viewManager, indicesToRemove, viewsToAdd, tagsToDelete));
}

int normalizedIndex = viewAtIndex.mIndex;
if (!pendingDeletionTags.isEmpty()) {
normalizedIndex = 0;
int counter = 0;
while (normalizedIndex < viewToManage.getChildCount()) {
if (counter == viewAtIndex.mIndex) {
break;
}
View v = viewToManage.getChildAt(normalizedIndex);
if (!pendingDeletionTags.contains(v.getId())) {
counter++;
}
normalizedIndex++;
}
}

viewManager.addView(viewToManage, viewToAdd, normalizedIndex);
}
}
if (pendingDeletionTags.isEmpty()) {
mPendingDeletionsForTag.remove(tag);
}
}

private boolean arrayContains(@Nullable int[] array, int ele) {
if (array == null) {
return false;
Expand All @@ -535,19 +321,6 @@ private boolean arrayContains(@Nullable int[] array, int ele) {
return false;
}

/**
* Simplified version of constructManageChildrenErrorMessage that only deals with adding children
* views
*/
private static String constructSetChildrenErrorMessage(
ViewGroup viewToManage, ViewGroupManager viewManager, ReadableArray childrenTags) {
ViewAtIndex[] viewsToAdd = new ViewAtIndex[childrenTags.size()];
for (int i = 0; i < childrenTags.size(); i++) {
viewsToAdd[i] = new ViewAtIndex(childrenTags.getInt(i), i);
}
return constructManageChildrenErrorMessage(viewToManage, viewManager, null, viewsToAdd, null);
}

/** Simplified version of manageChildren that only deals with adding children views */
public synchronized void setChildren(int tag, ReadableArray childrenTags) {
if (DEBUG_MODE) {
Expand All @@ -565,10 +338,7 @@ public synchronized void setChildren(int tag, ReadableArray childrenTags) {
View viewToAdd = mTagsToViews.get(childrenTags.getInt(i));
if (viewToAdd == null) {
throw new IllegalViewOperationException(
"Trying to add unknown view tag: "
+ childrenTags.getInt(i)
+ "\n detail: "
+ constructSetChildrenErrorMessage(viewToManage, viewManager, childrenTags));
"Trying to add unknown view tag: " + childrenTags.getInt(i));
}
viewManager.addView(viewToManage, viewToAdd, i);
}
Expand Down
Loading
Loading