Don't clobber in progress page transition in applyLoadPlan()
Also only reloadIfNeeded() instead of always reloading in showCurrentTask(), which is called twice as the gesture starts and could contribute to jank.
Test: quickly quick switch from app A to B, ensure no jumpcut back to A
Bug: 205499708
Change-Id: I516020551d3f76eb4025df848bf4c88adf5499b7
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index ed238d8..aab33aa 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1383,7 +1383,7 @@
// Removing views sets the currentPage to 0, so we save this and restore it after
// the new set of views are added
- int previousPage = mCurrentPage;
+ int previousCurrentPage = mCurrentPage;
removeAllViews();
// Add views as children based on whether it's grouped or single task
@@ -1407,7 +1407,14 @@
if (!taskGroups.isEmpty()) {
addView(mClearAllButton);
}
- setCurrentPage(previousPage);
+
+ boolean settlingOnNewTask = mNextPage != INVALID_PAGE;
+ if (settlingOnNewTask) {
+ // Restore mCurrentPage but don't call setCurrentPage() as that clobbers the scroll.
+ mCurrentPage = previousCurrentPage;
+ } else {
+ setCurrentPage(previousCurrentPage);
+ }
// Keep same previous focused task
TaskView newFocusedTaskView = getTaskViewByTaskId(focusedTaskId);
@@ -1433,7 +1440,7 @@
}
int targetPage = -1;
- if (mNextPage == INVALID_PAGE) {
+ if (!settlingOnNewTask) {
// Set the current page to the running task, but not if settling on new task.
if (runningTaskId != -1) {
targetPage = indexOfChild(newRunningTaskView);
@@ -2235,7 +2242,7 @@
updateChildTaskOrientations();
// Reload the task list
- mTaskListChangeId = mModel.getTasks(this::applyLoadPlan);
+ reloadIfNeeded();
}
/**