From 4e678ff6d5bb6c12ab8e2a76c00600eb61de897d Mon Sep 17 00:00:00 2001 From: Fedor Kudasov Date: Thu, 11 Nov 2021 21:10:03 +0000 Subject: [PATCH] Separate getTaskViewAt usage getTaskViewAt is used in two different contexts with different assumptions: 1. In the context of iterating over the all TaskViews, where the valid tasks indices are know. 2. In the context of requesting some TaskView by index, where the caller expects null when the input index is invalid. The nullability status of the method differs in these contexts and therefore getTaskViewAt usage can be separated into two different methods. Bug: 205828770 Test: m LauncherGoResLib Change-Id: I42c04c115c309f1849f9dfbb05c74b9b080acf13 (cherry picked from commit 4da3b4bdddbbff7a0dee1f57b3a74c616231e100) --- .../android/quickstep/views/RecentsView.java | 84 +++++++++++-------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 3aa8d4637b..e270cb7c1c 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -107,6 +107,7 @@ import android.widget.ListView; import android.widget.OverScroller; import android.widget.Toast; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.UiThread; import androidx.core.graphics.ColorUtils; @@ -181,6 +182,7 @@ import com.android.wm.shell.pip.IPipAnimationListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Objects; import java.util.function.Consumer; /** @@ -822,7 +824,7 @@ public abstract class RecentsView 0) { - targetPage = indexOfChild(getTaskViewAt(0)); + targetPage = indexOfChild(requireTaskViewAt(0)); } } else if (currentTaskId != -1) { currentTaskView = getTaskViewByTaskId(currentTaskId); @@ -1452,7 +1454,7 @@ public abstract class RecentsView= 0; i--) { - removeView(getTaskViewAt(i)); + removeView(requireTaskViewAt(i)); } if (indexOfChild(mClearAllButton) != -1) { removeView(mClearAllButton); @@ -1498,7 +1500,7 @@ public abstract class RecentsView= 0; i--) { - TaskView taskView = getTaskViewAt(i); + TaskView taskView = requireTaskViewAt(i); if (mIgnoreResetTaskId != taskView.getTaskIds()[0]) { taskView.resetViewTransforms(); taskView.setIconScaleAndDim(mTaskIconScaledDown ? 0 : 1); @@ -1529,7 +1531,7 @@ public abstract class RecentsView 0 && mTopRowIdSet.size() >= (taskCount - 1) / 2f; // Pick the next focused task from the preferred row. for (int i = 0; i < taskCount; i++) { - TaskView taskView = getTaskViewAt(i); + TaskView taskView = requireTaskViewAt(i); if (taskView == dismissedTaskView) { continue; } @@ -2816,7 +2818,7 @@ public abstract class RecentsView= 0; i--) { - TaskView child = getTaskViewAt(i); + TaskView child = requireTaskViewAt(i); int[] childTaskIds = child.getTaskIds(); if (!mRunningTaskTileHidden || (childTaskIds[0] != runningTaskId && childTaskIds[1] != runningTaskId)) { @@ -3542,6 +3544,14 @@ public abstract class RecentsView 0) { - final View taskView = getTaskViewAt(0); - getTaskViewAt(count - 1).getHitRect(mTaskViewDeadZoneRect); + final View taskView = requireTaskViewAt(0); + requireTaskViewAt(count - 1).getHitRect(mTaskViewDeadZoneRect); mTaskViewDeadZoneRect.union(taskView.getLeft(), taskView.getTop(), taskView.getRight(), taskView.getBottom()); } @@ -4548,7 +4558,7 @@ public abstract class RecentsView