Remove mFilteredApps

Currently, we are maintaining a list of appInfos to report the number of Accessibility recycler-view items. This could be done by maintaining an int.

Bug: 162480567
Test: Manual
Change-Id: I9de8e1d4ac6e1a674d1e19b591dedad0dd4cc536
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 5d9c554..0fc04a7 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -128,6 +128,10 @@
             item.searchSectionInfo = sectionInfo;
             return item;
         }
+
+        boolean isCountedForAccessibility() {
+            return viewType == AllAppsGridAdapter.VIEW_TYPE_ICON;
+        }
     }
 
     private final BaseDraggingActivity mLauncher;
@@ -136,8 +140,8 @@
     private final List<AppInfo> mApps = new ArrayList<>();
     private final AllAppsStore mAllAppsStore;
 
-    // The set of filtered apps with the current filter
-    private final List<AppInfo> mFilteredApps = new ArrayList<>();
+    // The number of results in current adapter
+    private int mAccessibilityResultsCount = 0;
     // The current set of adapter items
     private final ArrayList<AdapterItem> mAdapterItems = new ArrayList<>();
     // The set of sections that we allow fast-scrolling to (includes non-merged sections)
@@ -206,7 +210,7 @@
      * Returns the number of applications in this list.
      */
     public int getNumFilteredApps() {
-        return mFilteredApps.size();
+        return mAccessibilityResultsCount;
     }
 
     /**
@@ -220,7 +224,7 @@
      * Returns whether there are no filtered results.
      */
     public boolean hasNoFilteredResults() {
-        return (mSearchResults != null) && mFilteredApps.isEmpty();
+        return (mSearchResults != null) && mAccessibilityResultsCount == 0;
     }
 
     /**
@@ -306,7 +310,7 @@
         int appIndex = 0;
 
         // Prepare to update the list of sections, filtered apps, etc.
-        mFilteredApps.clear();
+        mAccessibilityResultsCount = 0;
         mFastScrollerSections.clear();
         mAdapterItems.clear();
 
@@ -318,6 +322,7 @@
         // ordered set of sections
 
         if (!hasFilter()) {
+            mAccessibilityResultsCount = mApps.size();
             appSection.setPosStart(position);
             for (AppInfo info : mApps) {
                 String sectionName = info.sectionName;
@@ -338,7 +343,6 @@
                     appItem.searchSectionInfo = appSection;
                 }
                 mAdapterItems.add(appItem);
-                mFilteredApps.add(info);
             }
             appSection.setPosEnd(mApps.isEmpty() ? appSection.getPosStart() : position - 1);
         } else {
@@ -358,8 +362,10 @@
                 if (AllAppsGridAdapter.isIconViewType(adapterItem.viewType)) {
                     appInfos.add(adapterItem.appInfo);
                 }
+                if (adapterItem.isCountedForAccessibility()) {
+                    mAccessibilityResultsCount++;
+                }
             }
-            mFilteredApps.addAll(appInfos);
             if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
                 // Append the search market item
                 if (hasNoFilteredResults()) {