mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Fix crash in some chart pages (#4319)
This commit is contained in:
parent
b56ed974a3
commit
9d1a57b6c2
@ -97,14 +97,14 @@ public class BodyEnergyFragment extends AbstractChartFragment<BodyEnergyFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BodyEnergyData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
protected BodyEnergyData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
||||||
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
|
|
||||||
mDateView.setText(formattedDate);
|
|
||||||
List<? extends BodyEnergySample> samples = getBodyEnergySamples(db, device, getTSStart(), getTSEnd());
|
List<? extends BodyEnergySample> samples = getBodyEnergySamples(db, device, getTSStart(), getTSEnd());
|
||||||
return new BodyEnergyData(samples);
|
return new BodyEnergyData(samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateChartsnUIThread(BodyEnergyData bodyEnergyData) {
|
protected void updateChartsnUIThread(BodyEnergyData bodyEnergyData) {
|
||||||
|
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
|
||||||
|
mDateView.setText(formattedDate);
|
||||||
|
|
||||||
List<Entry> lineEntries = new ArrayList<>();
|
List<Entry> lineEntries = new ArrayList<>();
|
||||||
final List<ILineDataSet> lineDataSets = new ArrayList<>();
|
final List<ILineDataSet> lineDataSets = new ArrayList<>();
|
||||||
|
@ -126,10 +126,8 @@ public class HRVStatusFragment extends AbstractChartFragment<HRVStatusFragment.H
|
|||||||
@Override
|
@Override
|
||||||
protected HRVStatusWeeklyData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
protected HRVStatusWeeklyData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
||||||
Calendar day = Calendar.getInstance();
|
Calendar day = Calendar.getInstance();
|
||||||
Date tsEnd = getChartsHost().getEndDate();
|
day.setTime(getEndDate());
|
||||||
day.setTime(tsEnd);
|
|
||||||
String formattedDate = new SimpleDateFormat("E, MMM dd").format(tsEnd);
|
|
||||||
mDateView.setText(formattedDate);
|
|
||||||
List<HRVStatusDayData> weeklyData = getWeeklyData(db, day, device);
|
List<HRVStatusDayData> weeklyData = getWeeklyData(db, day, device);
|
||||||
return new HRVStatusWeeklyData(weeklyData);
|
return new HRVStatusWeeklyData(weeklyData);
|
||||||
}
|
}
|
||||||
@ -164,6 +162,9 @@ public class HRVStatusFragment extends AbstractChartFragment<HRVStatusFragment.H
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateChartsnUIThread(HRVStatusWeeklyData weeklyData) {
|
protected void updateChartsnUIThread(HRVStatusWeeklyData weeklyData) {
|
||||||
|
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
|
||||||
|
mDateView.setText(formattedDate);
|
||||||
|
|
||||||
mWeeklyHRVStatusChart.setData(null); // workaround for https://github.com/PhilJay/MPAndroidChart/issues/2317
|
mWeeklyHRVStatusChart.setData(null); // workaround for https://github.com/PhilJay/MPAndroidChart/issues/2317
|
||||||
List<Entry> lineEntries = new ArrayList<>();
|
List<Entry> lineEntries = new ArrayList<>();
|
||||||
final List<ILineDataSet> lineDataSets = new ArrayList<>();
|
final List<ILineDataSet> lineDataSets = new ArrayList<>();
|
||||||
|
@ -124,9 +124,7 @@ public class HeartRateDailyFragment extends AbstractChartFragment<HeartRateDaily
|
|||||||
day.add(Calendar.HOUR, 0);
|
day.add(Calendar.HOUR, 0);
|
||||||
int startTs = (int) (day.getTimeInMillis() / 1000);
|
int startTs = (int) (day.getTimeInMillis() / 1000);
|
||||||
int endTs = startTs + 24 * 60 * 60 - 1;
|
int endTs = startTs + 24 * 60 * 60 - 1;
|
||||||
Date date = new Date((long) endTs * 1000);
|
|
||||||
String formattedDate = new SimpleDateFormat("E, MMM dd").format(date);
|
|
||||||
mDateView.setText(formattedDate);
|
|
||||||
List<? extends ActivitySample> samples = getActivitySamples(db, device, startTs, endTs);
|
List<? extends ActivitySample> samples = getActivitySamples(db, device, startTs, endTs);
|
||||||
|
|
||||||
int restingHeartRate = -1;
|
int restingHeartRate = -1;
|
||||||
@ -212,6 +210,19 @@ public class HeartRateDailyFragment extends AbstractChartFragment<HeartRateDaily
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateChartsnUIThread(HeartRateDailyFragment.HeartRateData data) {
|
protected void updateChartsnUIThread(HeartRateDailyFragment.HeartRateData data) {
|
||||||
|
Calendar day = Calendar.getInstance();
|
||||||
|
day.setTime(getEndDate());
|
||||||
|
day.add(Calendar.DATE, 0);
|
||||||
|
day.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
day.set(Calendar.MINUTE, 0);
|
||||||
|
day.set(Calendar.SECOND, 0);
|
||||||
|
day.add(Calendar.HOUR, 0);
|
||||||
|
int startTs = (int) (day.getTimeInMillis() / 1000);
|
||||||
|
int endTs = startTs + 24 * 60 * 60 - 1;
|
||||||
|
Date date = new Date((long) endTs * 1000);
|
||||||
|
String formattedDate = new SimpleDateFormat("E, MMM dd").format(date);
|
||||||
|
mDateView.setText(formattedDate);
|
||||||
|
|
||||||
HeartRateUtils heartRateUtilsInstance = HeartRateUtils.getInstance();
|
HeartRateUtils heartRateUtilsInstance = HeartRateUtils.getInstance();
|
||||||
final TimestampTranslation tsTranslation = new TimestampTranslation();
|
final TimestampTranslation tsTranslation = new TimestampTranslation();
|
||||||
final List<Entry> lineEntries = new ArrayList<>();
|
final List<Entry> lineEntries = new ArrayList<>();
|
||||||
|
@ -102,8 +102,6 @@ public class StepsDailyFragment extends StepsFragment<StepsDailyFragment.StepsDa
|
|||||||
protected StepsDailyFragment.StepsData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
protected StepsDailyFragment.StepsData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
||||||
Calendar day = Calendar.getInstance();
|
Calendar day = Calendar.getInstance();
|
||||||
day.setTime(chartsHost.getEndDate());
|
day.setTime(chartsHost.getEndDate());
|
||||||
String formattedDate = new SimpleDateFormat("E, MMM dd").format(chartsHost.getEndDate());
|
|
||||||
mDateView.setText(formattedDate);
|
|
||||||
List<StepsDay> stepsDayList = getMyStepsDaysData(db, day, device);
|
List<StepsDay> stepsDayList = getMyStepsDaysData(db, day, device);
|
||||||
final StepsDay stepsDay;
|
final StepsDay stepsDay;
|
||||||
if (stepsDayList.isEmpty()) {
|
if (stepsDayList.isEmpty()) {
|
||||||
@ -118,6 +116,9 @@ public class StepsDailyFragment extends StepsFragment<StepsDailyFragment.StepsDa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateChartsnUIThread(StepsDailyFragment.StepsData stepsData) {
|
protected void updateChartsnUIThread(StepsDailyFragment.StepsData stepsData) {
|
||||||
|
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
|
||||||
|
mDateView.setText(formattedDate);
|
||||||
|
|
||||||
final int width = (int) TypedValue.applyDimension(
|
final int width = (int) TypedValue.applyDimension(
|
||||||
TypedValue.COMPLEX_UNIT_DIP,
|
TypedValue.COMPLEX_UNIT_DIP,
|
||||||
300,
|
300,
|
||||||
|
@ -143,18 +143,19 @@ public class StepsPeriodFragment extends StepsFragment<StepsPeriodFragment.Steps
|
|||||||
@Override
|
@Override
|
||||||
protected StepsData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
protected StepsData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
||||||
Calendar day = Calendar.getInstance();
|
Calendar day = Calendar.getInstance();
|
||||||
Date to = new Date((long) this.getTSEnd() * 1000);
|
day.setTime(getEndDate());
|
||||||
Date from = DateUtils.addDays(to,-(TOTAL_DAYS - 1));
|
|
||||||
String toFormattedDate = new SimpleDateFormat("E, MMM dd").format(to);
|
|
||||||
String fromFormattedDate = new SimpleDateFormat("E, MMM dd").format(from);
|
|
||||||
mDateView.setText(fromFormattedDate + " - " + toFormattedDate);
|
|
||||||
day.setTime(to);
|
|
||||||
List<StepsDay> stepsDaysData = getMyStepsDaysData(db, day, device);
|
List<StepsDay> stepsDaysData = getMyStepsDaysData(db, day, device);
|
||||||
return new StepsData(stepsDaysData);
|
return new StepsData(stepsDaysData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateChartsnUIThread(StepsData stepsData) {
|
protected void updateChartsnUIThread(StepsData stepsData) {
|
||||||
|
Date to = new Date((long) getTSEnd() * 1000);
|
||||||
|
Date from = DateUtils.addDays(to,-(TOTAL_DAYS - 1));
|
||||||
|
String toFormattedDate = new SimpleDateFormat("E, MMM dd").format(to);
|
||||||
|
String fromFormattedDate = new SimpleDateFormat("E, MMM dd").format(from);
|
||||||
|
mDateView.setText(fromFormattedDate + " - " + toFormattedDate);
|
||||||
|
|
||||||
stepsChart.setData(null);
|
stepsChart.setData(null);
|
||||||
|
|
||||||
List<BarEntry> entries = new ArrayList<>();
|
List<BarEntry> entries = new ArrayList<>();
|
||||||
|
@ -118,8 +118,6 @@ public class VO2MaxFragment extends AbstractChartFragment<VO2MaxFragment.VO2MaxD
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected VO2MaxData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
protected VO2MaxData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
||||||
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
|
|
||||||
mDateView.setText(formattedDate);
|
|
||||||
List<VO2MaxRecord> records = new ArrayList<>();
|
List<VO2MaxRecord> records = new ArrayList<>();
|
||||||
int tsEnd = getTSEnd();
|
int tsEnd = getTSEnd();
|
||||||
Calendar day = Calendar.getInstance();
|
Calendar day = Calendar.getInstance();
|
||||||
@ -145,7 +143,9 @@ public class VO2MaxFragment extends AbstractChartFragment<VO2MaxFragment.VO2MaxD
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateChartsnUIThread(VO2MaxData vo2MaxData) {
|
protected void updateChartsnUIThread(VO2MaxData vo2MaxData) {
|
||||||
TimestampTranslation tsTranslation = new TimestampTranslation();
|
String formattedDate = new SimpleDateFormat("E, MMM dd").format(getEndDate());
|
||||||
|
mDateView.setText(formattedDate);
|
||||||
|
|
||||||
List<Entry> runningEntries = new ArrayList<>();
|
List<Entry> runningEntries = new ArrayList<>();
|
||||||
List<Entry> cyclingEntries = new ArrayList<>();
|
List<Entry> cyclingEntries = new ArrayList<>();
|
||||||
vo2MaxData.records.forEach((record) -> {
|
vo2MaxData.records.forEach((record) -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user