Skip to content

Commit b78c284

Browse files
committed
Always execute actions on the runQueue
A View that is not attached will place posted actions on the ViewRoot's runQueue. Previously, this runQueue was only ever executed during a layout (during performTraversals()). This works in most situations (a View that is added to or removed from the hierarchy will force a layout in general), but not in all cases. For example, a new View being added to a ListView will not cause a layout, so any actions posted to that View prior to its being attached will not be run until some indeterminate time later when a layout happens to run. The fix is to execute the (typically empty) runQueue on every traversal. Issue #6366678 View.post() ignored when called on an unattached ListView item Change-Id: I94e6fdd9da6bb57fd83b547f8d742cd0ddfecbd6
1 parent 5b086eb commit b78c284

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/java/android/view/ViewRootImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,13 +1199,13 @@ private void performTraversals() {
11991199
}
12001200
}
12011201

1202+
// Execute enqueued actions on every traversal in case a detached view enqueued an action
1203+
getRunQueue().executeActions(attachInfo.mHandler);
1204+
12021205
boolean insetsChanged = false;
12031206

12041207
boolean layoutRequested = mLayoutRequested && !mStopped;
12051208
if (layoutRequested) {
1206-
// Execute enqueued actions on every layout in case a view that was detached
1207-
// enqueued an action after being detached
1208-
getRunQueue().executeActions(attachInfo.mHandler);
12091209

12101210
final Resources res = mView.getContext().getResources();
12111211

0 commit comments

Comments
 (0)