1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-04 01:09:47 +01:00

Fix getLast24Hours() -- take end time into account

This commit is contained in:
cpfeiffer 2015-09-01 22:37:20 +02:00
parent a6d18e599b
commit d791054e42

View File

@ -273,20 +273,19 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
*/ */
protected List<ActivitySample> getAllSamples(DBHandler db, GBDevice device, int tsFrom, int tsTo) { protected List<ActivitySample> getAllSamples(DBHandler db, GBDevice device, int tsFrom, int tsTo) {
if (tsFrom == -1) { if (tsFrom == -1) {
tsFrom = getTSLast24Hours(); tsFrom = getTSLast24Hours(tsTo);
} }
SampleProvider provider = getProvider(device); SampleProvider provider = getProvider(device);
return db.getAllActivitySamples(tsFrom, tsTo, provider); return db.getAllActivitySamples(tsFrom, tsTo, provider);
} }
private int getTSLast24Hours() { private int getTSLast24Hours(int tsTo) {
long now = System.currentTimeMillis(); return (tsTo) - (24 * 60 * 60); // -24 hours
return (int) ((now / 1000) - (24 * 60 * 60)); // -24 hours
} }
protected List<ActivitySample> getActivitySamples(DBHandler db, GBDevice device, int tsFrom, int tsTo) { protected List<ActivitySample> getActivitySamples(DBHandler db, GBDevice device, int tsFrom, int tsTo) {
if (tsFrom == -1) { if (tsFrom == -1) {
tsFrom = getTSLast24Hours(); tsFrom = getTSLast24Hours(tsTo);
} }
SampleProvider provider = getProvider(device); SampleProvider provider = getProvider(device);
return db.getActivitySamples(tsFrom, tsTo, provider); return db.getActivitySamples(tsFrom, tsTo, provider);
@ -295,7 +294,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
protected List<ActivitySample> getSleepSamples(DBHandler db, GBDevice device, int tsFrom, int tsTo) { protected List<ActivitySample> getSleepSamples(DBHandler db, GBDevice device, int tsFrom, int tsTo) {
if (tsFrom == -1) { if (tsFrom == -1) {
tsFrom = getTSLast24Hours(); tsFrom = getTSLast24Hours(tsTo);
} }
SampleProvider provider = getProvider(device); SampleProvider provider = getProvider(device);
return db.getSleepSamples(tsFrom, tsTo, provider); return db.getSleepSamples(tsFrom, tsTo, provider);