diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt index f4eddb4a5e..2f4f7d935e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt @@ -83,7 +83,7 @@ class DexcomPlugin @Inject constructor( @Inject lateinit var sp: SP @Inject lateinit var dateUtil: DateUtil @Inject lateinit var dataWorker: DataWorker - @Inject lateinit var broadcastToXDrip: XDripBroadcast + @Inject lateinit var xDripBroadcast: XDripBroadcast @Inject lateinit var repository: AppRepository @Inject lateinit var uel: UserEntryLogger @@ -147,11 +147,11 @@ class DexcomPlugin @Inject constructor( .blockingGet() .also { result -> result.inserted.forEach { - broadcastToXDrip(it) + xDripBroadcast.send(it) aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") } result.updated.forEach { - broadcastToXDrip(it) + xDripBroadcast.send(it) aapsLogger.debug(LTag.DATABASE, "Updated bg $it") } result.sensorInsertionsInserted.forEach { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt index 6efc905729..e1f464f7f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt @@ -60,7 +60,7 @@ class EversensePlugin @Inject constructor( @Inject lateinit var dateUtil: DateUtil @Inject lateinit var dataWorker: DataWorker @Inject lateinit var repository: AppRepository - @Inject lateinit var broadcastToXDrip: XDripBroadcast + @Inject lateinit var xDripBroadcast: XDripBroadcast init { (context.applicationContext as HasAndroidInjector).androidInjector().inject(this) @@ -117,7 +117,7 @@ class EversensePlugin @Inject constructor( .blockingGet() .also { savedValues -> savedValues.inserted.forEach { - broadcastToXDrip(it) + xDripBroadcast.send(it) aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt index 9429e3b7c6..d23831a413 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt @@ -49,7 +49,7 @@ class GlimpPlugin @Inject constructor( @Inject lateinit var glimpPlugin: GlimpPlugin @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var repository: AppRepository - @Inject lateinit var broadcastToXDrip: XDripBroadcast + @Inject lateinit var xDripBroadcast: XDripBroadcast init { (context.applicationContext as HasAndroidInjector).androidInjector().inject(this) @@ -77,7 +77,7 @@ class GlimpPlugin @Inject constructor( .blockingGet() .also { savedValues -> savedValues.inserted.forEach { - broadcastToXDrip(it) + xDripBroadcast.send(it) aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt index 3b756c9f1c..63da6b8761 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt @@ -52,7 +52,7 @@ class MM640gPlugin @Inject constructor( @Inject lateinit var dateUtil: DateUtil @Inject lateinit var dataWorker: DataWorker @Inject lateinit var repository: AppRepository - @Inject lateinit var broadcastToXDrip: XDripBroadcast + @Inject lateinit var xDripBroadcast: XDripBroadcast init { (context.applicationContext as HasAndroidInjector).androidInjector().inject(this) @@ -93,7 +93,7 @@ class MM640gPlugin @Inject constructor( .blockingGet() .also { savedValues -> savedValues.all().forEach { - broadcastToXDrip(it) + xDripBroadcast.send(it) aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt index e1d1238e0d..0069586498 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt @@ -91,7 +91,7 @@ class NSClientSourcePlugin @Inject constructor( @Inject lateinit var dateUtil: DateUtil @Inject lateinit var dataWorker: DataWorker @Inject lateinit var repository: AppRepository - @Inject lateinit var broadcastToXDrip: XDripBroadcast + @Inject lateinit var xDripBroadcast: XDripBroadcast @Inject lateinit var dexcomPlugin: DexcomPlugin @Inject lateinit var nsClientPlugin: NSClientPlugin @@ -148,12 +148,12 @@ class NSClientSourcePlugin @Inject constructor( .blockingGet() .also { result -> result.updated.forEach { - broadcastToXDrip(it) + xDripBroadcast.send(it) nsClientSourcePlugin.detectSource(it) aapsLogger.debug(LTag.DATABASE, "Updated bg $it") } result.inserted.forEach { - broadcastToXDrip(it) + xDripBroadcast.send(it) nsClientSourcePlugin.detectSource(it) aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt index 4fe6fe5532..d17bef33e6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt @@ -51,7 +51,7 @@ class PoctechPlugin @Inject constructor( @Inject lateinit var poctechPlugin: PoctechPlugin @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var repository: AppRepository - @Inject lateinit var broadcastToXDrip: XDripBroadcast + @Inject lateinit var xDripBroadcast: XDripBroadcast init { (context.applicationContext as HasAndroidInjector).androidInjector().inject(this) @@ -86,7 +86,7 @@ class PoctechPlugin @Inject constructor( .blockingGet() .also { savedValues -> savedValues.inserted.forEach { - broadcastToXDrip(it) + xDripBroadcast.send(it) aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt index 1a55c23a35..66cf7f43ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt @@ -110,7 +110,7 @@ class RandomBgPlugin @Inject constructor( disposable += repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .subscribe({ savedValues -> savedValues.inserted.forEach { - xDripBroadcast(it) + xDripBroadcast.send(it) aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") } }, { aapsLogger.error(LTag.DATABASE, "Error while saving values from Random plugin", it) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt index 5c8e98190b..fd0eeb48dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt @@ -49,7 +49,7 @@ class TomatoPlugin @Inject constructor( @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var sp: SP @Inject lateinit var repository: AppRepository - @Inject lateinit var broadcastToXDrip: XDripBroadcast + @Inject lateinit var xDripBroadcast: XDripBroadcast init { (context.applicationContext as HasAndroidInjector).androidInjector().inject(this) @@ -77,7 +77,7 @@ class TomatoPlugin @Inject constructor( .blockingGet() .also { savedValues -> savedValues.inserted.forEach { - broadcastToXDrip(it) + xDripBroadcast.send(it) aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") } } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/XDripBroadcast.kt b/app/src/main/java/info/nightscout/androidaps/utils/XDripBroadcast.kt index 0ff3cab9ec..d669ef8bc3 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/XDripBroadcast.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/XDripBroadcast.kt @@ -14,14 +14,17 @@ import org.json.JSONObject import java.text.SimpleDateFormat import java.util.* import javax.inject.Inject +import javax.inject.Singleton -@Suppress("SpellCheckingInspection") class XDripBroadcast @Inject constructor( +@Suppress("SpellCheckingInspection") +@Singleton +class XDripBroadcast @Inject constructor( private val context: Context, private val aapsLogger: AAPSLogger, private val sp: SP ) { - operator fun invoke(glucoseValue: GlucoseValue) { + fun send(glucoseValue: GlucoseValue) { if (sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) { val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US) try {