Merge pull request #2788 from jbr7rr/medtrum-fixes
Medtrum: Move Initializers to onStart()
This commit is contained in:
commit
7bed95f131
3 changed files with 13 additions and 12 deletions
|
@ -95,6 +95,7 @@ import kotlin.math.abs
|
|||
override fun onStart() {
|
||||
super.onStart()
|
||||
aapsLogger.debug(LTag.PUMP, "MedtrumPlugin onStart()")
|
||||
medtrumPump.loadVarsFromSP()
|
||||
val intent = Intent(context, MedtrumService::class.java)
|
||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE)
|
||||
disposable += rxBus
|
||||
|
|
|
@ -279,7 +279,16 @@ class MedtrumPump @Inject constructor(
|
|||
var desiredHourlyMaxInsulin: Int = 40
|
||||
var desiredDailyMaxInsulin: Int = 180
|
||||
|
||||
init {
|
||||
fun pumpType(): PumpType = pumpType(deviceType)
|
||||
|
||||
fun pumpType(type: Int): PumpType =
|
||||
when (type) {
|
||||
MedtrumSnUtil.MD_0201, MedtrumSnUtil.MD_8201 -> PumpType.MEDTRUM_NANO
|
||||
MedtrumSnUtil.MD_8301 -> PumpType.MEDTRUM_300U
|
||||
else -> PumpType.MEDTRUM_UNTESTED
|
||||
}
|
||||
|
||||
fun loadVarsFromSP() {
|
||||
// Load stuff from SP
|
||||
_patchSessionToken = sp.getLong(R.string.key_session_token, 0L)
|
||||
_lastConnection = sp.getLong(R.string.key_last_connection, 0L)
|
||||
|
@ -304,16 +313,9 @@ class MedtrumPump @Inject constructor(
|
|||
} catch (e: Exception) {
|
||||
aapsLogger.warn(LTag.PUMP, "Error decoding basal profile from SP: $encodedString")
|
||||
}
|
||||
}
|
||||
|
||||
fun pumpType(): PumpType = pumpType(deviceType)
|
||||
|
||||
fun pumpType(type: Int): PumpType =
|
||||
when (type) {
|
||||
MedtrumSnUtil.MD_0201, MedtrumSnUtil.MD_8201 -> PumpType.MEDTRUM_NANO
|
||||
MedtrumSnUtil.MD_8301 -> PumpType.MEDTRUM_300U
|
||||
else -> PumpType.MEDTRUM_UNTESTED
|
||||
}
|
||||
loadUserSettingsFromSP()
|
||||
}
|
||||
|
||||
fun loadUserSettingsFromSP() {
|
||||
desiredPatchExpiration = sp.getBoolean(R.string.key_patch_expiration, false)
|
||||
|
|
|
@ -145,8 +145,6 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
|||
handleConnectionStateChange(connectionState)
|
||||
}
|
||||
}
|
||||
|
||||
medtrumPump.loadUserSettingsFromSP()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
Loading…
Reference in a new issue