Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 940fbe1e authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

Merge "Avoid instantiating unnecessary OverviewTask in getCurrentTask loop" into main

parents 15bbd177 7d237cd8
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -236,14 +236,13 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
        final List<UiObject2> taskViews = getTasks();
        mLauncher.assertNotEquals("Unable to find a task", 0, taskViews.size());

        final List<OverviewTask> overviewTasks = taskViews.stream().map(
                task -> new OverviewTask(mLauncher, task, this)).toList();
        // The widest, and most top-right task should be the current task
        return Collections.max(overviewTasks,
                Comparator.comparingInt(OverviewTask::getVisibleWidth)
                        .thenComparingInt(OverviewTask::getTaskCenterX)
                        .thenComparing(
                                Comparator.comparing(OverviewTask::getTaskCenterY).reversed()));
        UiObject2 currentTask = Collections.max(taskViews,
                Comparator.comparingInt((UiObject2 t) -> t.getParent().getVisibleBounds().width())
                        .thenComparingInt((UiObject2 t) -> t.getParent().getVisibleCenter().x)
                        .thenComparing(Comparator.comparing(
                                (UiObject2 t) -> t.getParent().getVisibleCenter().y).reversed()));
        return new OverviewTask(mLauncher, currentTask, this);
    }

    /** Returns an overview task matching TestActivity {@param activityNumber}. */