diff --git a/go/quickstep/src/com/android/quickstep/TaskListLoader.java b/go/quickstep/src/com/android/quickstep/TaskListLoader.java index 1234989d24..51b73f1815 100644 --- a/go/quickstep/src/com/android/quickstep/TaskListLoader.java +++ b/go/quickstep/src/com/android/quickstep/TaskListLoader.java @@ -67,17 +67,27 @@ public final class TaskListLoader { return Collections.unmodifiableList(mTaskList); } + /** + * Whether or not the loader needs to load data to be up to date. This can return true if the + * task list is already up to date OR there is already a load in progress for the task list to + * become up to date. + * + * @return true if already up to date or load in progress, false otherwise + */ + public boolean needsToLoad() { + return !mRecentsModel.isTaskListValid(mTaskListChangeId); + } + /** * Fetches the most recent tasks and updates the task list asynchronously. This call does not * provide guarantees the task content (icon, thumbnail, label) are loaded but will fill in * what it has. May run the callback immediately if there have been no changes in the task - * list. + * list since the start of the last load. * * @param onLoadedCallback callback to run when task list is loaded */ public void loadTaskList(@Nullable Consumer> onLoadedCallback) { - if (mRecentsModel.isTaskListValid(mTaskListChangeId)) { - // Current task list is already up to date. No need to update. + if (!needsToLoad()) { if (onLoadedCallback != null) { onLoadedCallback.accept(mTaskList); } diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java index c742be3e85..c06b6ec416 100644 --- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java +++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java @@ -166,9 +166,13 @@ public final class IconRecentsView extends FrameLayout { */ public void onBeginTransitionToOverview() { mTaskRecyclerView.scheduleLayoutAnimation(); + + // Load any task changes + if (!mTaskLoader.needsToLoad()) { + return; + } mTaskAdapter.setIsShowingLoadingUi(true); mTaskAdapter.notifyDataSetChanged(); - // Load any task changes mTaskLoader.loadTaskList(tasks -> { mTaskAdapter.setIsShowingLoadingUi(false); // TODO: Animate the loading UI out and the loaded data in.