public void preloadRecents() {
// Preload only the raw task list into a new load plan (which will be consumed by the
- // RecentsActivity) only if there is a task to animate to.
- SystemServicesProxy ssp = Recents.getSystemServices();
- MutableBoolean isHomeStackVisible = new MutableBoolean(true);
- if (!ssp.isRecentsActivityVisible(isHomeStackVisible)) {
- ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
- if (runningTask == null) {
- return;
- }
+ // RecentsActivity) only if there is a task to animate to. Post this to ensure that we
+ // don't block the touch feedback on the nav bar button which triggers this.
+ mHandler.post(() -> {
+ SystemServicesProxy ssp = Recents.getSystemServices();
+ MutableBoolean isHomeStackVisible = new MutableBoolean(true);
+ if (!ssp.isRecentsActivityVisible(isHomeStackVisible)) {
+ ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
+ if (runningTask == null) {
+ return;
+ }
- RecentsTaskLoader loader = Recents.getTaskLoader();
- sInstanceLoadPlan = loader.createLoadPlan(mContext);
- loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible.value);
- TaskStack stack = sInstanceLoadPlan.getTaskStack();
- if (stack.getTaskCount() > 0) {
- // Only preload the icon (but not the thumbnail since it may not have been taken for
- // the pausing activity)
- preloadIcon(runningTask.id);
-
- // At this point, we don't know anything about the stack state. So only calculate
- // the dimensions of the thumbnail that we need for the transition into Recents, but
- // do not draw it until we construct the activity options when we start Recents
- updateHeaderBarLayout(stack, null /* window rect override*/);
+ RecentsTaskLoader loader = Recents.getTaskLoader();
+ sInstanceLoadPlan = loader.createLoadPlan(mContext);
+ loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible.value);
+ TaskStack stack = sInstanceLoadPlan.getTaskStack();
+ if (stack.getTaskCount() > 0) {
+ // Only preload the icon (but not the thumbnail since it may not have been taken
+ // for the pausing activity)
+ preloadIcon(runningTask.id);
+
+ // At this point, we don't know anything about the stack state. So only
+ // calculate the dimensions of the thumbnail that we need for the transition
+ // into Recents, but do not draw it until we construct the activity options when
+ // we start Recents
+ updateHeaderBarLayout(stack, null /* window rect override*/);
+ }
}
- }
+ });
}
public void cancelPreloadingRecents() {