Merge "Make large task tile snap to position after scrolling" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
da290bcacf
@@ -113,6 +113,12 @@ class RecentsViewUtils {
|
||||
it.isVisibleInCarousel(runningTaskView, nonRunningTaskCarouselHidden)
|
||||
}
|
||||
|
||||
/** Returns if any small tasks are fully visible */
|
||||
fun isAnySmallTaskFullyVisible(
|
||||
taskViews: Iterable<TaskView>,
|
||||
isTaskViewFullyVisible: (TaskView) -> Boolean,
|
||||
): Boolean = taskViews.any { !it.isLargeTile && isTaskViewFullyVisible(it) }
|
||||
|
||||
/** Returns the current list of [TaskView] children. */
|
||||
fun getTaskViews(taskViewCount: Int, requireTaskViewAt: (Int) -> TaskView): Iterable<TaskView> =
|
||||
(0 until taskViewCount).map(requireTaskViewAt)
|
||||
|
||||
@@ -1706,10 +1706,11 @@ public abstract class RecentsView<
|
||||
return;
|
||||
}
|
||||
TaskView taskView = getTaskViewAt(mNextPage);
|
||||
// Snap to fully visible focused task and clear all button.
|
||||
boolean shouldSnapToLargeTask = taskView != null && taskView.isLargeTile()
|
||||
&& isTaskViewFullyVisible(taskView);
|
||||
&& !mUtils.isAnySmallTaskFullyVisible(getTaskViews(),
|
||||
this::isTaskViewFullyVisible);
|
||||
boolean shouldSnapToClearAll = mNextPage == indexOfChild(mClearAllButton);
|
||||
// Snap to large tile when grid tasks aren't fully visible or the clear all button.
|
||||
if (!shouldSnapToLargeTask && !shouldSnapToClearAll) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user