return null;
}
+ /**
+ * Returns the task in stack tasks which should be launched next if Recents are toggled
+ * again, or null if there is no task to be launched.
+ */
+ public Task getNextLaunchTarget() {
+ int taskCount = getTaskCount();
+ if (taskCount == 0) {
+ return null;
+ }
+ int launchTaskIndex = indexOfStackTask(getLaunchTarget());
+ if (launchTaskIndex != -1) {
+ launchTaskIndex = Math.max(0, launchTaskIndex - 1);
+ } else {
+ launchTaskIndex = getTaskCount() - 1;
+ }
+ return getStackTasks().get(launchTaskIndex);
+ }
+
/** Returns the index of this task in this current task stack */
public int indexOfStackTask(Task t) {
return mStackTaskList.indexOf(t);
return;
}
- int launchTaskIndex = mStack.indexOfStackTask(mStack.getLaunchTarget());
- if (launchTaskIndex != -1) {
- launchTaskIndex = Math.max(0, launchTaskIndex - 1);
- } else {
- launchTaskIndex = mStack.getTaskCount() - 1;
- }
- if (launchTaskIndex != -1) {
+ final Task launchTask = mStack.getNextLaunchTarget();
+ if (launchTask != null) {
// Stop all animations
cancelAllTaskViewAnimations();
- final Task launchTask = mStack.getStackTasks().get(launchTaskIndex);
float curScroll = mStackScroller.getStackScroll();
float targetScroll = mLayoutAlgorithm.getStackScrollForTaskAtInitialOffset(launchTask);
float absScrollDiff = Math.abs(targetScroll - curScroll);