Bug: crash due to color not found.

Introduced in 674d231b7a
This commit is contained in:
Dennis Guse
2023-01-29 21:41:11 +01:00
parent 8cc4fd1d4f
commit c666d55211
2 changed files with 9 additions and 10 deletions
@@ -3,6 +3,7 @@ package de.dennisguse.opentracks.data.models;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.ui.util.ThemeUtils;
@@ -15,19 +16,19 @@ public class HeartRateZones {
this.max = max;
}
public int getColorForZone(Context context, HeartRate current) {
public int getTextColorForZone(Context context, HeartRate current) {
if (current != null) {
if (current.getBPM() >= max.getBPM() * 0.9) {
return R.color.heart_rate_zone_textcolor_5;
return ContextCompat.getColor(context, R.color.heart_rate_zone_textcolor_5);
}
if (current.getBPM() >= max.getBPM() * 0.8) {
return R.color.heart_rate_zone_textcolor_4;
return ContextCompat.getColor(context, R.color.heart_rate_zone_textcolor_4);
}
if (current.getBPM() >= max.getBPM() * 0.7) {
return R.color.heart_rate_zone_textcolor_3;
return ContextCompat.getColor(context, R.color.heart_rate_zone_textcolor_3);
}
if (current.getBPM() >= max.getBPM() * 0.6) {
return R.color.heart_rate_zone_textcolor_2;
return ContextCompat.getColor(context, R.color.heart_rate_zone_textcolor_2);
}
}