AndroidAPS/app/src/main/java/info/nightscout/androidaps/receivers/TimeDateOrTZChangeReceiver.kt

26 lines
1 KiB
Kotlin
Raw Normal View History

2020-03-16 21:40:29 +01:00
package info.nightscout.androidaps.receivers
import android.content.Context
import android.content.Intent
2020-03-18 00:22:21 +01:00
import dagger.android.DaggerBroadcastReceiver
2020-03-16 21:40:29 +01:00
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.PumpInterface
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import javax.inject.Inject
2020-03-18 00:22:21 +01:00
class TimeDateOrTZChangeReceiver : DaggerBroadcastReceiver() {
2020-03-16 21:40:29 +01:00
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var activePlugin: ActivePluginProvider
override fun onReceive(context: Context, intent: Intent) {
2020-03-18 00:22:21 +01:00
super.onReceive(context, intent)
2020-03-16 21:40:29 +01:00
val action = intent.action
2020-03-31 09:48:46 +02:00
val activePump: PumpInterface = activePlugin.activePump
2020-03-16 21:40:29 +01:00
aapsLogger.debug(LTag.PUMP, "Date, Time and/or TimeZone changed.")
if (action != null) {
aapsLogger.debug(LTag.PUMP, "Date, Time and/or TimeZone changed. Notifying pump driver.")
activePump.timeDateOrTimeZoneChanged()
}
}
}