Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2fcbdb7b authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Hide empty data usage cycles." into mnc-dr-dev

parents 29b0ea2d 02551ecd
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -1166,6 +1166,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
        mCycleAdapter.clear();

        final Context context = mCycleSpinner.getContext();
        NetworkStatsHistory.Entry entry = null;

        long historyStart = Long.MAX_VALUE;
        long historyEnd = Long.MIN_VALUE;
@@ -1188,10 +1189,21 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
                final long cycleStart = computeLastCycleBoundary(cycleEnd, policy);
                Log.d(TAG, "generating cs=" + cycleStart + " to ce=" + cycleEnd + " waiting for hs="
                        + historyStart);

                final boolean includeCycle;
                if (mChartData != null) {
                    entry = mChartData.network.getValues(cycleStart, cycleEnd, entry);
                    includeCycle = (entry.rxBytes + entry.txBytes) > 0;
                } else {
                    includeCycle = true;
                }

                if (includeCycle) {
                    mCycleAdapter.add(new CycleItem(context, cycleStart, cycleEnd));
                cycleEnd = cycleStart;
                    hasCycles = true;
                }
                cycleEnd = cycleStart;
            }

            // one last cycle entry to modify policy cycle day
            mCycleAdapter.setChangePossible(isNetworkPolicyModifiable(policy));
@@ -1202,7 +1214,18 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
            long cycleEnd = historyEnd;
            while (cycleEnd > historyStart) {
                final long cycleStart = cycleEnd - (DateUtils.WEEK_IN_MILLIS * 4);

                final boolean includeCycle;
                if (mChartData != null) {
                    entry = mChartData.network.getValues(cycleStart, cycleEnd, entry);
                    includeCycle = (entry.rxBytes + entry.txBytes) > 0;
                } else {
                    includeCycle = true;
                }

                if (includeCycle) {
                    mCycleAdapter.add(new CycleItem(context, cycleStart, cycleEnd));
                }
                cycleEnd = cycleStart;
            }