From 47dcff42dfa7efa763e282108f2619a2e6e5b8fb Mon Sep 17 00:00:00 2001 From: Raff Tsai Date: Wed, 7 Aug 2019 10:31:36 +0800 Subject: [PATCH] Fix storage page slow loading issue StorageAsyncLoader is the bottleneck. It needs to loop all installed apps and count all apps size. Original design was waiting the asyncLoader went back then hide the loading icon. Change the design to hide the loading icon before asyncLoader is back. Fixes: 138964123 Test: manual Change-Id: I54c2efa7cf61d711145811619512d927adcee210 --- .../deviceinfo/StorageDashboardFragment.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java index c9cec578df1..9dab2bd4387 100644 --- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java +++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java @@ -66,7 +66,6 @@ public class StorageDashboardFragment extends DashboardFragment private static final int STORAGE_JOB_ID = 0; private static final int ICON_JOB_ID = 1; private static final int VOLUME_SIZE_JOB_ID = 2; - private static final int OPTIONS_MENU_MIGRATE_DATA = 100; private VolumeInfo mVolume; private PrivateStorageInfo mStorageInfo; @@ -139,6 +138,7 @@ public class StorageDashboardFragment extends DashboardFragment } private void onReceivedSizes() { + boolean stopLoading = false; if (mStorageInfo != null) { long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes; mSummaryController.updateBytes(privateUsedBytes, mStorageInfo.totalBytes); @@ -152,18 +152,21 @@ public class StorageDashboardFragment extends DashboardFragment userController.setTotalSize(mStorageInfo.totalBytes); } } + stopLoading = true; + } - if (mAppsResult == null) { - return; + if (mAppsResult != null) { + mPreferenceController.onLoadFinished(mAppsResult, UserHandle.myUserId()); + updateSecondaryUserControllers(mSecondaryUsers, mAppsResult); + stopLoading = true; } - mPreferenceController.onLoadFinished(mAppsResult, UserHandle.myUserId()); - updateSecondaryUserControllers(mSecondaryUsers, mAppsResult); - // setLoading always causes a flicker, so let's avoid doing it. - if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) { - setLoading(false, true); + if (stopLoading) { + if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) { + setLoading(false, true); + } } }