Improve the latency of DataUsageList
Up to 30x faster. Currently it load the usage detail for every day at the beginning, so it's quite slow. To fix, - Not load the usage detail for every day at the beginning - Load only the cycles first - And only load the daily detail for the selected month Fix: 290856342 Test: manual - on DataUsageList (cell & wifi) Test: unit tests Change-Id: Ie18fa68f801743389bd6b6a28e236dcf1fea00e4
This commit is contained in:
@@ -14,9 +14,9 @@
|
||||
package com.android.settings.datausage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Range;
|
||||
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.net.NetworkCycleData;
|
||||
import com.android.settingslib.widget.SettingsSpinnerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
@@ -62,15 +62,15 @@ 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 void updateCycleList(List<? extends NetworkCycleData> cycleData) {
|
||||
public void updateCycleList(List<Range<Long>> cycleData) {
|
||||
// stash away currently selected cycle to try restoring below
|
||||
final CycleAdapter.CycleItem previousItem = (CycleAdapter.CycleItem)
|
||||
mSpinner.getSelectedItem();
|
||||
clear();
|
||||
|
||||
final Context context = getContext();
|
||||
for (NetworkCycleData data : cycleData) {
|
||||
add(new CycleAdapter.CycleItem(context, data.getStartTime(), data.getEndTime()));
|
||||
for (Range<Long> cycle : cycleData) {
|
||||
add(new CycleAdapter.CycleItem(context, cycle.getLower(), cycle.getUpper()));
|
||||
}
|
||||
|
||||
// force pick the current cycle (first item)
|
||||
|
Reference in New Issue
Block a user