Extract method Profile.toTargetRangeString.
This commit is contained in:
parent
754a0097b9
commit
759afcec7a
|
@ -391,4 +391,9 @@ public class Profile {
|
||||||
if (units.equals(Constants.MGDL)) return DecimalFormatter.to0Decimal(valueInMgdl);
|
if (units.equals(Constants.MGDL)) return DecimalFormatter.to0Decimal(valueInMgdl);
|
||||||
else return DecimalFormatter.to1Decimal(valueInMmol);
|
else return DecimalFormatter.to1Decimal(valueInMmol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String toTargetRangeString(double low, double high, String units) {
|
||||||
|
if (low == high) return toUnitsString(low, low, units);
|
||||||
|
else return toUnitsString(low, low, units) + " - " + toUnitsString(high, high, units);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -952,19 +952,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
tempTargetView.setTextColor(Color.BLACK);
|
tempTargetView.setTextColor(Color.BLACK);
|
||||||
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
|
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
|
||||||
tempTargetView.setVisibility(View.VISIBLE);
|
tempTargetView.setVisibility(View.VISIBLE);
|
||||||
if (tempTarget.low == tempTarget.high)
|
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, units));
|
||||||
tempTargetView.setText(Profile.toUnitsString(tempTarget.low, tempTarget.low, units));
|
|
||||||
else
|
|
||||||
tempTargetView.setText(Profile.toUnitsString(tempTarget.low, tempTarget.low, units) + " - " + Profile.toUnitsString(tempTarget.high, tempTarget.high, units));
|
|
||||||
} else {
|
} else {
|
||||||
tempTargetView.setTextColor(Color.WHITE);
|
tempTargetView.setTextColor(Color.WHITE);
|
||||||
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));
|
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));
|
||||||
double low = MainApp.getConfigBuilder().getProfile().getTargetLow();
|
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units));
|
||||||
double high = MainApp.getConfigBuilder().getProfile().getTargetHigh();
|
|
||||||
if (low == high)
|
|
||||||
tempTargetView.setText(Profile.toUnitsString(low, low, units));
|
|
||||||
else
|
|
||||||
tempTargetView.setText(Profile.toUnitsString(low, low, units) + " - " + Profile.toUnitsString(high, high, units));
|
|
||||||
tempTargetView.setVisibility(View.VISIBLE);
|
tempTargetView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
if (Config.NSCLIENT && tempTarget == null) {
|
if (Config.NSCLIENT && tempTarget == null) {
|
||||||
|
|
|
@ -472,7 +472,7 @@ public class ActionStringHandler {
|
||||||
//Check for Temp-Target:
|
//Check for Temp-Target:
|
||||||
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
|
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
ret += "Temp Target: " + Profile.toUnitsString(tempTarget.low, tempTarget.low, profile.getUnits()) + " - " + Profile.toUnitsString(tempTarget.high, tempTarget.high, profile.getUnits());
|
ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.low, tempTarget.low, profile.getUnits());
|
||||||
ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd());
|
ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd());
|
||||||
ret += "\n\n";
|
ret += "\n\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue