diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index bff302521c..1205bdc3b6 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -229,7 +229,9 @@ public abstract class RecentsView extends PagedView impl } }; - private int mLoadPlanId = -1; + // Used to keep track of the last requested load plan id, so that we do not request to load the + // tasks again if we have already requested it and the task list has not changed + private int mRequestedLoadPlanId = -1; // Only valid until the launcher state changes to NORMAL private int mRunningTaskId = -1; @@ -447,6 +449,7 @@ public abstract class RecentsView extends PagedView impl mPendingAnimation.addEndListener((onEndListener) -> applyLoadPlan(loadPlan)); return; } + TaskStack stack = loadPlan != null ? loadPlan.getTaskStack() : null; if (stack == null) { removeAllViews(); @@ -615,8 +618,9 @@ public abstract class RecentsView extends PagedView impl * and unloads the associated task data for tasks that are no longer visible. */ public void loadVisibleTaskData() { - if (!mOverviewStateEnabled) { - // Skip loading visible task data if we've already left the overview state + if (!mOverviewStateEnabled || mRequestedLoadPlanId == -1) { + // Skip loading visible task data if we've already left the overview state, or if the + // task list hasn't been loaded yet (the task views will not reflect the task list) return; } @@ -675,6 +679,7 @@ public abstract class RecentsView extends PagedView impl mRunningTaskId = -1; mRunningTaskTileHidden = false; mIgnoreResetTaskId = -1; + mRequestedLoadPlanId = -1; unloadVisibleTaskData(); setCurrentPage(0); @@ -686,8 +691,8 @@ public abstract class RecentsView extends PagedView impl * Reloads the view if anything in recents changed. */ public void reloadIfNeeded() { - if (!mModel.isLoadPlanValid(mLoadPlanId)) { - mLoadPlanId = mModel.loadTasks(mRunningTaskId, this::applyLoadPlan); + if (!mModel.isLoadPlanValid(mRequestedLoadPlanId)) { + mRequestedLoadPlanId = mModel.loadTasks(mRunningTaskId, this::applyLoadPlan); } } @@ -748,8 +753,8 @@ public abstract class RecentsView extends PagedView impl setCurrentPage(0); - // Load the tasks (if the loading is already - mLoadPlanId = mModel.loadTasks(runningTaskId, this::applyLoadPlan); + // Load the tasks + reloadIfNeeded(); } public void showNextTask() {