Cleanup
This commit is contained in:
parent
4e44055014
commit
aaed25c5f8
2 changed files with 10 additions and 11 deletions
|
@ -6,16 +6,15 @@ import android.provider.Telephony
|
|||
import androidx.work.Data
|
||||
import androidx.work.OneTimeWorkRequest
|
||||
import dagger.android.DaggerBroadcastReceiver
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.BundleLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
||||
import info.nightscout.androidaps.plugins.source.*
|
||||
import info.nightscout.androidaps.services.Intents
|
||||
import info.nightscout.androidaps.utils.extensions.copyDouble
|
||||
import info.nightscout.androidaps.utils.extensions.copyInt
|
||||
import info.nightscout.androidaps.utils.extensions.copyLong
|
||||
import info.nightscout.androidaps.utils.extensions.copyString
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.BundleLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
import javax.inject.Inject
|
||||
|
||||
open class DataReceiver : DaggerBroadcastReceiver() {
|
||||
|
@ -31,7 +30,7 @@ open class DataReceiver : DaggerBroadcastReceiver() {
|
|||
when (intent.action) {
|
||||
Intents.ACTION_NEW_BG_ESTIMATE ->
|
||||
OneTimeWorkRequest.Builder(XdripPlugin.XdripWorker::class.java)
|
||||
.setInputData(dataWorker.storeInputData(bundle, intent)).build()
|
||||
.setInputData(dataWorker.storeInputData(bundle, intent.action)).build()
|
||||
Intents.POCTECH_BG ->
|
||||
OneTimeWorkRequest.Builder(PoctechPlugin.PoctechWorker::class.java)
|
||||
.setInputData(Data.Builder().also {
|
||||
|
@ -59,16 +58,16 @@ open class DataReceiver : DaggerBroadcastReceiver() {
|
|||
}.build()).build()
|
||||
Telephony.Sms.Intents.SMS_RECEIVED_ACTION ->
|
||||
OneTimeWorkRequest.Builder(SmsCommunicatorPlugin.SmsCommunicatorWorker::class.java)
|
||||
.setInputData(dataWorker.storeInputData(bundle, intent)).build()
|
||||
.setInputData(dataWorker.storeInputData(bundle, intent.action)).build()
|
||||
Intents.EVERSENSE_BG ->
|
||||
OneTimeWorkRequest.Builder(EversensePlugin.EversenseWorker::class.java)
|
||||
.setInputData(dataWorker.storeInputData(bundle, intent)).build()
|
||||
.setInputData(dataWorker.storeInputData(bundle, intent.action)).build()
|
||||
Intents.DEXCOM_BG ->
|
||||
OneTimeWorkRequest.Builder(DexcomPlugin.DexcomWorker::class.java)
|
||||
.setInputData(dataWorker.storeInputData(bundle, intent)).build()
|
||||
.setInputData(dataWorker.storeInputData(bundle, intent.action)).build()
|
||||
Intents.AIDEX_NEW_BG_ESTIMATE ->
|
||||
OneTimeWorkRequest.Builder(AidexPlugin.AidexWorker::class.java)
|
||||
.setInputData(dataWorker.storeInputData(bundle, intent)).build()
|
||||
.setInputData(dataWorker.storeInputData(bundle, intent.action)).build()
|
||||
else -> null
|
||||
}?.let { request -> dataWorker.enqueue(request) }
|
||||
}
|
||||
|
|
|
@ -56,10 +56,10 @@ class DataWorker @Inject constructor(
|
|||
return value as JSONObject?
|
||||
}
|
||||
|
||||
fun storeInputData(value: Any, intent: Intent? = null) =
|
||||
fun storeInputData(value: Any, action: String? = null) =
|
||||
Data.Builder()
|
||||
.putLong(STORE_KEY, store(value))
|
||||
.putString(ACTION_KEY, intent?.action).build()
|
||||
.putString(ACTION_KEY, action).build()
|
||||
|
||||
fun enqueue(request: OneTimeWorkRequest) {
|
||||
WorkManager.getInstance(context)
|
||||
|
|
Loading…
Reference in a new issue