Reduce flickers when launching Storage Settings
This change remove unnecessary UI dpdate of StorageItemPreferenceController. - For StorageItemPreferenceController: Remove UI update at #displayPreference since onLoadFinished will update. Don't update order at #setVolume since onLoadFinished will update. - StorageDashboardFragment & StorageCategoryFragment update StorageItemPreferenceController only when both StorageInfo and StorageResult are loaded. Bug: 185547228 Test: atest com.android.settings.deviceinfo atest com.android.settings.deviceinfo.storage make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.deviceinfo make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.deviceinfo.storage manual visual Click each file category to count files size is the same as displayed in Storage Settings. manual visual Change-Id: Id449003827a3e340e7a90f706152100b5568f834
This commit is contained in:
@@ -232,14 +232,16 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
mOptionMenuController.setSelectedStorageEntry(mSelectedStorageEntry);
|
||||
getActivity().invalidateOptionsMenu();
|
||||
|
||||
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
|
||||
|
||||
if (!mSelectedStorageEntry.isMounted()) {
|
||||
// Set null volume to hide category stats.
|
||||
mPreferenceController.setVolume(null);
|
||||
return;
|
||||
}
|
||||
if (mSelectedStorageEntry.isPrivate()) {
|
||||
mStorageInfo = null;
|
||||
mAppsResult = null;
|
||||
maybeSetLoading(isQuotaSupported());
|
||||
|
||||
// Stats data is only available on private volumes.
|
||||
getLoaderManager().restartLoader(STORAGE_JOB_ID, Bundle.EMPTY, this);
|
||||
getLoaderManager()
|
||||
@@ -315,7 +317,6 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
public void onViewCreated(View v, Bundle savedInstanceState) {
|
||||
super.onViewCreated(v, savedInstanceState);
|
||||
initializeCacheProvider();
|
||||
maybeSetLoading(isQuotaSupported());
|
||||
|
||||
EntityHeaderController.newInstance(getActivity(), this /*fragment*/,
|
||||
null /* header view */)
|
||||
@@ -350,33 +351,27 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
private void onReceivedSizes() {
|
||||
boolean stopLoading = false;
|
||||
if (mStorageInfo != null) {
|
||||
final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
|
||||
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
|
||||
mPreferenceController.setUsedSize(privateUsedBytes);
|
||||
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
|
||||
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
|
||||
final AbstractPreferenceController controller = mSecondaryUsers.get(i);
|
||||
if (controller instanceof SecondaryUserController) {
|
||||
SecondaryUserController userController = (SecondaryUserController) controller;
|
||||
userController.setTotalSize(mStorageInfo.totalBytes);
|
||||
}
|
||||
}
|
||||
stopLoading = true;
|
||||
if (mStorageInfo == null || mAppsResult == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAppsResult != null) {
|
||||
mPreferenceController.onLoadFinished(mAppsResult, mUserId);
|
||||
updateSecondaryUserControllers(mSecondaryUsers, mAppsResult);
|
||||
stopLoading = true;
|
||||
final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
|
||||
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
|
||||
mPreferenceController.setUsedSize(privateUsedBytes);
|
||||
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
|
||||
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
|
||||
final AbstractPreferenceController controller = mSecondaryUsers.get(i);
|
||||
if (controller instanceof SecondaryUserController) {
|
||||
SecondaryUserController userController = (SecondaryUserController) controller;
|
||||
userController.setTotalSize(mStorageInfo.totalBytes);
|
||||
}
|
||||
}
|
||||
|
||||
// setLoading always causes a flicker, so let's avoid doing it.
|
||||
if (stopLoading) {
|
||||
if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) {
|
||||
setLoading(false, true);
|
||||
}
|
||||
mPreferenceController.onLoadFinished(mAppsResult, mUserId);
|
||||
updateSecondaryUserControllers(mSecondaryUsers, mAppsResult);
|
||||
|
||||
if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) {
|
||||
setLoading(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user