From 1d5ff7e71e50d0649911df7b41e77801c170797e Mon Sep 17 00:00:00 2001 From: Winson Date: Fri, 4 Mar 2016 11:21:09 -0800 Subject: [PATCH] Just return the task to the pool if it is not in the current stack. Bug: 27467025 Change-Id: I5c414d674fb0db152b77c2025b4885d340e81880 --- .../systemui/recents/views/TaskStackView.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java index 0a50f2f75189b..6abb82686c639 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -523,15 +523,22 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal for (int i = taskViewCount - 1; i >= 0; i--) { TaskView tv = taskViews.get(i); Task task = tv.getTask(); - int taskIndex = mStack.indexOfStackTask(task); - TaskViewTransform transform = mCurrentTaskTransforms.get(taskIndex); // Skip ignored tasks if (ignoreTasksSet.contains(task.key)) { continue; } - if (task.isFreeformTask() || transform.visible) { + // It is possible for the set of lingering TaskViews to differ from the stack if the + // stack was updated before the relayout. If the task view is no longer in the stack, + // then just return it back to the view pool. + int taskIndex = mStack.indexOfStackTask(task); + TaskViewTransform transform = null; + if (taskIndex != -1) { + transform = mCurrentTaskTransforms.get(taskIndex); + } + + if (task.isFreeformTask() || (transform != null && transform.visible)) { mTmpTaskViewMap.put(task.key, tv); } else { if (mTouchExplorationEnabled) {