This commit is contained in:
Milos Kozak 2022-12-04 17:07:47 +01:00
parent 9a35579d66
commit 8dc346e4c8
4 changed files with 14 additions and 14 deletions

View file

@ -17,7 +17,7 @@ import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.plugins.aps.databinding.OpenapsFragmentBinding import info.nightscout.plugins.aps.databinding.OpenapsFragmentBinding
import info.nightscout.plugins.aps.events.EventOpenAPSUpdateGui import info.nightscout.plugins.aps.events.EventOpenAPSUpdateGui
import info.nightscout.plugins.aps.events.EventOpenAPSUpdateResultGui import info.nightscout.plugins.aps.events.EventResetOpenAPSGui
import info.nightscout.plugins.aps.utils.JSONFormatter import info.nightscout.plugins.aps.utils.JSONFormatter
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -97,10 +97,10 @@ class OpenAPSFragment : DaggerFragment(), MenuProvider {
updateGUI() updateGUI()
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus
.toObservable(EventOpenAPSUpdateResultGui::class.java) .toObservable(EventResetOpenAPSGui::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ .subscribe({
updateResultGUI(it.text) resetGUI(it.text)
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
updateGUI() updateGUI()
@ -156,7 +156,7 @@ class OpenAPSFragment : DaggerFragment(), MenuProvider {
} }
@Synchronized @Synchronized
private fun updateResultGUI(text: String) { private fun resetGUI(text: String) {
if (_binding == null) return if (_binding == null) return
binding.result.text = text binding.result.text = text
binding.glucosestatus.text = "" binding.glucosestatus.text = ""

View file

@ -2,4 +2,4 @@ package info.nightscout.plugins.aps.events
import info.nightscout.rx.events.EventUpdateGui import info.nightscout.rx.events.EventUpdateGui
class EventOpenAPSUpdateResultGui(val text: String) : EventUpdateGui() class EventResetOpenAPSGui(val text: String) : EventUpdateGui()

View file

@ -27,7 +27,7 @@ import info.nightscout.interfaces.utils.Round
import info.nightscout.plugins.aps.OpenAPSFragment import info.nightscout.plugins.aps.OpenAPSFragment
import info.nightscout.plugins.aps.R import info.nightscout.plugins.aps.R
import info.nightscout.plugins.aps.events.EventOpenAPSUpdateGui import info.nightscout.plugins.aps.events.EventOpenAPSUpdateGui
import info.nightscout.plugins.aps.events.EventOpenAPSUpdateResultGui import info.nightscout.plugins.aps.events.EventResetOpenAPSGui
import info.nightscout.plugins.aps.utils.ScriptReader import info.nightscout.plugins.aps.utils.ScriptReader
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -100,17 +100,17 @@ class OpenAPSAMAPlugin @Inject constructor(
val profile = profileFunction.getProfile() val profile = profileFunction.getProfile()
val pump = activePlugin.activePump val pump = activePlugin.activePump
if (profile == null) { if (profile == null) {
rxBus.send(EventOpenAPSUpdateResultGui(rh.gs(info.nightscout.core.ui.R.string.no_profile_set))) rxBus.send(EventResetOpenAPSGui(rh.gs(info.nightscout.core.ui.R.string.no_profile_set)))
aapsLogger.debug(LTag.APS, rh.gs(info.nightscout.core.ui.R.string.no_profile_set)) aapsLogger.debug(LTag.APS, rh.gs(info.nightscout.core.ui.R.string.no_profile_set))
return return
} }
if (!isEnabled()) { if (!isEnabled()) {
rxBus.send(EventOpenAPSUpdateResultGui(rh.gs(R.string.openapsma_disabled))) rxBus.send(EventResetOpenAPSGui(rh.gs(R.string.openapsma_disabled)))
aapsLogger.debug(LTag.APS, rh.gs(R.string.openapsma_disabled)) aapsLogger.debug(LTag.APS, rh.gs(R.string.openapsma_disabled))
return return
} }
if (glucoseStatus == null) { if (glucoseStatus == null) {
rxBus.send(EventOpenAPSUpdateResultGui(rh.gs(R.string.openapsma_no_glucose_data))) rxBus.send(EventResetOpenAPSGui(rh.gs(R.string.openapsma_no_glucose_data)))
aapsLogger.debug(LTag.APS, rh.gs(R.string.openapsma_no_glucose_data)) aapsLogger.debug(LTag.APS, rh.gs(R.string.openapsma_no_glucose_data))
return return
} }
@ -167,7 +167,7 @@ class OpenAPSAMAPlugin @Inject constructor(
if (constraintChecker.isAutosensModeEnabled().value()) { if (constraintChecker.isAutosensModeEnabled().value()) {
val autosensData = iobCobCalculator.getLastAutosensDataWithWaitForCalculationFinish("OpenAPSPlugin") val autosensData = iobCobCalculator.getLastAutosensDataWithWaitForCalculationFinish("OpenAPSPlugin")
if (autosensData == null) { if (autosensData == null) {
rxBus.send(EventOpenAPSUpdateResultGui(rh.gs(R.string.openaps_no_as_data))) rxBus.send(EventResetOpenAPSGui(rh.gs(R.string.openaps_no_as_data)))
return return
} }
lastAutosensResult = autosensData.autosensResult lastAutosensResult = autosensData.autosensResult

View file

@ -104,17 +104,17 @@ class OpenAPSSMBPlugin @Inject constructor(
val profile = profileFunction.getProfile() val profile = profileFunction.getProfile()
val pump = activePlugin.activePump val pump = activePlugin.activePump
if (profile == null) { if (profile == null) {
rxBus.send(info.nightscout.plugins.aps.events.EventOpenAPSUpdateResultGui(rh.gs(info.nightscout.core.ui.R.string.no_profile_set))) rxBus.send(info.nightscout.plugins.aps.events.EventResetOpenAPSGui(rh.gs(info.nightscout.core.ui.R.string.no_profile_set)))
aapsLogger.debug(LTag.APS, rh.gs(info.nightscout.core.ui.R.string.no_profile_set)) aapsLogger.debug(LTag.APS, rh.gs(info.nightscout.core.ui.R.string.no_profile_set))
return return
} }
if (!isEnabled()) { if (!isEnabled()) {
rxBus.send(info.nightscout.plugins.aps.events.EventOpenAPSUpdateResultGui(rh.gs(R.string.openapsma_disabled))) rxBus.send(info.nightscout.plugins.aps.events.EventResetOpenAPSGui(rh.gs(R.string.openapsma_disabled)))
aapsLogger.debug(LTag.APS, rh.gs(R.string.openapsma_disabled)) aapsLogger.debug(LTag.APS, rh.gs(R.string.openapsma_disabled))
return return
} }
if (glucoseStatus == null) { if (glucoseStatus == null) {
rxBus.send(info.nightscout.plugins.aps.events.EventOpenAPSUpdateResultGui(rh.gs(R.string.openapsma_no_glucose_data))) rxBus.send(info.nightscout.plugins.aps.events.EventResetOpenAPSGui(rh.gs(R.string.openapsma_no_glucose_data)))
aapsLogger.debug(LTag.APS, rh.gs(R.string.openapsma_no_glucose_data)) aapsLogger.debug(LTag.APS, rh.gs(R.string.openapsma_no_glucose_data))
return return
} }
@ -169,7 +169,7 @@ class OpenAPSSMBPlugin @Inject constructor(
if (constraintChecker.isAutosensModeEnabled().value()) { if (constraintChecker.isAutosensModeEnabled().value()) {
val autosensData = iobCobCalculator.getLastAutosensDataWithWaitForCalculationFinish("OpenAPSPlugin") val autosensData = iobCobCalculator.getLastAutosensDataWithWaitForCalculationFinish("OpenAPSPlugin")
if (autosensData == null) { if (autosensData == null) {
rxBus.send(info.nightscout.plugins.aps.events.EventOpenAPSUpdateResultGui(rh.gs(R.string.openaps_no_as_data))) rxBus.send(info.nightscout.plugins.aps.events.EventResetOpenAPSGui(rh.gs(R.string.openaps_no_as_data)))
return return
} }
lastAutosensResult = autosensData.autosensResult lastAutosensResult = autosensData.autosensResult