fix HistoryBrowser injection
This commit is contained in:
parent
8729fe18bd
commit
eeb4ce1686
|
@ -49,7 +49,8 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||
@Inject lateinit var iobCobStaticCalculatorPlugin: IobCobStaticCalculatorPlugin
|
||||
@Inject lateinit var iobCobCalculatorPluginHistory: IobCobCalculatorPluginHistory
|
||||
@Inject lateinit var treatmentsPluginHistory: TreatmentsPluginHistory
|
||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||
@Inject lateinit var buildHelper: BuildHelper
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
|
@ -148,7 +149,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
public override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
iobCobStaticCalculatorPlugin.stopCalculation("onPause")
|
||||
iobCobCalculatorPluginHistory.stopCalculation("onPause")
|
||||
}
|
||||
|
||||
public override fun onResume() {
|
||||
|
@ -157,7 +158,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ event: EventAutosensCalculationFinished ->
|
||||
// catch only events from iobCobStaticCalculatorPlugin
|
||||
// catch only events from iobCobCalculatorPluginHistory
|
||||
if (event.cause === eventCustomCalculationFinished) {
|
||||
aapsLogger.debug(LTag.AUTOSENS, "EventAutosensCalculationFinished")
|
||||
updateGUI("EventAutosensCalculationFinished")
|
||||
|
@ -220,10 +221,11 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun runCalculation(from: String) {
|
||||
treatmentsPluginHistory.initializeData(start - T.hours(8).msecs())
|
||||
val end = start + T.hours(rangeToDisplay.toLong()).msecs()
|
||||
iobCobStaticCalculatorPlugin.stopCalculation(from)
|
||||
iobCobStaticCalculatorPlugin.clearCache()
|
||||
iobCobStaticCalculatorPlugin.runCalculation(from, end, true, false, eventCustomCalculationFinished)
|
||||
iobCobCalculatorPluginHistory.stopCalculation(from)
|
||||
iobCobCalculatorPluginHistory.clearCache()
|
||||
iobCobCalculatorPluginHistory.runCalculation(from, end, true, false, eventCustomCalculationFinished)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
@ -242,7 +244,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
historybrowse_bggraph ?: return@launch
|
||||
val graphData = GraphData(injector, historybrowse_bggraph, iobCobStaticCalculatorPlugin)
|
||||
val graphData = GraphData(injector, historybrowse_bggraph, iobCobCalculatorPluginHistory, treatmentsPluginHistory)
|
||||
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
||||
|
||||
// do preparation in different thread
|
||||
|
@ -279,7 +281,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
// ------------------ 2nd graph
|
||||
for (g in 0 until secondaryGraphs.size) {
|
||||
val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobStaticCalculatorPlugin)
|
||||
val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobCalculatorPluginHistory, treatmentsPluginHistory)
|
||||
var useIobForScale = false
|
||||
var useCobForScale = false
|
||||
var useDevForScale = false
|
||||
|
|
|
@ -9,7 +9,6 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorP
|
|||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
|
@ -18,7 +17,7 @@ import javax.inject.Inject
|
|||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class IobCobStaticCalculatorPlugin @Inject constructor(
|
||||
class IobCobCalculatorPluginHistory @Inject constructor(
|
||||
injector: HasAndroidInjector,
|
||||
aapsLogger: AAPSLogger,
|
||||
rxBus: RxBusWrapper,
|
||||
|
@ -26,14 +25,14 @@ class IobCobStaticCalculatorPlugin @Inject constructor(
|
|||
resourceHelper: ResourceHelper,
|
||||
profileFunction: ProfileFunction,
|
||||
activePlugin: ActivePluginProvider,
|
||||
treatmentsPlugin: TreatmentsPlugin,
|
||||
treatmentsPluginHistory: TreatmentsPluginHistory,
|
||||
sensitivityOref1Plugin: SensitivityOref1Plugin,
|
||||
sensitivityAAPSPlugin: SensitivityAAPSPlugin,
|
||||
sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin,
|
||||
fabricPrivacy: FabricPrivacy,
|
||||
dateUtil: DateUtil
|
||||
) : IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction,
|
||||
activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil) {
|
||||
activePlugin, treatmentsPluginHistory, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil) {
|
||||
|
||||
override fun onStart() { // do not attach to rxbus
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package info.nightscout.androidaps.historyBrowser
|
||||
|
||||
import android.content.Context
|
||||
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.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentService
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
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 TreatmentsPluginHistory @Inject constructor(
|
||||
injector: HasAndroidInjector,
|
||||
aapsLogger: AAPSLogger,
|
||||
rxBus: RxBusWrapper,
|
||||
resourceHelper: ResourceHelper,
|
||||
context: Context,
|
||||
sp: SP,
|
||||
profileFunction: ProfileFunction,
|
||||
activePlugin: ActivePluginProvider,
|
||||
nsUpload: NSUpload,
|
||||
fabricPrivacy: FabricPrivacy, dateUtil: DateUtil
|
||||
) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, context, sp, profileFunction, activePlugin, nsUpload, fabricPrivacy, dateUtil) {
|
||||
|
||||
init {
|
||||
onStart()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
service = TreatmentService(injector)
|
||||
initializeData(range())
|
||||
}
|
||||
}
|
|
@ -771,7 +771,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
// ****** GRAPH *******
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
overview_bggraph ?: return@launch
|
||||
val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin)
|
||||
val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin, treatmentsPlugin)
|
||||
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
||||
|
||||
// do preparation in different thread
|
||||
|
@ -834,7 +834,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
// ------------------ 2nd graph
|
||||
for (g in 0 until secondaryGraphs.size) {
|
||||
val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobCalculatorPlugin)
|
||||
val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobCalculatorPlugin, treatmentsPlugin)
|
||||
var useIobForScale = false
|
||||
var useCobForScale = false
|
||||
var useDevForScale = false
|
||||
|
|
|
@ -34,7 +34,13 @@ import kotlin.math.abs
|
|||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
class GraphData(injector: HasAndroidInjector, private val graph: GraphView, private val iobCobCalculatorPlugin: IobCobCalculatorPlugin) {
|
||||
class GraphData(
|
||||
injector: HasAndroidInjector,
|
||||
private val graph: GraphView,
|
||||
private val iobCobCalculatorPlugin: IobCobCalculatorPlugin,
|
||||
private val treatmentsPlugin: TreatmentsInterface
|
||||
|
||||
) {
|
||||
|
||||
// IobCobCalculatorPlugin Cannot be injected: HistoryBrowser
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
|
@ -42,8 +48,6 @@ class GraphData(injector: HasAndroidInjector, private val graph: GraphView, priv
|
|||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||
|
||||
private val treatmentsPlugin: TreatmentsInterface
|
||||
|
||||
var maxY = Double.MIN_VALUE
|
||||
private var minY = Double.MAX_VALUE
|
||||
private var bgReadingsArray: List<BgReading>? = null
|
||||
|
@ -53,7 +57,6 @@ class GraphData(injector: HasAndroidInjector, private val graph: GraphView, priv
|
|||
init {
|
||||
injector.androidInjector().inject(this)
|
||||
units = profileFunction.getUnits()
|
||||
treatmentsPlugin = activePlugin.activeTreatments
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
|
|
|
@ -178,7 +178,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
return this.service;
|
||||
}
|
||||
|
||||
private long range() {
|
||||
protected long range() {
|
||||
double dia = Constants.defaultDIA;
|
||||
if (profileFunction.getProfile() != null)
|
||||
dia = profileFunction.getProfile().getDia();
|
||||
|
|
Loading…
Reference in a new issue