Merge "Indices correction inside RecentsView" into main

This commit is contained in:
Treehugger Robot
2025-02-18 17:02:45 -08:00
committed by Android (Google) Code Review
3 changed files with 24 additions and 34 deletions
@@ -2013,7 +2013,7 @@ public abstract class RecentsView<
}
// If the list changed, maybe the focused task doesn't exist anymore.
if (newFocusedTaskView == null) {
newFocusedTaskView = mUtils.getExpectedFocusedTask();
newFocusedTaskView = mUtils.getFirstNonDesktopTaskView();
}
}
setFocusedTaskViewId(
@@ -2119,15 +2119,6 @@ public abstract class RecentsView<
return mTaskViewCount;
}
/**
* Transverse RecentsView children to calculate the amount of DesktopTaskViews.
*
* @return Number of children that are instances of DesktopTaskView
*/
private int getDesktopTaskViewCount() {
return mUtils.getDesktopTaskViewCount();
}
/** Counts {@link TaskView}s that are not {@link DesktopTaskView} instances. */
public int getNonDesktopTaskViewCount() {
return mUtils.getNonDesktopTaskViewCount();
@@ -3079,7 +3070,7 @@ public abstract class RecentsView<
focusedTaskViewId = INVALID_TASK_ID;
} else if (enableLargeDesktopWindowingTile()
&& getRunningTaskView() instanceof DesktopTaskView) {
TaskView focusedTaskView = getTaskViewAt(getDesktopTaskViewCount());
TaskView focusedTaskView = mUtils.getFirstNonDesktopTaskView();
focusedTaskViewId =
focusedTaskView != null ? focusedTaskView.getTaskViewId() : INVALID_TASK_ID;
} else {
@@ -3950,9 +3941,9 @@ public abstract class RecentsView<
int distanceFromDismissedTask = 1;
int slidingTranslation = 0;
if (isSlidingTasks) {
int nextSnappedPage = isStagingFocusedTask
? indexOfChild(mUtils.getFirstSmallTaskView())
: mUtils.getDesktopTaskViewCount();
int nextSnappedPage = indexOfChild(isStagingFocusedTask
? mUtils.getFirstSmallTaskView()
: mUtils.getFirstNonDesktopTaskView());
slidingTranslation = getPagedOrientationHandler().getPrimaryScroll(this)
- getScrollForPage(nextSnappedPage);
slidingTranslation += mIsRtl ? newClearAllShortTotalWidthTranslation
@@ -3978,7 +3969,7 @@ public abstract class RecentsView<
Math.abs(i - dismissedIndex),
scrollDiff,
anim,
splitTimings, i);
splitTimings);
needsCurveUpdates = true;
}
} else if (child instanceof TaskView taskView) {
@@ -4354,8 +4345,7 @@ public abstract class RecentsView<
int indexDiff,
int scrollDiffPerPage,
PendingAnimation pendingAnimation,
SplitAnimationTimings splitTimings,
int index) {
SplitAnimationTimings splitTimings) {
// No need to translate the AddDesktopButton on dismissing a TaskView, which should be
// always at the right most position, even when dismissing the last TaskView.
if (view instanceof AddDesktopButton) {
@@ -6277,12 +6267,12 @@ public abstract class RecentsView<
}
@Override
protected int getChildVisibleSize(int index) {
final TaskView taskView = getTaskViewAt(index);
protected int getChildVisibleSize(int childIndex) {
final TaskView taskView = getTaskViewAt(childIndex);
if (taskView == null) {
return super.getChildVisibleSize(index);
return super.getChildVisibleSize(childIndex);
}
return (int) (super.getChildVisibleSize(index) * taskView.getSizeAdjustment(
return (int) (super.getChildVisibleSize(childIndex) * taskView.getSizeAdjustment(
showAsFullscreen()));
}
@@ -6341,7 +6331,7 @@ public abstract class RecentsView<
* Returns how many pixels the page is offset on the currently laid out dominant axis.
*/
private int getUnclampedScrollOffset(int pageIndex) {
if (pageIndex == -1) {
if (pageIndex == INVALID_PAGE) {
return 0;
}
// Don't dampen the scroll (due to overscroll) if the adjacent tasks are offscreen, so that