[DO NOT MERGE] Fix flicker for Data Usage page

Both "Mobile data usage" & "Non-carrier data usage".

By,
1. Use summary placeholder for usage amount to avoid shift
2. Before fix CycleListener's onItemSelected() is called multiple times,
   cause the app list to flash, let DataUsageList to handle the dedup
   logic to better handling.
3. Before fix if return from App Usage page, no loading view is
   displayed (only first enter has it), move this to onResume() to fix.
4. Before fix the cycles passed to App Usage page is cached (even when
   the cycles are changed), clear the cache when onResume() to fix.
5. Listener in SpinnerPreference could be null, add safety guard to it.

Fix: 187019210
Test: manual visual test
Change-Id: I95e544c46333496f4f30ed77dafa4779b4d66019
This commit is contained in:
Chaohui Wang
2022-05-11 11:42:11 +08:00
parent 94a97b6c59
commit 5a2f5ecff5
5 changed files with 74 additions and 56 deletions

View File

@@ -94,6 +94,7 @@ public class DataUsageListTest {
mMobileDataEnabledListener);
ReflectionHelpers.setField(mDataUsageList, "services", mNetworkServices);
doReturn(mLoaderManager).when(mDataUsageList).getLoaderManager();
mDataUsageList.mLoadingViewController = mock(LoadingViewController.class);
}
@Test
@@ -207,8 +208,6 @@ public class DataUsageListTest {
@Test
public void onLoadFinished_networkCycleDataCallback_shouldShowCycleSpinner() {
final LoadingViewController loadingViewController = mock(LoadingViewController.class);
mDataUsageList.mLoadingViewController = loadingViewController;
final Spinner spinner = getSpinner(getHeader());
spinner.setVisibility(View.INVISIBLE);
mDataUsageList.mCycleSpinner = spinner;