Show remaining time of TT

This commit is contained in:
AdrianLxM 2017-10-28 02:16:30 +02:00 committed by GitHub
parent 8a6e811c95
commit 7d82870203
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -994,10 +994,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// temp target
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
if (tempTarget != null) {
long remainingTimeMinutes = (tempTarget.end()- System.currentTimeMillis())/(1000*60);
long remainingTimeHours = remainingTimeMinutes/60;
remainingTimeMinutes = remainingTimeMinutes%60;
String remaining = " (" + ((remainingTimeHours >0)?(remainingTimeHours + "h "):"") + remainingTimeMinutes + "')";
tempTargetView.setTextColor(Color.BLACK);
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
tempTargetView.setVisibility(View.VISIBLE);
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units));
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + remaining);
} else {
tempTargetView.setTextColor(Color.WHITE);
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));