Reducing numerous extraneous allocations.
Change-Id: Icca49f12a9e0be08eb6d4dbbbf2fd5994a3a25a5
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 40864c9..074fe68 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -585,6 +585,7 @@
@Override
public void onUserInteraction() {
+ // TODO: Prevent creating so many events here
final RecentsDebugFlags debugFlags = Recents.getDebugFlags();
EventBus.getDefault().send(new UserInteractionEvent(debugFlags.isFastToggleRecentsEnabled()
&& debugFlags.isFastToggleIndicatorEnabled()));
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/EventBus.java b/packages/SystemUI/src/com/android/systemui/recents/events/EventBus.java
index b0c8ff3..212c7f4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/EventBus.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/EventBus.java
@@ -290,6 +290,28 @@
}
/**
+ * An event that can be reusable, only used for situations where we want to reduce memory
+ * allocations when events are sent frequently (ie. on scroll).
+ */
+ public static class ReusableEvent extends Event {
+
+ private int mDispatchCount;
+
+ protected ReusableEvent() {}
+
+ @Override
+ void onPostDispatch() {
+ super.onPostDispatch();
+ mDispatchCount++;
+ }
+
+ @Override
+ protected Object clone() throws CloneNotSupportedException {
+ throw new CloneNotSupportedException();
+ }
+ }
+
+ /**
* An inter-process event super class that allows us to track user state across subscriber
* invocations.
*/
@@ -770,8 +792,11 @@
event.onPreDispatch();
// We need to clone the list in case a subscriber unregisters itself during traversal
+ // TODO: Investigate whether we can skip the object creation here
eventHandlers = (ArrayList<EventHandler>) eventHandlers.clone();
- for (final EventHandler eventHandler : eventHandlers) {
+ int eventHandlerCount = eventHandlers.size();
+ for (int i = 0; i < eventHandlerCount; i++) {
+ final EventHandler eventHandler = eventHandlers.get(i);
if (eventHandler.subscriber.getReference() != null) {
if (event.requiresPost) {
mHandler.post(new Runnable() {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/ui/StackViewScrolledEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/ui/StackViewScrolledEvent.java
index cb5011a..ad9feb6 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/ui/StackViewScrolledEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/ui/StackViewScrolledEvent.java
@@ -16,16 +16,21 @@
package com.android.systemui.recents.events.ui;
+import android.util.MutableInt;
import com.android.systemui.recents.events.EventBus;
/**
* This is sent whenever a new scroll gesture happens on a stack view.
*/
-public class StackViewScrolledEvent extends EventBus.Event {
+public class StackViewScrolledEvent extends EventBus.ReusableEvent {
- public final int yMovement;
+ public final MutableInt yMovement;
- public StackViewScrolledEvent(int yMovement) {
- this.yMovement = yMovement;
+ public StackViewScrolledEvent() {
+ yMovement = new MutableInt(0);
+ }
+
+ public void updateY(int y) {
+ yMovement.value = y;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
index d8dfce5..0028ca7 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
@@ -25,7 +25,9 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.util.ArraySet;
+
import com.android.systemui.Prefs;
+import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.misc.SystemServicesProxy;
@@ -120,6 +122,8 @@
preloadRawTasks(isTopTaskHome);
}
+ String dismissDescFormat = mContext.getString(
+ R.string.accessibility_recents_item_will_be_dismissed);
long lastStackActiveTime = Prefs.getLong(mContext,
Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, 0);
long newLastStackActiveTime = -1;
@@ -143,6 +147,7 @@
// Load the title, icon, and color
String title = loader.getAndUpdateActivityTitle(taskKey, t.taskDescription);
String contentDescription = loader.getAndUpdateContentDescription(taskKey, title, res);
+ String dismissDescription = String.format(dismissDescFormat, contentDescription);
Drawable icon = isStackTask
? loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, res, false)
: null;
@@ -151,8 +156,8 @@
// Add the task to the stack
Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon,
- thumbnail, title, contentDescription, activityColor, !isStackTask,
- t.bounds, t.taskDescription);
+ thumbnail, title, contentDescription, dismissDescription, activityColor,
+ !isStackTask, t.bounds, t.taskDescription);
allTasks.add(task);
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
index f7e2b9d..29e7077 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
@@ -54,6 +54,8 @@
public long firstActiveTime;
public long lastActiveTime;
+ private int mHashCode;
+
public TaskKey(int id, int stackId, Intent intent, int userId, long firstActiveTime,
long lastActiveTime) {
this.id = id;
@@ -62,6 +64,12 @@
this.userId = userId;
this.firstActiveTime = firstActiveTime;
this.lastActiveTime = lastActiveTime;
+ updateHashCode();
+ }
+
+ public void setStackId(int stackId) {
+ this.stackId = stackId;
+ updateHashCode();
}
public ComponentName getComponent() {
@@ -79,7 +87,7 @@
@Override
public int hashCode() {
- return Objects.hash(id, stackId, userId);
+ return mHashCode;
}
@Override
@@ -90,6 +98,10 @@
+ "lat: " + lastActiveTime + ", "
+ getComponent().getPackageName();
}
+
+ private void updateHashCode() {
+ mHashCode = Objects.hash(id, stackId, userId);
+ }
}
public TaskKey key;
@@ -113,6 +125,7 @@
public Bitmap thumbnail;
public String title;
public String contentDescription;
+ public String dismissDescription;
public int colorPrimary;
public boolean useLightOnPrimaryColor;
@@ -139,9 +152,9 @@
}
public Task(TaskKey key, int affiliationTaskId, int affiliationColor, Drawable icon,
- Bitmap thumbnail, String title, String contentDescription, int colorPrimary,
- boolean isHistorical, Rect bounds,
- ActivityManager.TaskDescription taskDescription) {
+ Bitmap thumbnail, String title, String contentDescription,
+ String dismissDescription, int colorPrimary, boolean isHistorical,
+ Rect bounds, ActivityManager.TaskDescription taskDescription) {
boolean isInAffiliationGroup = (affiliationTaskId != key.id);
boolean hasAffiliationGroupColor = isInAffiliationGroup && (affiliationColor != 0);
this.key = key;
@@ -151,6 +164,7 @@
this.thumbnail = thumbnail;
this.title = title;
this.contentDescription = contentDescription;
+ this.dismissDescription = dismissDescription;
this.colorPrimary = hasAffiliationGroupColor ? affiliationColor : colorPrimary;
this.useLightOnPrimaryColor = Utilities.computeContrastBetweenColors(this.colorPrimary,
Color.WHITE) > 3f;
@@ -169,6 +183,7 @@
this.thumbnail = o.thumbnail;
this.title = o.title;
this.contentDescription = o.contentDescription;
+ this.dismissDescription = o.dismissDescription;
this.colorPrimary = o.colorPrimary;
this.useLightOnPrimaryColor = o.useLightOnPrimaryColor;
this.bounds = o.bounds;
@@ -201,7 +216,7 @@
* Updates the stack id of this task.
*/
public void setStackId(int stackId) {
- key.stackId = stackId;
+ key.setStackId(stackId);
int callbackCount = mCallbacks.size();
for (int i = 0; i < callbackCount; i++) {
mCallbacks.get(i).onTaskStackIdChanged();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskGrouping.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskGrouping.java
index 288f07c..15f6b0a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskGrouping.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskGrouping.java
@@ -1,7 +1,8 @@
package com.android.systemui.recents.model;
+import android.util.ArrayMap;
+
import java.util.ArrayList;
-import java.util.HashMap;
/** Represents a grouping of tasks witihin a stack. */
public class TaskGrouping {
@@ -11,7 +12,7 @@
Task.TaskKey mFrontMostTaskKey;
ArrayList<Task.TaskKey> mTaskKeys = new ArrayList<Task.TaskKey>();
- HashMap<Task.TaskKey, Integer> mTaskKeyIndices = new HashMap<Task.TaskKey, Integer>();
+ ArrayMap<Task.TaskKey, Integer> mTaskKeyIndices = new ArrayMap<>();
/** Creates a group with a specified affiliation. */
public TaskGrouping(int affiliation) {
@@ -94,9 +95,10 @@
return;
}
+ int taskCount = mTaskKeys.size();
mFrontMostTaskKey = mTaskKeys.get(mTaskKeys.size() - 1);
mTaskKeyIndices.clear();
- int taskCount = mTaskKeys.size();
+ mTaskKeyIndices.ensureCapacity(taskCount);
for (int i = 0; i < taskCount; i++) {
Task.TaskKey k = mTaskKeys.get(i);
mTaskKeyIndices.put(k, i);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
index e97188b..829ec56 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
@@ -29,6 +29,8 @@
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.ColorDrawable;
+import android.util.ArrayMap;
+import android.util.ArraySet;
import android.util.SparseArray;
import android.view.animation.Interpolator;
import com.android.internal.policy.DockedDividerUtils;
@@ -44,8 +46,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Random;
@@ -53,11 +53,11 @@
import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
+import static android.view.WindowManager.DOCKED_BOTTOM;
+import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.DOCKED_LEFT;
import static android.view.WindowManager.DOCKED_RIGHT;
import static android.view.WindowManager.DOCKED_TOP;
-import static android.view.WindowManager.DOCKED_BOTTOM;
-import static android.view.WindowManager.DOCKED_INVALID;
/**
@@ -73,17 +73,14 @@
*/
class FilteredTaskList {
- private static final String TAG = "FilteredTaskList";
- private static final boolean DEBUG = false;
-
ArrayList<Task> mTasks = new ArrayList<>();
ArrayList<Task> mFilteredTasks = new ArrayList<>();
- HashMap<Task.TaskKey, Integer> mTaskIndices = new HashMap<>();
+ ArrayMap<Task.TaskKey, Integer> mTaskIndices = new ArrayMap<>();
TaskFilter mFilter;
/** Sets the task filter, saving the current touch state */
boolean setFilter(TaskFilter filter) {
- ArrayList<Task> prevFilteredTasks = new ArrayList<Task>(mFilteredTasks);
+ ArrayList<Task> prevFilteredTasks = new ArrayList<>(mFilteredTasks);
mFilter = filter;
updateFilteredTasks();
if (!prevFilteredTasks.equals(mFilteredTasks)) {
@@ -194,8 +191,9 @@
/** Updates the mapping of tasks to indices. */
private void updateFilteredTaskIndices() {
- mTaskIndices.clear();
int taskCount = mFilteredTasks.size();
+ mTaskIndices.clear();
+ mTaskIndices.ensureCapacity(taskCount);
for (int i = 0; i < taskCount; i++) {
Task t = mFilteredTasks.get(i);
mTaskIndices.put(t.key, i);
@@ -438,7 +436,7 @@
TaskStackCallbacks mCb;
ArrayList<TaskGrouping> mGroups = new ArrayList<>();
- HashMap<Integer, TaskGrouping> mAffinitiesGroups = new HashMap<>();
+ ArrayMap<Integer, TaskGrouping> mAffinitiesGroups = new ArrayMap<>();
public TaskStack() {
// Ensure that we only show non-docked tasks
@@ -551,8 +549,8 @@
*/
public void setTasks(List<Task> tasks, boolean notifyStackChanges) {
// Compute a has set for each of the tasks
- HashMap<Task.TaskKey, Task> currentTasksMap = createTaskKeyMapFromList(mRawTaskList);
- HashMap<Task.TaskKey, Task> newTasksMap = createTaskKeyMapFromList(tasks);
+ ArrayMap<Task.TaskKey, Task> currentTasksMap = createTaskKeyMapFromList(mRawTaskList);
+ ArrayMap<Task.TaskKey, Task> newTasksMap = createTaskKeyMapFromList(tasks);
ArrayList<Task> newTasks = new ArrayList<>();
@@ -759,7 +757,7 @@
*/
public void createAffiliatedGroupings(Context context) {
if (RecentsDebugFlags.Static.EnableSimulatedTaskGroups) {
- HashMap<Task.TaskKey, Task> taskMap = new HashMap<Task.TaskKey, Task>();
+ ArrayMap<Task.TaskKey, Task> taskMap = new ArrayMap<>();
// Sort all tasks by increasing firstActiveTime of the task
ArrayList<Task> tasks = mStackTaskList.getTasks();
Collections.sort(tasks, new Comparator<Task>() {
@@ -824,9 +822,10 @@
mStackTaskList.set(tasks);
} else {
// Create the task groups
- HashMap<Task.TaskKey, Task> tasksMap = new HashMap<>();
+ ArrayMap<Task.TaskKey, Task> tasksMap = new ArrayMap<>();
ArrayList<Task> tasks = mStackTaskList.getTasks();
int taskCount = tasks.size();
+ tasksMap.ensureCapacity(taskCount);
for (int i = 0; i < taskCount; i++) {
Task t = tasks.get(i);
TaskGrouping group;
@@ -868,12 +867,12 @@
* Computes the components of tasks in this stack that have been removed as a result of a change
* in the specified package.
*/
- public HashSet<ComponentName> computeComponentsRemoved(String packageName, int userId) {
+ public ArraySet<ComponentName> computeComponentsRemoved(String packageName, int userId) {
// Identify all the tasks that should be removed as a result of the package being removed.
// Using a set to ensure that we callback once per unique component.
SystemServicesProxy ssp = Recents.getSystemServices();
- HashSet<ComponentName> existingComponents = new HashSet<>();
- HashSet<ComponentName> removedComponents = new HashSet<>();
+ ArraySet<ComponentName> existingComponents = new ArraySet<>();
+ ArraySet<ComponentName> removedComponents = new ArraySet<>();
ArrayList<Task.TaskKey> taskKeys = getTaskKeys();
for (Task.TaskKey t : taskKeys) {
// Skip if this doesn't apply to the current user
@@ -911,8 +910,8 @@
/**
* Given a list of tasks, returns a map of each task's key to the task.
*/
- private HashMap<Task.TaskKey, Task> createTaskKeyMapFromList(List<Task> tasks) {
- HashMap<Task.TaskKey, Task> map = new HashMap<>();
+ private ArrayMap<Task.TaskKey, Task> createTaskKeyMapFromList(List<Task> tasks) {
+ ArrayMap<Task.TaskKey, Task> map = new ArrayMap<>(tasks.size());
int taskCount = tasks.size();
for (int i = 0; i < taskCount; i++) {
Task task = tasks.get(i);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java
index 890713e..d3a1e91 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java
@@ -17,13 +17,12 @@
package com.android.systemui.recents.views;
import android.content.Context;
-import android.graphics.Rect;
import android.graphics.RectF;
+import android.util.ArrayMap;
import com.android.systemui.R;
import com.android.systemui.recents.model.Task;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
/**
@@ -32,7 +31,7 @@
public class FreeformWorkspaceLayoutAlgorithm {
// Optimization, allows for quick lookup of task -> rect
- private HashMap<Task.TaskKey, RectF> mTaskRectMap = new HashMap<>();
+ private ArrayMap<Task.TaskKey, RectF> mTaskRectMap = new ArrayMap<>();
private int mTaskPadding;
@@ -49,6 +48,7 @@
public void update(List<Task> freeformTasks, TaskStackLayoutAlgorithm stackLayout) {
Collections.reverse(freeformTasks);
mTaskRectMap.clear();
+ mTaskRectMap.ensureCapacity(freeformTasks.size());
int numFreeformTasks = stackLayout.mNumFreeformTasks;
if (!freeformTasks.isEmpty()) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
index 1e3baa6..1ecadae 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
@@ -21,6 +21,8 @@
import android.content.res.Resources;
import android.graphics.Path;
import android.graphics.Rect;
+import android.util.ArrayMap;
+import android.util.ArraySet;
import android.util.FloatProperty;
import android.util.Property;
import android.view.animation.AnimationUtils;
@@ -37,9 +39,6 @@
import com.android.systemui.recents.model.TaskStack;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
/**
* Used to describe a visible range that can be normalized to [0, 1].
@@ -272,7 +271,7 @@
int mMaxTranslationZ;
// Optimization, allows for quick lookup of task -> index
- private HashMap<Task.TaskKey, Integer> mTaskIndexMap = new HashMap<>();
+ private ArrayMap<Task.TaskKey, Integer> mTaskIndexMap = new ArrayMap<>();
// The freeform workspace layout
FreeformWorkspaceLayoutAlgorithm mFreeformLayoutAlgorithm;
@@ -375,7 +374,7 @@
* Computes the minimum and maximum scroll progress values and the progress values for each task
* in the stack.
*/
- void update(TaskStack stack, HashSet<Task> ignoreTasksSet) {
+ void update(TaskStack stack, ArraySet<Task> ignoreTasksSet) {
SystemServicesProxy ssp = Recents.getSystemServices();
// Clear the progress map
@@ -410,6 +409,7 @@
// Put each of the tasks in the progress map at a fixed index (does not need to actually
// map to a scroll position, just by index)
int taskCount = stackTasks.size();
+ mTaskIndexMap.ensureCapacity(taskCount);
for (int i = 0; i < taskCount; i++) {
Task task = stackTasks.get(i);
mTaskIndexMap.put(task.key, i);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index 582698c..9c5756b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -28,6 +28,8 @@
import android.os.Bundle;
import android.os.Parcelable;
import android.provider.Settings;
+import android.util.ArrayMap;
+import android.util.ArraySet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -76,8 +78,6 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
@@ -136,8 +136,8 @@
Rect mStackBounds = new Rect();
int[] mTmpVisibleRange = new int[2];
Rect mTmpRect = new Rect();
- HashMap<Task, TaskView> mTmpTaskViewMap = new HashMap<>();
- HashSet<Task> mTmpTaskSet = new HashSet<>();
+ ArrayMap<Task.TaskKey, TaskView> mTmpTaskViewMap = new ArrayMap<>();
+ ArraySet<Task> mTmpTaskSet = new ArraySet<>();
List<TaskView> mTmpTaskViews = new ArrayList<>();
TaskViewTransform mTmpTransform = new TaskViewTransform();
LayoutInflater mInflater;
@@ -149,8 +149,10 @@
new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- mTaskViewsClipDirty = true;
- invalidate();
+ if (!mTaskViewsClipDirty) {
+ mTaskViewsClipDirty = true;
+ invalidate();
+ }
}
};
@@ -350,7 +352,7 @@
*/
private boolean updateStackTransforms(ArrayList<TaskViewTransform> taskTransforms,
ArrayList<Task> tasks, float stackScroll,
- int[] visibleRangeOut, HashSet<Task> ignoreTasksSet) {
+ int[] visibleRangeOut, ArraySet<Task> ignoreTasksSet) {
int taskTransformCount = taskTransforms.size();
int taskCount = tasks.size();
int frontMostVisibleIndex = -1;
@@ -415,7 +417,7 @@
* they are initially picked up from the pool, when they will be placed in a suitable initial
* position.
*/
- private void bindTaskViewsWithStack(HashSet<Task> ignoreTasksSet) {
+ private void bindTaskViewsWithStack(ArraySet<Task> ignoreTasksSet) {
final float stackScroll = mStackScroller.getStackScroll();
final int[] visibleStackRange = mTmpVisibleRange;
@@ -425,10 +427,11 @@
tasks, stackScroll, visibleStackRange, ignoreTasksSet);
// Return all the invisible children to the pool
- mTmpTaskViewMap.clear();
final List<TaskView> taskViews = getTaskViews();
final int taskViewCount = taskViews.size();
int lastFocusedTaskIndex = -1;
+ mTmpTaskViewMap.clear();
+ mTmpTaskViewMap.ensureCapacity(tasks.size());
for (int i = taskViewCount - 1; i >= 0; i--) {
final TaskView tv = taskViews.get(i);
final Task task = tv.getTask();
@@ -441,7 +444,7 @@
if (task.isFreeformTask() ||
visibleStackRange[1] <= taskIndex && taskIndex <= visibleStackRange[0]) {
- mTmpTaskViewMap.put(task, tv);
+ mTmpTaskViewMap.put(task.key, tv);
} else {
if (mTouchExplorationEnabled) {
lastFocusedTaskIndex = taskIndex;
@@ -467,7 +470,7 @@
continue;
}
- TaskView tv = mTmpTaskViewMap.get(task);
+ TaskView tv = mTmpTaskViewMap.get(task.key);
if (tv == null) {
tv = mViewPool.pickUpViewFromPool(task, task);
if (task.isFreeformTask()) {
@@ -516,8 +519,9 @@
*/
private void updateTaskViewsToLayout(TaskViewAnimation animation, Task... ignoreTasks) {
// Keep track of the ignore tasks
- HashSet<Task> ignoreTasksSet = mTmpTaskSet;
+ ArraySet<Task> ignoreTasksSet = mTmpTaskSet;
ignoreTasksSet.clear();
+ ignoreTasksSet.ensureCapacity(ignoreTasks.length);
Collections.addAll(ignoreTasksSet, ignoreTasks);
// If we had a deferred animation, cancel that
@@ -626,8 +630,9 @@
*/
void updateLayout(boolean boundScrollToNewMinMax, Task... ignoreTasks) {
// Keep track of the ingore tasks
- HashSet<Task> ignoreTasksSet = mTmpTaskSet;
+ ArraySet<Task> ignoreTasksSet = mTmpTaskSet;
ignoreTasksSet.clear();
+ ignoreTasksSet.ensureCapacity(ignoreTasks.length);
Collections.addAll(ignoreTasksSet, ignoreTasks);
// Compute the min and max scroll values
@@ -1355,7 +1360,7 @@
public final void onBusEvent(PackagesChangedEvent event) {
// Compute which components need to be removed
- HashSet<ComponentName> removedComponents = mStack.computeComponentsRemoved(
+ ArraySet<ComponentName> removedComponents = mStack.computeComponentsRemoved(
event.packageName, event.userId);
// For other tasks, just remove them directly if they no longer exist
@@ -1545,7 +1550,7 @@
}
public final void onBusEvent(StackViewScrolledEvent event) {
- mLayoutAlgorithm.updateFocusStateOnScroll(event.yMovement);
+ mLayoutAlgorithm.updateFocusStateOnScroll(event.yMovement.value);
}
public final void onBusEvent(IterateRecentsEvent event) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
index c748efc..31f7559 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
@@ -71,6 +71,7 @@
// Used to calculate when a tap is outside a task view rectangle.
final int mWindowTouchSlop;
+ private final StackViewScrolledEvent mStackViewScrolledEvent = new StackViewScrolledEvent();
SwipeHelper mSwipeHelper;
boolean mInterceptedBySwipeHelper;
@@ -207,7 +208,8 @@
if (DEBUG) {
Log.d(TAG, "scroll: " + curScrollP);
}
- EventBus.getDefault().send(new StackViewScrolledEvent(y - mLastY));
+ mStackViewScrolledEvent.updateY(y - mLastY);
+ EventBus.getDefault().send(mStackViewScrolledEvent);
}
mLastY = y;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index 7abbdb8..3f1d320 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -257,7 +257,9 @@
mTmpAnimators.clear();
toTransform.applyToTaskView(this, mTmpAnimators, toAnimation, !config.fakeShadows);
if (toAnimation.isImmediate()) {
- setTaskProgress(toTransform.p);
+ if (Float.compare(getTaskProgress(), toTransform.p) != 0) {
+ setTaskProgress(toTransform.p);
+ }
if (toAnimation.listener != null) {
toAnimation.listener.onAnimationEnd(null);
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
index 96dadff..e7717ac 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
@@ -142,7 +142,6 @@
Drawable mDarkFullscreenIcon;
int mTaskBarViewLightTextColor;
int mTaskBarViewDarkTextColor;
- String mDismissContentDescription;
// Header background
private HighlightColorDrawable mBackground;
@@ -177,8 +176,6 @@
Resources res = context.getResources();
mLightDismissDrawable = context.getDrawable(R.drawable.recents_dismiss_light);
mDarkDismissDrawable = context.getDrawable(R.drawable.recents_dismiss_dark);
- mDismissContentDescription = context.getString(
- R.string.accessibility_recents_item_will_be_dismissed);
mCornerRadius = res.getDimensionPixelSize(R.dimen.recents_task_view_rounded_corners_radius);
mHighlightHeight = res.getDimensionPixelSize(R.dimen.recents_task_view_highlight);
mTaskBarViewLightTextColor = context.getColor(R.color.recents_task_bar_light_text_color);
@@ -363,8 +360,7 @@
mTaskBarViewLightTextColor : mTaskBarViewDarkTextColor);
mDismissButton.setImageDrawable(t.useLightOnPrimaryColor ?
mLightDismissDrawable : mDarkDismissDrawable);
- mDismissButton.setContentDescription(String.format(mDismissContentDescription,
- t.contentDescription));
+ mDismissButton.setContentDescription(t.dismissDescription);
// When freeform workspaces are enabled, then update the move-task button depending on the
// current task