Merge "Add GroupedTaskView to recents view only if needed" into sc-v2-dev

This commit is contained in:
Vinit Nayak 2021-08-27 22:13:20 +00:00 committed by Android (Google) Code Review
commit 5025ecb8b6
1 changed files with 12 additions and 1 deletions

View File

@ -1278,7 +1278,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
while (getTaskViewCount() > requiredTaskViewCount) {
removeView(getChildAt(getChildCount() - 1));
}
while (requiredGroupTaskViews > 0) {
int groupedTaskViewCount = getGroupedTaskViewCount();
while (requiredGroupTaskViews > groupedTaskViewCount) {
// Add to front of list
addView(getTaskViewFromPool(true), 0);
requiredGroupTaskViews--;
@ -1405,6 +1406,16 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
return taskViewCount;
}
public int getGroupedTaskViewCount() {
int groupViewCount = 0;
for (int i = 0; i < getChildCount(); i++) {
if (getChildAt(i) instanceof GroupedTaskView) {
groupViewCount++;
}
}
return groupViewCount;
}
protected void onTaskStackUpdated() {
// Lazily update the empty message only when the task stack is reapplied
updateEmptyMessage();