Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix view indices with Android LayoutAnimation #18830

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,13 @@ public synchronized void manageChildren(
if (mLayoutAnimationEnabled &&
mLayoutAnimator.shouldAnimateLayout(viewToRemove) &&
arrayContains(tagsToDelete, viewToRemove.getId())) {
// The view will be removed and dropped by the 'delete' layout animation
// instead, so do nothing
} else {
viewManager.removeViewAt(viewToManage, indexToRemove);
// Display the view in the parent after removal for the duration of the layout animation,
// but pretend that it doesn't exist when calling other ViewGroup methods.
viewManager.startViewTransition(viewToManage, viewToRemove);
}

viewManager.removeViewAt(viewToManage, indexToRemove);

lastIndexToRemove = indexToRemove;
}
}
Expand Down Expand Up @@ -423,7 +424,9 @@ public synchronized void manageChildren(
mLayoutAnimator.deleteView(viewToDestroy, new LayoutAnimationListener() {
@Override
public void onAnimationEnd() {
viewManager.removeView(viewToManage, viewToDestroy);
// Already removed from the ViewGroup, we can just end the transition here to
// release the child.
viewManager.endViewTransition(viewToManage, viewToDestroy);
dropView(viewToDestroy);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ public void removeAllViews(T parent) {
}
}

public void startViewTransition(T parent, View view) {
parent.startViewTransition(view);
}

public void endViewTransition(T parent, View view) {
parent.endViewTransition(view);
}

/**
* Returns whether this View type needs to handle laying out its own children instead of
* deferring to the standard css-layout algorithm.
Expand Down