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. Cherry-pick from Change-Id: I95e544c46333496f4f30ed77dafa4779b4d66019 Fix: 277162513 Test: manual visual test Test: Unit test Change-Id: I50fb79aa3c888651a79fd1d030da554bebb6a660
This commit is contained in:
@@ -21,7 +21,6 @@ import com.android.settingslib.net.NetworkCycleData;
|
||||
import com.android.settingslib.widget.SettingsSpinnerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CycleAdapter extends SettingsSpinnerAdapter<CycleAdapter.CycleItem> {
|
||||
|
||||
@@ -67,7 +66,7 @@ public class CycleAdapter extends SettingsSpinnerAdapter<CycleAdapter.CycleItem>
|
||||
* Rebuild list based on network data. Always selects the newest item,
|
||||
* updating the inspection range on chartData.
|
||||
*/
|
||||
public boolean updateCycleList(List<? extends NetworkCycleData> cycleData) {
|
||||
public void updateCycleList(List<? extends NetworkCycleData> cycleData) {
|
||||
mSpinner.setOnItemSelectedListener(mListener);
|
||||
// stash away currently selected cycle to try restoring below
|
||||
final CycleAdapter.CycleItem previousItem = (CycleAdapter.CycleItem)
|
||||
@@ -83,16 +82,7 @@ public class CycleAdapter extends SettingsSpinnerAdapter<CycleAdapter.CycleItem>
|
||||
if (getCount() > 0) {
|
||||
final int position = findNearestPosition(previousItem);
|
||||
mSpinner.setSelection(position);
|
||||
|
||||
// only force-update cycle when changed; skipping preserves any
|
||||
// user-defined inspection region.
|
||||
final CycleAdapter.CycleItem selectedItem = getItem(position);
|
||||
if (!Objects.equals(selectedItem, previousItem)) {
|
||||
mListener.onItemSelected(null, null, position, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user