From d44bc87d1b52e56b109cc56967ddb687d4d0ec7f Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 4 May 2020 10:15:21 +0200 Subject: [PATCH 1/2] Fix Crash TemporyBasal Injector missing with extendedbolus --- .../main/java/info/nightscout/androidaps/db/TemporaryBasal.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java b/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java index c65732b932..aa902b0867 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java +++ b/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java @@ -110,6 +110,8 @@ public class TemporaryBasal implements Interval, DbObjectBase { } public TemporaryBasal(ExtendedBolus extendedBolus) { + injector = MainApp.instance(); + injector.androidInjector().inject(this); double basal = profileFunction.getProfile(extendedBolus.date).getBasal(extendedBolus.date); this.date = extendedBolus.date; this.isValid = extendedBolus.isValid; From 3e63d32d60b900a258cbf05002214f58982644e7 Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 4 May 2020 10:40:22 +0200 Subject: [PATCH 2/2] Add missing function in DatabaseHelper getExtendedBolusDataFromTime(long from, long to, boolean ascending) => I need it for autotune plugin... --- .../nightscout/androidaps/db/DatabaseHelper.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index 616108669f..5759429d69 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -1250,6 +1250,22 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { return new ArrayList(); } + public List getExtendedBolusDataFromTime(long from, long to, boolean ascending) { + try { + List extendedBoluses; + QueryBuilder queryBuilder = getDaoExtendedBolus().queryBuilder(); + queryBuilder.orderBy("date", ascending); + Where where = queryBuilder.where(); + where.between("date", from, to); + PreparedQuery preparedQuery = queryBuilder.prepare(); + extendedBoluses = getDaoExtendedBolus().query(preparedQuery); + return extendedBoluses; + } catch (SQLException e) { + log.error("Unhandled exception", e); + } + return new ArrayList(); + } + public void deleteExtendedBolusById(String _id) { ExtendedBolus stored = findExtendedBolusById(_id); if (stored != null) {