1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-28 11:35:48 +01:00

Calories: fix loading lag, gap

This commit is contained in:
a0z 2024-10-27 14:16:34 +01:00 committed by José Rebelo
parent 622d37ed38
commit 37ea9bc571
2 changed files with 13 additions and 10 deletions

View File

@ -41,12 +41,14 @@ public class CaloriesDailyFragment extends AbstractChartFragment<CaloriesDailyFr
private ImageView caloriesGauge; private ImageView caloriesGauge;
private TextView dateView; private TextView dateView;
private TextView caloriesResting; private TextView caloriesResting;
private LinearLayout caloriesRestingWrapper;
private TextView caloriesActive; private TextView caloriesActive;
private LinearLayout caloriesActiveWrapper;
private TextView caloriesActiveGoal; private TextView caloriesActiveGoal;
private LinearLayout caloriesActiveGoalWrapper;
private TextView caloriesTotalGoal; private TextView caloriesTotalGoal;
private LinearLayout caloriesTotalGoalWrapper;
protected int CALORIES_GOAL; protected int CALORIES_GOAL;
protected int TOTAL_CALORIES_GOAL;
protected int ACTIVE_CALORIES_GOAL;
public enum GaugeViewMode { public enum GaugeViewMode {
ACTIVE_CALORIES_GOAL, ACTIVE_CALORIES_GOAL,
TOTAL_CALORIES_GOAL, TOTAL_CALORIES_GOAL,
@ -86,20 +88,19 @@ public class CaloriesDailyFragment extends AbstractChartFragment<CaloriesDailyFr
caloriesGauge = rootView.findViewById(R.id.calories_gauge); caloriesGauge = rootView.findViewById(R.id.calories_gauge);
dateView = rootView.findViewById(R.id.date_view); dateView = rootView.findViewById(R.id.date_view);
caloriesResting = rootView.findViewById(R.id.calories_resting); caloriesResting = rootView.findViewById(R.id.calories_resting);
caloriesRestingWrapper = rootView.findViewById(R.id.calories_resting_wrapper);
caloriesActive = rootView.findViewById(R.id.calories_active); caloriesActive = rootView.findViewById(R.id.calories_active);
caloriesActiveWrapper = rootView.findViewById(R.id.calories_active_wrapper);
caloriesActiveGoal = rootView.findViewById(R.id.calories_active_goal); caloriesActiveGoal = rootView.findViewById(R.id.calories_active_goal);
caloriesActiveGoalWrapper = rootView.findViewById(R.id.calories_active_goal_wrapper);
caloriesTotalGoal = rootView.findViewById(R.id.calories_total_goal); caloriesTotalGoal = rootView.findViewById(R.id.calories_total_goal);
caloriesTotalGoalWrapper = rootView.findViewById(R.id.calories_total_goal_wrapper);
ActivityUser activityUser = new ActivityUser(); ActivityUser activityUser = new ActivityUser();
int TOTAL_CALORIES_GOAL = activityUser.getCaloriesBurntGoal(); TOTAL_CALORIES_GOAL = activityUser.getCaloriesBurntGoal();
caloriesTotalGoal.setText(String.valueOf(TOTAL_CALORIES_GOAL)); ACTIVE_CALORIES_GOAL = activityUser.getActiveCaloriesBurntGoal();
int ACTIVE_CALORIES_GOAL = activityUser.getActiveCaloriesBurntGoal();
caloriesActiveGoal.setText(String.valueOf(ACTIVE_CALORIES_GOAL));
refresh(); refresh();
if (!supportsActiveCalories()) { if (!supportsActiveCalories()) {
caloriesActive.setVisibility(View.GONE); caloriesActiveWrapper.setVisibility(View.GONE);
caloriesActiveGoalWrapper.setVisibility(View.GONE);
} }
if (gaugeViewMode == null) { if (gaugeViewMode == null) {
@ -183,6 +184,8 @@ public class CaloriesDailyFragment extends AbstractChartFragment<CaloriesDailyFr
int totalCalories = activeCalories + restingCalories; int totalCalories = activeCalories + restingCalories;
caloriesActive.setText(String.valueOf(activeCalories)); caloriesActive.setText(String.valueOf(activeCalories));
caloriesResting.setText(String.valueOf(restingCalories)); caloriesResting.setText(String.valueOf(restingCalories));
caloriesTotalGoal.setText(String.valueOf(TOTAL_CALORIES_GOAL));
caloriesActiveGoal.setText(String.valueOf(ACTIVE_CALORIES_GOAL));
if (gaugeViewMode.equals(GaugeViewMode.TOTAL_CALORIES_SEGMENT)) { if (gaugeViewMode.equals(GaugeViewMode.TOTAL_CALORIES_SEGMENT)) {
int[] colors = new int[] { int[] colors = new int[] {

View File

@ -233,7 +233,7 @@ public class GaugeDrawer {
float sweepAngleDegrees = segments[i] * 360; float sweepAngleDegrees = segments[i] * 360;
if (gapBetweenSegments) { if (gapBetweenSegments) {
sweepAngleDegrees -= 2; sweepAngleDegrees -= 1;
} }
canvas.drawArc( canvas.drawArc(