Skip to content

Commit 38330ec

Browse files
chethaaseAndroid (Google) Code Review
authored andcommitted
Merge "Avoid running layout transitions on unattached views and windows" into jb-dev
2 parents b72ac9d + ab3a776 commit 38330ec

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/java/android/animation/LayoutTransition.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,9 @@ public void onAnimationEnd(Animator anim) {
12081208
* affect CHANGE_APPEARING or CHANGE_DISAPPEARING animations.
12091209
*/
12101210
private void addChild(ViewGroup parent, View child, boolean changesLayout) {
1211+
if (parent.getWindowVisibility() != View.VISIBLE) {
1212+
return;
1213+
}
12111214
if ((mTransitionTypes & FLAG_APPEARING) == FLAG_APPEARING) {
12121215
// Want disappearing animations to finish up before proceeding
12131216
cancel(DISAPPEARING);
@@ -1243,6 +1246,9 @@ private void addChild(ViewGroup parent, View child, boolean changesLayout) {
12431246
* @hide
12441247
*/
12451248
public void layoutChange(ViewGroup parent) {
1249+
if (parent.getWindowVisibility() != View.VISIBLE) {
1250+
return;
1251+
}
12461252
if ((mTransitionTypes & FLAG_CHANGING) == FLAG_CHANGING && !isRunning()) {
12471253
// This method is called for all calls to layout() in the container, including
12481254
// those caused by add/remove/hide/show events, which will already have set up
@@ -1301,6 +1307,9 @@ public void showChild(ViewGroup parent, View child, int oldVisibility) {
13011307
* affect CHANGE_APPEARING or CHANGE_DISAPPEARING animations.
13021308
*/
13031309
private void removeChild(ViewGroup parent, View child, boolean changesLayout) {
1310+
if (parent.getWindowVisibility() != View.VISIBLE) {
1311+
return;
1312+
}
13041313
if ((mTransitionTypes & FLAG_DISAPPEARING) == FLAG_DISAPPEARING) {
13051314
// Want appearing animations to finish up before proceeding
13061315
cancel(APPEARING);

0 commit comments

Comments
 (0)