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
private int mRunningTaskId = -1;
@ -447,6 +449,7 @@ public abstract class RecentsView<T extends BaseActivity> 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<T extends BaseActivity> 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<T extends BaseActivity> extends PagedView impl
mRunningTaskId = -1;
mRunningTaskTileHidden = false;
mIgnoreResetTaskId = -1;
mRequestedLoadPlanId = -1;
unloadVisibleTaskData();
setCurrentPage(0);
@ -686,8 +691,8 @@ public abstract class RecentsView<T extends BaseActivity> 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<T extends BaseActivity> 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() {