prepare XDripBroadcast

This commit is contained in:
Milos Kozak 2021-11-10 17:10:10 +01:00
parent 081e8bd684
commit 584e91f8dc
9 changed files with 22 additions and 19 deletions

View file

@ -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 {

View file

@ -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")
}
}

View file

@ -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")
}
}

View file

@ -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")
}
}

View file

@ -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")
}

View file

@ -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")
}
}

View file

@ -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) }

View file

@ -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")
}
}

View file

@ -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 {