prepare XDripBroadcast
This commit is contained in:
parent
081e8bd684
commit
584e91f8dc
9 changed files with 22 additions and 19 deletions
|
@ -83,7 +83,7 @@ class DexcomPlugin @Inject constructor(
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorker: DataWorker
|
||||||
@Inject lateinit var broadcastToXDrip: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var uel: UserEntryLogger
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
|
@ -147,11 +147,11 @@ class DexcomPlugin @Inject constructor(
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
.also { result ->
|
.also { result ->
|
||||||
result.inserted.forEach {
|
result.inserted.forEach {
|
||||||
broadcastToXDrip(it)
|
xDripBroadcast.send(it)
|
||||||
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
||||||
}
|
}
|
||||||
result.updated.forEach {
|
result.updated.forEach {
|
||||||
broadcastToXDrip(it)
|
xDripBroadcast.send(it)
|
||||||
aapsLogger.debug(LTag.DATABASE, "Updated bg $it")
|
aapsLogger.debug(LTag.DATABASE, "Updated bg $it")
|
||||||
}
|
}
|
||||||
result.sensorInsertionsInserted.forEach {
|
result.sensorInsertionsInserted.forEach {
|
||||||
|
|
|
@ -60,7 +60,7 @@ class EversensePlugin @Inject constructor(
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorker: DataWorker
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var broadcastToXDrip: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||||
|
@ -117,7 +117,7 @@ class EversensePlugin @Inject constructor(
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
.also { savedValues ->
|
.also { savedValues ->
|
||||||
savedValues.inserted.forEach {
|
savedValues.inserted.forEach {
|
||||||
broadcastToXDrip(it)
|
xDripBroadcast.send(it)
|
||||||
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ class GlimpPlugin @Inject constructor(
|
||||||
@Inject lateinit var glimpPlugin: GlimpPlugin
|
@Inject lateinit var glimpPlugin: GlimpPlugin
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var broadcastToXDrip: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||||
|
@ -77,7 +77,7 @@ class GlimpPlugin @Inject constructor(
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
.also { savedValues ->
|
.also { savedValues ->
|
||||||
savedValues.inserted.forEach {
|
savedValues.inserted.forEach {
|
||||||
broadcastToXDrip(it)
|
xDripBroadcast.send(it)
|
||||||
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ class MM640gPlugin @Inject constructor(
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorker: DataWorker
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var broadcastToXDrip: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||||
|
@ -93,7 +93,7 @@ class MM640gPlugin @Inject constructor(
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
.also { savedValues ->
|
.also { savedValues ->
|
||||||
savedValues.all().forEach {
|
savedValues.all().forEach {
|
||||||
broadcastToXDrip(it)
|
xDripBroadcast.send(it)
|
||||||
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ class NSClientSourcePlugin @Inject constructor(
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var dataWorker: DataWorker
|
@Inject lateinit var dataWorker: DataWorker
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var broadcastToXDrip: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
||||||
@Inject lateinit var nsClientPlugin: NSClientPlugin
|
@Inject lateinit var nsClientPlugin: NSClientPlugin
|
||||||
|
|
||||||
|
@ -148,12 +148,12 @@ class NSClientSourcePlugin @Inject constructor(
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
.also { result ->
|
.also { result ->
|
||||||
result.updated.forEach {
|
result.updated.forEach {
|
||||||
broadcastToXDrip(it)
|
xDripBroadcast.send(it)
|
||||||
nsClientSourcePlugin.detectSource(it)
|
nsClientSourcePlugin.detectSource(it)
|
||||||
aapsLogger.debug(LTag.DATABASE, "Updated bg $it")
|
aapsLogger.debug(LTag.DATABASE, "Updated bg $it")
|
||||||
}
|
}
|
||||||
result.inserted.forEach {
|
result.inserted.forEach {
|
||||||
broadcastToXDrip(it)
|
xDripBroadcast.send(it)
|
||||||
nsClientSourcePlugin.detectSource(it)
|
nsClientSourcePlugin.detectSource(it)
|
||||||
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ class PoctechPlugin @Inject constructor(
|
||||||
@Inject lateinit var poctechPlugin: PoctechPlugin
|
@Inject lateinit var poctechPlugin: PoctechPlugin
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var broadcastToXDrip: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||||
|
@ -86,7 +86,7 @@ class PoctechPlugin @Inject constructor(
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
.also { savedValues ->
|
.also { savedValues ->
|
||||||
savedValues.inserted.forEach {
|
savedValues.inserted.forEach {
|
||||||
broadcastToXDrip(it)
|
xDripBroadcast.send(it)
|
||||||
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ class RandomBgPlugin @Inject constructor(
|
||||||
disposable += repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
|
disposable += repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
|
||||||
.subscribe({ savedValues ->
|
.subscribe({ savedValues ->
|
||||||
savedValues.inserted.forEach {
|
savedValues.inserted.forEach {
|
||||||
xDripBroadcast(it)
|
xDripBroadcast.send(it)
|
||||||
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
||||||
}
|
}
|
||||||
}, { aapsLogger.error(LTag.DATABASE, "Error while saving values from Random plugin", it) }
|
}, { aapsLogger.error(LTag.DATABASE, "Error while saving values from Random plugin", it) }
|
||||||
|
|
|
@ -49,7 +49,7 @@ class TomatoPlugin @Inject constructor(
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var broadcastToXDrip: XDripBroadcast
|
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||||
|
@ -77,7 +77,7 @@ class TomatoPlugin @Inject constructor(
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
.also { savedValues ->
|
.also { savedValues ->
|
||||||
savedValues.inserted.forEach {
|
savedValues.inserted.forEach {
|
||||||
broadcastToXDrip(it)
|
xDripBroadcast.send(it)
|
||||||
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,17 @@ import org.json.JSONObject
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
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 context: Context,
|
||||||
private val aapsLogger: AAPSLogger,
|
private val aapsLogger: AAPSLogger,
|
||||||
private val sp: SP
|
private val sp: SP
|
||||||
) {
|
) {
|
||||||
|
|
||||||
operator fun invoke(glucoseValue: GlucoseValue) {
|
fun send(glucoseValue: GlucoseValue) {
|
||||||
if (sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
if (sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||||
val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US)
|
val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US)
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue