1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-19 00:19:25 +01:00

Refactor retrieval of data points to static class for deduplication

This commit is contained in:
Arjan Schrijver 2024-02-01 22:22:32 +01:00
parent dbb9e36490
commit 3621377d91
8 changed files with 147 additions and 77 deletions

View File

@ -35,6 +35,7 @@ import androidx.gridlayout.widget.GridLayout;
import com.google.android.material.card.MaterialCardView;
import java.io.Serializable;
import java.util.Calendar;
import java.util.GregorianCalendar;
@ -49,6 +50,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.dashboard.DashboardSleepW
import nodomain.freeyourgadget.gadgetbridge.activities.dashboard.DashboardStepsWidget;
import nodomain.freeyourgadget.gadgetbridge.activities.dashboard.DashboardTodayWidget;
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
import nodomain.freeyourgadget.gadgetbridge.util.HealthUtils;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class DashboardFragment extends Fragment {
@ -63,6 +65,7 @@ public class DashboardFragment extends Fragment {
private DashboardDistanceWidget distanceWidget;
private DashboardActiveTimeWidget activeTimeWidget;
private DashboardSleepWidget sleepWidget;
private DashboardData dashboardData = new DashboardData();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -144,8 +147,9 @@ public class DashboardFragment extends Fragment {
day.set(Calendar.HOUR_OF_DAY, 23);
day.set(Calendar.MINUTE, 59);
day.set(Calendar.SECOND, 59);
int timeTo = (int) (day.getTimeInMillis() / 1000);
int timeFrom = DateTimeUtils.shiftDays(timeTo, -1);
dashboardData.clear();
dashboardData.timeTo = (int) (day.getTimeInMillis() / 1000);
dashboardData.timeFrom = DateTimeUtils.shiftDays(dashboardData.timeTo, -1);
Calendar today = GregorianCalendar.getInstance();
if (DateTimeUtils.isSameDay(today, day)) {
@ -161,50 +165,50 @@ public class DashboardFragment extends Fragment {
if (prefs.getBoolean("dashboard_widget_today_enabled", true)) {
if (todayWidget == null) {
todayWidget = DashboardTodayWidget.newInstance(timeFrom, timeTo);
todayWidget = DashboardTodayWidget.newInstance(dashboardData);
createWidget(todayWidget, cardsEnabled, 2);
} else {
todayWidget.setTimespan(timeFrom, timeTo);
todayWidget.update();
}
}
if (prefs.getBoolean("dashboard_widget_goals_enabled", true)) {
if (goalsWidget == null) {
goalsWidget = DashboardGoalsWidget.newInstance(timeFrom, timeTo);
goalsWidget = DashboardGoalsWidget.newInstance(dashboardData);
createWidget(goalsWidget, cardsEnabled, 2);
} else {
goalsWidget.setTimespan(timeFrom, timeTo);
goalsWidget.update();
}
}
if (prefs.getBoolean("dashboard_widget_steps_enabled", true)) {
if (stepsWidget == null) {
stepsWidget = DashboardStepsWidget.newInstance(timeFrom, timeTo);
stepsWidget = DashboardStepsWidget.newInstance(dashboardData);
createWidget(stepsWidget, cardsEnabled, 1);
} else {
stepsWidget.setTimespan(timeFrom, timeTo);
stepsWidget.update();
}
}
if (prefs.getBoolean("dashboard_widget_distance_enabled", true)) {
if (distanceWidget == null) {
distanceWidget = DashboardDistanceWidget.newInstance(timeFrom, timeTo);
distanceWidget = DashboardDistanceWidget.newInstance(dashboardData);
createWidget(distanceWidget, cardsEnabled, 1);
} else {
distanceWidget.setTimespan(timeFrom, timeTo);
distanceWidget.update();
}
}
if (prefs.getBoolean("dashboard_widget_active_time_enabled", true)) {
if (activeTimeWidget == null) {
activeTimeWidget = DashboardActiveTimeWidget.newInstance(timeFrom, timeTo);
activeTimeWidget = DashboardActiveTimeWidget.newInstance(dashboardData);
createWidget(activeTimeWidget, cardsEnabled, 1);
} else {
activeTimeWidget.setTimespan(timeFrom, timeTo);
activeTimeWidget.update();
}
}
if (prefs.getBoolean("dashboard_widget_sleep_enabled", true)) {
if (sleepWidget == null) {
sleepWidget = DashboardSleepWidget.newInstance(timeFrom, timeTo);
sleepWidget = DashboardSleepWidget.newInstance(dashboardData);
createWidget(sleepWidget, cardsEnabled, 1);
} else {
sleepWidget.setTimespan(timeFrom, timeTo);
sleepWidget.update();
}
}
}
@ -241,4 +245,82 @@ public class DashboardFragment extends Fragment {
gridLayout.addView(fragment);
}
}
/**
* This class serves as a data collection object for all data points used by the various
* dashboard widgets. Since retrieving this data can be costly, this class makes sure it will
* only be done once. It will be passed to every widget, making sure they have the necessary
* data available.
*/
public static class DashboardData implements Serializable {
public int timeFrom;
public int timeTo;
private int stepsTotal;
private float stepsGoalFactor;
private long sleepTotalMinutes;
private float sleepGoalFactor;
private float distanceTotalMeters;
private float distanceGoalFactor;
private long activeMinutesTotal;
private float activeMinutesGoalFactor;
public void clear() {
stepsTotal = 0;
stepsGoalFactor = 0;
sleepTotalMinutes = 0;
sleepGoalFactor = 0;
distanceTotalMeters = 0;
distanceGoalFactor = 0;
activeMinutesTotal = 0;
activeMinutesGoalFactor = 0;
}
public synchronized int getStepsTotal() {
if (stepsTotal == 0)
stepsTotal = HealthUtils.getStepsTotal(timeTo);
return stepsTotal;
}
public synchronized float getStepsGoalFactor() {
if (stepsGoalFactor == 0)
stepsGoalFactor = HealthUtils.getStepsGoalFactor(timeTo);
return stepsGoalFactor;
}
public synchronized float getDistanceTotal() {
if (distanceTotalMeters == 0)
distanceTotalMeters = HealthUtils.getDistanceTotal(timeTo);
return distanceTotalMeters;
}
public synchronized float getDistanceGoalFactor() {
if (distanceGoalFactor == 0)
distanceGoalFactor = HealthUtils.getDistanceGoalFactor(timeTo);
return distanceGoalFactor;
}
public synchronized long getActiveMinutesTotal() {
if (activeMinutesTotal == 0)
activeMinutesTotal = HealthUtils.getActiveMinutesTotal(timeFrom, timeTo);
return activeMinutesTotal;
}
public synchronized float getActiveMinutesGoalFactor() {
if (activeMinutesGoalFactor == 0)
activeMinutesGoalFactor = HealthUtils.getActiveMinutesGoalFactor(timeFrom, timeTo);
return activeMinutesGoalFactor;
}
public synchronized long getSleepMinutesTotal() {
if (sleepTotalMinutes == 0)
sleepTotalMinutes = HealthUtils.getSleepMinutesTotal(timeTo);
return sleepTotalMinutes;
}
public synchronized float getSleepMinutesGoalFactor() {
if (sleepGoalFactor == 0)
sleepGoalFactor = HealthUtils.getSleepMinutesGoalFactor(timeTo);
return sleepGoalFactor;
}
}
}

View File

@ -28,14 +28,14 @@ import androidx.fragment.app.Fragment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.activities.DashboardFragment;
public abstract class AbstractDashboardWidget extends Fragment {
private static final Logger LOG = LoggerFactory.getLogger(AbstractDashboardWidget.class);
protected static String ARG_TIME_FROM = "dashboard_widget_argument_time_from";
protected static String ARG_TIME_TO = "dashboard_widget_argument_time_to";
protected static String ARG_DASHBOARD_DATA = "dashboard_widget_argument_data";
protected int timeFrom;
protected int timeTo;
protected DashboardFragment.DashboardData dashboardData;
protected @ColorInt int color_not_worn = Color.argb(75, 128, 128, 128);
protected @ColorInt int color_worn = Color.rgb(128, 128, 128);
@ -49,22 +49,21 @@ public abstract class AbstractDashboardWidget extends Fragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
timeFrom = getArguments().getInt(ARG_TIME_FROM);
timeTo = getArguments().getInt(ARG_TIME_TO);
dashboardData = (DashboardFragment.DashboardData) getArguments().getSerializable(ARG_DASHBOARD_DATA);
}
}
public void setTimespan(int timeFrom, int timeTo) {
this.timeFrom = timeFrom;
this.timeTo = timeTo;
public void update() {
fillData();
}
protected abstract void fillData();
/**
* @param width Bitmap width in pixels
* @param width Bitmap width in pixels this.timeFrom = timeFrom;
this.timeTo = timeTo;
* @param barWidth Gauge bar width in pixels
* @param filledColor Color of the filled part of the gauge
* @param filledFactor Factor between 0 and 1 that determines the amount of the gauge that should be filled

View File

@ -27,7 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.util.HealthUtils;
import nodomain.freeyourgadget.gadgetbridge.activities.DashboardFragment;
/**
* A simple {@link AbstractDashboardWidget} subclass.
@ -47,15 +47,13 @@ public class DashboardActiveTimeWidget extends AbstractDashboardWidget {
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param timeFrom Start time in seconds since Unix epoch.
* @param timeTo End time in seconds since Unix epoch.
* @param dashboardData An instance of DashboardFragment.DashboardData.
* @return A new instance of fragment DashboardActiveTimeWidget.
*/
public static DashboardActiveTimeWidget newInstance(int timeFrom, int timeTo) {
public static DashboardActiveTimeWidget newInstance(DashboardFragment.DashboardData dashboardData) {
DashboardActiveTimeWidget fragment = new DashboardActiveTimeWidget();
Bundle args = new Bundle();
args.putInt(ARG_TIME_FROM, timeFrom);
args.putInt(ARG_TIME_TO, timeTo);
args.putSerializable(ARG_DASHBOARD_DATA, dashboardData);
fragment.setArguments(args);
return fragment;
}
@ -80,12 +78,12 @@ public class DashboardActiveTimeWidget extends AbstractDashboardWidget {
@Override
protected void fillData() {
// Update text representation
long totalActiveMinutes = HealthUtils.getActiveMinutesTotal(timeFrom, timeTo);
long totalActiveMinutes = dashboardData.getActiveMinutesTotal();
String activeHours = String.format("%d", (int) Math.floor(totalActiveMinutes / 60f));
String activeMinutes = String.format("%02d", (int) (totalActiveMinutes % 60f));
activeTime.setText(activeHours + ":" + activeMinutes);
// Draw gauge
activeTimeGauge.setImageBitmap(drawGauge(200, 15, color_active_time, HealthUtils.getActiveMinutesGoalFactor(timeFrom, timeTo)));
activeTimeGauge.setImageBitmap(drawGauge(200, 15, color_active_time, dashboardData.getActiveMinutesGoalFactor()));
}
}

View File

@ -27,8 +27,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.DashboardFragment;
import nodomain.freeyourgadget.gadgetbridge.util.FormatUtils;
import nodomain.freeyourgadget.gadgetbridge.util.HealthUtils;
/**
* A simple {@link AbstractDashboardWidget} subclass.
@ -48,15 +48,13 @@ public class DashboardDistanceWidget extends AbstractDashboardWidget {
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param timeFrom Start time in seconds since Unix epoch.
* @param timeTo End time in seconds since Unix epoch.
* @param dashboardData An instance of DashboardFragment.DashboardData.
* @return A new instance of fragment DashboardDistanceWidget.
*/
public static DashboardDistanceWidget newInstance(int timeFrom, int timeTo) {
public static DashboardDistanceWidget newInstance(DashboardFragment.DashboardData dashboardData) {
DashboardDistanceWidget fragment = new DashboardDistanceWidget();
Bundle args = new Bundle();
args.putInt(ARG_TIME_FROM, timeFrom);
args.putInt(ARG_TIME_TO, timeTo);
args.putSerializable(ARG_DASHBOARD_DATA, dashboardData);
fragment.setArguments(args);
return fragment;
}
@ -81,10 +79,10 @@ public class DashboardDistanceWidget extends AbstractDashboardWidget {
@Override
protected void fillData() {
// Update text representation
String distanceFormatted = FormatUtils.getFormattedDistanceLabel(HealthUtils.getDistanceTotal(timeTo));
String distanceFormatted = FormatUtils.getFormattedDistanceLabel(dashboardData.getDistanceTotal());
distanceText.setText(distanceFormatted);
// Draw gauge
distanceGauge.setImageBitmap(drawGauge(200, 15, color_distance, HealthUtils.getDistanceGoalFactor(timeTo)));
distanceGauge.setImageBitmap(drawGauge(200, 15, color_distance, dashboardData.getDistanceGoalFactor()));
}
}

View File

@ -35,7 +35,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.util.HealthUtils;
import nodomain.freeyourgadget.gadgetbridge.activities.DashboardFragment;
/**
* A simple {@link AbstractDashboardWidget} subclass.
@ -55,15 +55,13 @@ public class DashboardGoalsWidget extends AbstractDashboardWidget {
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param timeFrom Start time in seconds since Unix epoch.
* @param timeTo End time in seconds since Unix epoch.
* @param dashboardData An instance of DashboardFragment.DashboardData.
* @return A new instance of fragment DashboardGoalsWidget.
*/
public static DashboardGoalsWidget newInstance(int timeFrom, int timeTo) {
public static DashboardGoalsWidget newInstance(DashboardFragment.DashboardData dashboardData) {
DashboardGoalsWidget fragment = new DashboardGoalsWidget();
Bundle args = new Bundle();
args.putInt(ARG_TIME_FROM, timeFrom);
args.putInt(ARG_TIME_TO, timeTo);
args.putSerializable(ARG_DASHBOARD_DATA, dashboardData);
fragment.setArguments(args);
return fragment;
}
@ -133,19 +131,19 @@ public class DashboardGoalsWidget extends AbstractDashboardWidget {
paint.setStrokeWidth(barWidth);
paint.setColor(color_activity);
canvas.drawArc(barMargin, barMargin, width - barMargin, height - barMargin, 270, 360 * HealthUtils.getStepsGoalFactor(timeTo), false, paint);
canvas.drawArc(barMargin, barMargin, width - barMargin, height - barMargin, 270, 360 * dashboardData.getStepsGoalFactor(), false, paint);
barMargin += barWidth * 1.5;
paint.setColor(color_distance);
canvas.drawArc(barMargin, barMargin, width - barMargin, height - barMargin, 270, 360 * HealthUtils.getDistanceGoalFactor(timeTo), false, paint);
canvas.drawArc(barMargin, barMargin, width - barMargin, height - barMargin, 270, 360 * dashboardData.getDistanceGoalFactor(), false, paint);
barMargin += barWidth * 1.5;
paint.setColor(color_active_time);
canvas.drawArc(barMargin, barMargin, width - barMargin, height - barMargin, 270, 360 * HealthUtils.getActiveMinutesGoalFactor(timeFrom, timeTo), false, paint);
canvas.drawArc(barMargin, barMargin, width - barMargin, height - barMargin, 270, 360 * dashboardData.getActiveMinutesGoalFactor(), false, paint);
barMargin += barWidth * 1.5;
paint.setColor(color_light_sleep);
canvas.drawArc(barMargin, barMargin, width - barMargin, height - barMargin, 270, 360 * HealthUtils.getSleepMinutesGoalFactor(timeTo), false, paint);
canvas.drawArc(barMargin, barMargin, width - barMargin, height - barMargin, 270, 360 * dashboardData.getSleepMinutesGoalFactor(), false, paint);
return null;
}

View File

@ -27,7 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.util.HealthUtils;
import nodomain.freeyourgadget.gadgetbridge.activities.DashboardFragment;
/**
* A simple {@link AbstractDashboardWidget} subclass.
@ -47,15 +47,13 @@ public class DashboardSleepWidget extends AbstractDashboardWidget {
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param timeFrom Start time in seconds since Unix epoch.
* @param timeTo End time in seconds since Unix epoch.
* @param dashboardData An instance of DashboardFragment.DashboardData.
* @return A new instance of fragment DashboardSleepWidget.
*/
public static DashboardSleepWidget newInstance(int timeFrom, int timeTo) {
public static DashboardSleepWidget newInstance(DashboardFragment.DashboardData dashboardData) {
DashboardSleepWidget fragment = new DashboardSleepWidget();
Bundle args = new Bundle();
args.putInt(ARG_TIME_FROM, timeFrom);
args.putInt(ARG_TIME_TO, timeTo);
args.putSerializable(ARG_DASHBOARD_DATA, dashboardData);
fragment.setArguments(args);
return fragment;
}
@ -80,12 +78,12 @@ public class DashboardSleepWidget extends AbstractDashboardWidget {
@Override
protected void fillData() {
// Update text representation
long totalSleepMinutes = HealthUtils.getSleepMinutesTotal(timeTo);
long totalSleepMinutes = dashboardData.getSleepMinutesTotal();
String sleepHours = String.format("%d", (int) Math.floor(totalSleepMinutes / 60f));
String sleepMinutes = String.format("%02d", (int) (totalSleepMinutes % 60f));
sleepAmount.setText(sleepHours + ":" + sleepMinutes);
// Draw gauge
sleepGauge.setImageBitmap(drawGauge(200, 15, color_light_sleep, HealthUtils.getSleepMinutesGoalFactor(timeTo)));
sleepGauge.setImageBitmap(drawGauge(200, 15, color_light_sleep, dashboardData.getSleepMinutesGoalFactor()));
}
}

View File

@ -27,7 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.util.HealthUtils;
import nodomain.freeyourgadget.gadgetbridge.activities.DashboardFragment;
/**
* A simple {@link AbstractDashboardWidget} subclass.
@ -47,15 +47,13 @@ public class DashboardStepsWidget extends AbstractDashboardWidget {
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param timeFrom Start time in seconds since Unix epoch.
* @param timeTo End time in seconds since Unix epoch.
* @param dashboardData An instance of DashboardFragment.DashboardData.
* @return A new instance of fragment DashboardStepsWidget.
*/
public static DashboardStepsWidget newInstance(int timeFrom, int timeTo) {
public static DashboardStepsWidget newInstance(DashboardFragment.DashboardData dashboardData) {
DashboardStepsWidget fragment = new DashboardStepsWidget();
Bundle args = new Bundle();
args.putInt(ARG_TIME_FROM, timeFrom);
args.putInt(ARG_TIME_TO, timeTo);
args.putSerializable(ARG_DASHBOARD_DATA, dashboardData);
fragment.setArguments(args);
return fragment;
}
@ -77,9 +75,9 @@ public class DashboardStepsWidget extends AbstractDashboardWidget {
protected void fillData() {
// Update text representation
stepsCount.setText(String.valueOf(HealthUtils.getStepsTotal(timeTo)));
stepsCount.setText(String.valueOf(dashboardData.getStepsTotal()));
// Draw gauge
stepsGauge.setImageBitmap(drawGauge(200, 15, color_activity, HealthUtils.getStepsGoalFactor(timeTo)));
stepsGauge.setImageBitmap(drawGauge(200, 15, color_activity, dashboardData.getStepsGoalFactor()));
}
}

View File

@ -43,6 +43,7 @@ import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.DashboardFragment;
import nodomain.freeyourgadget.gadgetbridge.activities.charts.StepAnalysis;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -75,15 +76,13 @@ public class DashboardTodayWidget extends AbstractDashboardWidget {
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param timeFrom Start time in seconds since Unix epoch.
* @param timeTo End time in seconds since Unix epoch.
* @param dashboardData An instance of DashboardFragment.DashboardData.
* @return A new instance of fragment DashboardTodayWidget.
*/
public static DashboardTodayWidget newInstance(int timeFrom, int timeTo) {
public static DashboardTodayWidget newInstance(DashboardFragment.DashboardData dashboardData) {
DashboardTodayWidget fragment = new DashboardTodayWidget();
Bundle args = new Bundle();
args.putInt(ARG_TIME_FROM, timeFrom);
args.putInt(ARG_TIME_TO, timeTo);
args.putSerializable(ARG_DASHBOARD_DATA, dashboardData);
fragment.setArguments(args);
return fragment;
}
@ -209,7 +208,7 @@ public class DashboardTodayWidget extends AbstractDashboardWidget {
try (DBHandler dbHandler = GBApplication.acquireDB()) {
for (GBDevice dev : devices) {
if (dev.getDeviceCoordinator().supportsActivityTracking()) {
List<? extends ActivitySample> activitySamples = HealthUtils.getAllSamples(dbHandler, dev, timeFrom, timeTo);
List<? extends ActivitySample> activitySamples = HealthUtils.getAllSamples(dbHandler, dev, dashboardData.timeFrom, dashboardData.timeTo);
allActivitySamples.addAll(activitySamples);
StepAnalysis stepAnalysis = new StepAnalysis();
stepSessions.addAll(stepAnalysis.calculateStepSessions(activitySamples));
@ -221,7 +220,7 @@ public class DashboardTodayWidget extends AbstractDashboardWidget {
// Integrate and chronologically order various data from multiple devices
List<GeneralizedActivity> generalizedActivities = new ArrayList<>();
long midDaySecond = timeFrom + (12 * 60 * 60);
long midDaySecond = dashboardData.timeFrom + (12 * 60 * 60);
for (ActivitySample sample : allActivitySamples) {
// Handle only TYPE_NOT_WORN and TYPE_SLEEP (including variants) here
if (sample.getKind() != ActivityKind.TYPE_NOT_WORN && (sample.getKind() == ActivityKind.TYPE_NOT_MEASURED || (sample.getKind() & ActivityKind.TYPE_SLEEP) == 0))
@ -270,7 +269,7 @@ public class DashboardTodayWidget extends AbstractDashboardWidget {
ArrayList<Integer> colors_0_12 = new ArrayList<>();
ArrayList<PieEntry> entries_12_24 = new ArrayList<>();
ArrayList<Integer> colors_12_24 = new ArrayList<>();
long secondIndex = timeFrom;
long secondIndex = dashboardData.timeFrom;
for (GeneralizedActivity activity : generalizedActivities) {
// FIXME: correctly merge parallel activities from multiple devices
// Skip earlier sessions
@ -308,7 +307,7 @@ public class DashboardTodayWidget extends AbstractDashboardWidget {
}
// Fill remaining time until midnight
long currentTime = Calendar.getInstance().getTimeInMillis() / 1000;
if (!mode_24h && currentTime > timeFrom && currentTime < midDaySecond) {
if (!mode_24h && currentTime > dashboardData.timeFrom && currentTime < midDaySecond) {
// Fill with unknown slice up until current time
entries_0_12.add(new PieEntry(currentTime - secondIndex, "Unknown"));
colors_0_12.add(color_worn);
@ -316,12 +315,12 @@ public class DashboardTodayWidget extends AbstractDashboardWidget {
entries_0_12.add(new PieEntry(midDaySecond - currentTime, "Empty"));
colors_0_12.add(Color.TRANSPARENT);
}
if ((mode_24h || currentTime >= midDaySecond) && currentTime < timeTo) {
if ((mode_24h || currentTime >= midDaySecond) && currentTime < dashboardData.timeTo) {
// Fill with unknown slice up until current time
entries_12_24.add(new PieEntry(currentTime - secondIndex, "Unknown"));
colors_12_24.add(color_worn);
// Draw transparent slice for remaining time until midnight
entries_12_24.add(new PieEntry(timeTo - currentTime, "Empty"));
entries_12_24.add(new PieEntry(dashboardData.timeTo - currentTime, "Empty"));
colors_12_24.add(Color.TRANSPARENT);
}