Reduce extraneous loading of task snapshots/icons
- Skip handling loading visible task data after resetting overview, we currently keep the tasks bound to their task views (some calls are not synchronous with the lifecycle of recents, can be changed later), so the next call to loadVisibleTasks before the tasks have been loaded would load snapshots for old tasks - Skip loading tasks if the previously requested load plan is still valid, this can happen because setCurrentTask() will be called multiple times during swipe up Bug: 117603579 Change-Id: Ie58ded14dedbb3934d08163ca7939d89310c3ecf
This commit is contained in:
parent
f307b6032e
commit
4292c3038b
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue