From 4b374e3f7efdc27284ec2e4e278328590d407afe Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Mon, 16 May 2016 23:45:21 +0200 Subject: [PATCH] Implement changeStoredSamplesType() --- .../devices/AbstractSampleProvider.java | 14 ++++++++++---- .../entities/AbstractActivitySample.java | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractSampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractSampleProvider.java index 4df87cc4..127df254 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractSampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractSampleProvider.java @@ -98,15 +98,21 @@ public abstract class AbstractSampleProvider i // public void changeStoredSamplesType(int timestampFrom, int timestampTo, int kind) { - // TODO: implement + List samples = getAllActivitySamples(timestampFrom, timestampTo); + for (T sample : samples) { + sample.setRawKind(kind); + } + getSampleDao().updateInTx(samples); } public void changeStoredSamplesType(int timestampFrom, int timestampTo, int fromKind, int toKind) { - // TODO: implement + List samples = getGBActivitySamples(timestampFrom, timestampTo, fromKind); + for (T sample : samples) { + sample.setRawKind(toKind); + } + getSampleDao().updateInTx(samples); } -//// SQLiteDatabase getWritableDatabase(); - protected List getGBActivitySamples(int timestamp_from, int timestamp_to, int activityType) { QueryBuilder qb = getSampleDao().queryBuilder(); qb.where(MiBandActivitySampleDao.Properties.Timestamp.ge(timestamp_from)) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/entities/AbstractActivitySample.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/entities/AbstractActivitySample.java index 81474e5b..e9956665 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/entities/AbstractActivitySample.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/entities/AbstractActivitySample.java @@ -26,6 +26,10 @@ public abstract class AbstractActivitySample implements ActivitySample { return getProvider().normalizeIntensity(getRawIntensity()); } + public abstract void setRawKind(int kind); + + public abstract void setRawIntensity(int intensity); + @Override public String toString() { return getClass().getSimpleName() + "{" +