From 2bd36dd3260ac7b88fa849aba19eae115ba9d5cd Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 5 Apr 2019 13:25:11 -0700 Subject: [PATCH] Don't put up loading UI if load isn't necessary. Do not put up the loading UI when we don't need to load (whether that's because we're already up to date or there is already a load in progress) Bug: 114136250 Test: Manual; go to recents and see that it doesn't load when updated Change-Id: Idbcc3731e4ecab8f67b7b5b07a98cb112ed4e07a --- .../com/android/quickstep/TaskListLoader.java | 16 +++++++++++++--- .../android/quickstep/views/IconRecentsView.java | 6 +++++- 2 files changed, 18 insertions(+), 4 deletions(-) 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.