Merge "Add the string "No time remaining" when remaining time <= 0." into pi-dev

This commit is contained in:
Andreas Terzis
2018-03-19 14:22:51 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 16 deletions

View File

@@ -199,18 +199,18 @@ public class DataUsageSummaryPreference extends Preference {
}
private void updateCycleTimeText(PreferenceViewHolder holder) {
float daysLeft =
((float) mCycleEndTimeMs - System.currentTimeMillis()) / MILLIS_IN_A_DAY;
if (daysLeft < 0) {
daysLeft = 0;
}
TextView cycleTime = (TextView) holder.findViewById(R.id.cycle_left_time);
cycleTime.setText(
(daysLeft > 0 && daysLeft < 1)
? getContext().getString(R.string.billing_cycle_less_than_one_day_left)
: getContext().getResources().getQuantityString(
R.plurals.billing_cycle_days_left, (int) daysLeft, (int) daysLeft));
long millisLeft = mCycleEndTimeMs - System.currentTimeMillis();
if (millisLeft <= 0) {
cycleTime.setText(getContext().getString(R.string.billing_cycle_none_left));
} else {
int daysLeft = (int)(millisLeft / MILLIS_IN_A_DAY);
cycleTime.setText(daysLeft < 1
? getContext().getString(R.string.billing_cycle_less_than_one_day_left)
: getContext().getResources().getQuantityString(
R.plurals.billing_cycle_days_left, daysLeft, daysLeft));
}
}