From d791054e42ad4a6b22d183242096097b0fc25e92 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Tue, 1 Sep 2015 22:37:20 +0200 Subject: [PATCH] Fix getLast24Hours() -- take end time into account --- .../activities/charts/AbstractChartFragment.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java index 5c45a6378..1c0ce68b0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java @@ -273,20 +273,19 @@ public abstract class AbstractChartFragment extends AbstractGBFragment { */ protected List getAllSamples(DBHandler db, GBDevice device, int tsFrom, int tsTo) { if (tsFrom == -1) { - tsFrom = getTSLast24Hours(); + tsFrom = getTSLast24Hours(tsTo); } SampleProvider provider = getProvider(device); return db.getAllActivitySamples(tsFrom, tsTo, provider); } - private int getTSLast24Hours() { - long now = System.currentTimeMillis(); - return (int) ((now / 1000) - (24 * 60 * 60)); // -24 hours + private int getTSLast24Hours(int tsTo) { + return (tsTo) - (24 * 60 * 60); // -24 hours } protected List getActivitySamples(DBHandler db, GBDevice device, int tsFrom, int tsTo) { if (tsFrom == -1) { - tsFrom = getTSLast24Hours(); + tsFrom = getTSLast24Hours(tsTo); } SampleProvider provider = getProvider(device); return db.getActivitySamples(tsFrom, tsTo, provider); @@ -295,7 +294,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment { protected List getSleepSamples(DBHandler db, GBDevice device, int tsFrom, int tsTo) { if (tsFrom == -1) { - tsFrom = getTSLast24Hours(); + tsFrom = getTSLast24Hours(tsTo); } SampleProvider provider = getProvider(device); return db.getSleepSamples(tsFrom, tsTo, provider);