From 6c40e8548e676d9150844f8281bcb25107de6760 Mon Sep 17 00:00:00 2001 From: Jeremy Sim Date: Thu, 2 Feb 2023 11:20:08 +0800 Subject: [PATCH] Refactor getIndexOfTask() to getTaskAttributesById() This change is a minor cleanup to make a function more streamlined. Bug: 265244769 Test: Manual, confirmed no regression Change-Id: I557246a7633b10701adf75aaba6930f25e1c30aa --- .../launcher3/taskbar/TaskbarUIController.java | 5 ++--- .../com/android/quickstep/views/TaskView.java | 16 +++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java index 87fa6f318f..bfdf156dbd 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java @@ -204,12 +204,11 @@ public class TaskbarUIController { if (foundTaskView != null) { // There is already a running app of this type, use that as second app. // Get index of task (0 or 1), in case it's a GroupedTaskView - int indexOfTask = foundTaskView.getIndexOfTask(foundTask.key.id); TaskIdAttributeContainer taskAttributes = - foundTaskView.getTaskIdAttributeContainers()[indexOfTask]; + foundTaskView.getTaskAttributesById(foundTask.key.id); recents.confirmSplitSelect( foundTaskView, - taskAttributes.getTask(), + foundTask, taskAttributes.getIconView().getDrawable(), taskAttributes.getThumbnailView(), taskAttributes.getThumbnailView().getThumbnail(), diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index b23c87349c..baef722f83 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -601,16 +601,18 @@ public class TaskView extends FrameLayout implements Reusable { } /** - * Finds the index of a given taskId within this TaskView, or -1 if the TaskView does not - * contain it. For grouped tasks (of two), this is 0 or 1; for solo tasks, it is 0. + * Returns the TaskIdAttributeContainer corresponding to a given taskId, or null if the TaskView + * does not contain a Task with that ID. */ - public int getIndexOfTask(int taskId) { - for (int i = 0; i < mTaskIdContainer.length; i++) { - if (mTaskIdContainer[i] == taskId) { - return i; + @Nullable + public TaskIdAttributeContainer getTaskAttributesById(int taskId) { + for (TaskIdAttributeContainer attributes : mTaskIdAttributeContainer) { + if (attributes.getTask().key.id == taskId) { + return attributes; } } - return -1; + + return null; } public TaskThumbnailView getThumbnail() {