Introduce mTaskViewCount inside the RecentsView

Add a member property `mTaskViewCount` inside the RecentsView to track
the number of TaskView inside it. Its value will be increased
`onViewAdded` and decreased `onViewRemoved`.
- Then `getTaskViewCount()` can just return this variable directly.
- Invalidate the `PagedView.mPageScrolls` on a view addition and
  removal util they have been updated on next `onLayout`. This is done
  to guarantee that `mOnPageScrollsInitializedCallbacks` is run with
  up to date `mPageScrolls`.

Flag: EXEMPT as no functionality changes
Bug: 379942019
Test: Tested on Tangor, ensure `mTaskViewCount` is correct in the
      following scenarios:
      1. Adding more tasks and enter overview
      2. Dismissing one and more tasks
      3. Dismissing all tasks
Change-Id: I32407e77dd2a9b3d8200efc334c1eadea1336b31
This commit is contained in:
minch authored and Min Chen committed 2024-12-11 10:43:31 -08:00
1 parent b0ce150306
commit 58abc8b0a6
2 files changed
+25 -22

No files matched your search

+2
View File
@@ -903,12 +903,14 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
@Override
public void onViewAdded(View child) {
super.onViewAdded(child);
mPageScrolls = null;
dispatchPageCountChanged();
}
@Override
public void onViewRemoved(View child) {
super.onViewRemoved(child);
mPageScrolls = null;
runOnPageScrollsInitialized(() -> {
mCurrentPage = validateNewPage(mCurrentPage);
mCurrentScrollOverPage = mCurrentPage;