Merge "Reduce extraneous loading of task snapshots/icons" into ub-launcher3-master

This commit is contained in:
Winson Chung 2018-10-11 23:09:42 +00:00 committed by Android (Google) Code Review
commit 181f9865ca
1 changed files with 12 additions and 7 deletions

View File

@ -229,7 +229,9 @@ public abstract class RecentsView<T extends BaseActivity> 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 // Only valid until the launcher state changes to NORMAL
private int mRunningTaskId = -1; private int mRunningTaskId = -1;
@ -447,6 +449,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
mPendingAnimation.addEndListener((onEndListener) -> applyLoadPlan(loadPlan)); mPendingAnimation.addEndListener((onEndListener) -> applyLoadPlan(loadPlan));
return; return;
} }
TaskStack stack = loadPlan != null ? loadPlan.getTaskStack() : null; TaskStack stack = loadPlan != null ? loadPlan.getTaskStack() : null;
if (stack == null) { if (stack == null) {
removeAllViews(); removeAllViews();
@ -615,8 +618,9 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
* and unloads the associated task data for tasks that are no longer visible. * and unloads the associated task data for tasks that are no longer visible.
*/ */
public void loadVisibleTaskData() { public void loadVisibleTaskData() {
if (!mOverviewStateEnabled) { if (!mOverviewStateEnabled || mRequestedLoadPlanId == -1) {
// Skip loading visible task data if we've already left the overview state // 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; return;
} }
@ -675,6 +679,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
mRunningTaskId = -1; mRunningTaskId = -1;
mRunningTaskTileHidden = false; mRunningTaskTileHidden = false;
mIgnoreResetTaskId = -1; mIgnoreResetTaskId = -1;
mRequestedLoadPlanId = -1;
unloadVisibleTaskData(); unloadVisibleTaskData();
setCurrentPage(0); setCurrentPage(0);
@ -686,8 +691,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
* Reloads the view if anything in recents changed. * Reloads the view if anything in recents changed.
*/ */
public void reloadIfNeeded() { public void reloadIfNeeded() {
if (!mModel.isLoadPlanValid(mLoadPlanId)) { if (!mModel.isLoadPlanValid(mRequestedLoadPlanId)) {
mLoadPlanId = mModel.loadTasks(mRunningTaskId, this::applyLoadPlan); mRequestedLoadPlanId = mModel.loadTasks(mRunningTaskId, this::applyLoadPlan);
} }
} }
@ -748,8 +753,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
setCurrentPage(0); setCurrentPage(0);
// Load the tasks (if the loading is already // Load the tasks
mLoadPlanId = mModel.loadTasks(runningTaskId, this::applyLoadPlan); reloadIfNeeded();
} }
public void showNextTask() { public void showNextTask() {