diff --git a/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt index 4a81820fd7..03214175d2 100644 --- a/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt @@ -2,9 +2,9 @@ package info.nightscout.androidaps.historyBrowser import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin @@ -15,7 +15,9 @@ import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import javax.inject.Inject +import javax.inject.Singleton +@Singleton class IobCobStaticCalculatorPlugin @Inject constructor( injector: HasAndroidInjector, aapsLogger: AAPSLogger, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java index c38c286122..01e8aa2ce2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java @@ -814,9 +814,9 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat getAapsLogger().debug(LTag.AUTOSENS, "Starting calculation thread: " + from + " to " + dateUtil.dateAndTimeString(end)); if (thread == null || thread.getState() == Thread.State.TERMINATED) { if (sensitivityOref1Plugin.isEnabled()) - thread = new IobCobOref1Thread(injector, from, end, bgDataReload, limitDataToOldestAvailable, cause); + thread = new IobCobOref1Thread(injector, this, from, end, bgDataReload, limitDataToOldestAvailable, cause); else - thread = new IobCobThread(injector, from, end, bgDataReload, limitDataToOldestAvailable, cause); + thread = new IobCobThread(injector, this, from, end, bgDataReload, limitDataToOldestAvailable, cause); thread.start(); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java index 457b16716a..ef891ff62c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java @@ -62,7 +62,6 @@ public class IobCobOref1Thread extends Thread { @Inject ProfileFunction profileFunction; @Inject Context context; @Inject ActivePluginProvider activePluginProvider; - @Inject IobCobCalculatorPlugin iobCobCalculatorPlugin; @Inject SensitivityAAPSPlugin sensitivityAAPSPlugin; @Inject SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin; @Inject BuildHelper buildHelper; @@ -71,6 +70,7 @@ public class IobCobOref1Thread extends Thread { @Inject DateUtil dateUtil; private final HasAndroidInjector injector; + private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance private boolean bgDataReload; private boolean limitDataToOldestAvailable; private String from; @@ -78,10 +78,11 @@ public class IobCobOref1Thread extends Thread { private PowerManager.WakeLock mWakeLock; - IobCobOref1Thread(HasAndroidInjector injector, String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) { + IobCobOref1Thread(HasAndroidInjector injector, IobCobCalculatorPlugin iobCobCalculatorPlugin, String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) { super(); injector.androidInjector().inject(this); this.injector = injector; + this.iobCobCalculatorPlugin = iobCobCalculatorPlugin; this.bgDataReload = bgDataReload; this.limitDataToOldestAvailable = limitDataToOldestAvailable; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java index 84a02005e1..d5af67e3b8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java @@ -59,7 +59,6 @@ public class IobCobThread extends Thread { @Inject ProfileFunction profileFunction; @Inject Context context; @Inject ActivePluginProvider activePluginProvider; - @Inject IobCobCalculatorPlugin iobCobCalculatorPlugin; @Inject SensitivityAAPSPlugin sensitivityAAPSPlugin; @Inject SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin; @Inject BuildHelper buildHelper; @@ -68,6 +67,7 @@ public class IobCobThread extends Thread { @Inject DateUtil dateUtil; private final HasAndroidInjector injector; + private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance private boolean bgDataReload; private boolean limitDataToOldestAvailable; private String from; @@ -75,10 +75,11 @@ public class IobCobThread extends Thread { private PowerManager.WakeLock mWakeLock; - @Inject IobCobThread(HasAndroidInjector injector, String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) { + @Inject IobCobThread(HasAndroidInjector injector, IobCobCalculatorPlugin iobCobCalculatorPlugin, String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) { super(); injector.androidInjector().inject(this); this.injector = injector; + this.iobCobCalculatorPlugin = iobCobCalculatorPlugin; this.bgDataReload = bgDataReload; this.limitDataToOldestAvailable = limitDataToOldestAvailable;