Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d31f9080 authored by Fengjiang Li's avatar Fengjiang Li Committed by Android (Google) Code Review
Browse files

Merge "Fix All Apps Icons Count estimation" into main

parents 0c740c77 6c590826
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -704,6 +704,17 @@ public class DeviceProfile {
        return renderer;
    }

    /**
     * Return maximum of all apps row count displayed on screen. Note that 1) Partially displayed
     * row is counted as 1 row, and 2) we don't exclude the space of floating search bar. This
     * method is used for calculating number of {@link BubbleTextView} we need to pre-inflate. Thus
     * reasonable over estimation is fine.
     */
    public int getMaxAllAppsRowCount() {
        return (int) (Math.ceil((availableHeightPx - allAppsTopPadding)
                / (float) allAppsCellHeightPx));
    }

    /**
     * QSB width is always calculated because when in 3 button nav the width doesn't follow the
     * width of the hotseat.
+9 −7
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.launcher3.allapps;

import static com.android.launcher3.config.FeatureFlags.ALL_APPS_GONE_VISIBILITY;
import static com.android.launcher3.config.FeatureFlags.ENABLE_ALL_APPS_RV_PREINFLATION;
import static com.android.launcher3.logger.LauncherAtom.ContainerInfo;
import static com.android.launcher3.logger.LauncherAtom.SearchResultContainer;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_PERSONAL_SCROLLED_DOWN;
@@ -96,16 +97,17 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
    protected void updatePoolSize() {
        DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
        RecyclerView.RecycledViewPool pool = getRecycledViewPool();
        int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
        pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, 1);
        pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER, 1);

        // If all apps' hidden visibility is INVISIBLE, we will need to preinflate one page of
        // all apps icons for smooth scrolling.
        int maxPoolSizeForAppIcons = (approxRows + 1) * grid.numShownAllAppsColumns;
        if (ALL_APPS_GONE_VISIBILITY.get()) {
            // If all apps' hidden visibility is GONE, we need to increase prefinated icons number
            // by [PREINFLATE_ICONS_ROW_COUNT] rows + [EXTRA_ICONS_COUNT] for fast opening all apps.
        // By default the max num of pool size for app icons is num of app icons in one page of
        // all apps.
        int maxPoolSizeForAppIcons = grid.getMaxAllAppsRowCount()
                * grid.numShownAllAppsColumns;
        if (ALL_APPS_GONE_VISIBILITY.get() && ENABLE_ALL_APPS_RV_PREINFLATION.get()) {
            // If we set all apps' hidden visibility to GONE and enable pre-inflation, we want to
            // preinflate one page of all apps icons plus [PREINFLATE_ICONS_ROW_COUNT] rows +
            // [EXTRA_ICONS_COUNT]. Thus we need to bump the max pool size of app icons accordingly.
            maxPoolSizeForAppIcons +=
                    PREINFLATE_ICONS_ROW_COUNT * grid.numShownAllAppsColumns + EXTRA_ICONS_COUNT;
        }
+1 −3
Original line number Diff line number Diff line
@@ -93,9 +93,7 @@ class AllAppsRecyclerViewPool<T> : RecycledViewPool() {
                EXTRA_ICONS_COUNT
        if (FeatureFlags.ALL_APPS_GONE_VISIBILITY.get()) {
            val grid = ActivityContext.lookupContext<T>(context).deviceProfile
            val approxRows =
                Math.ceil((grid.availableHeightPx / grid.allAppsIconSizePx).toDouble()).toInt()
            targetPreinflateCount += (approxRows + 1) * grid.numShownAllAppsColumns
            targetPreinflateCount += grid.maxAllAppsRowCount * grid.numShownAllAppsColumns
        }
        val existingPreinflateCount = getRecycledViewCount(BaseAllAppsAdapter.VIEW_TYPE_ICON)
        return targetPreinflateCount - existingPreinflateCount