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() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
aapsLogger.debug(LTag.PUMP, "MedtrumPlugin onStart()")
|
aapsLogger.debug(LTag.PUMP, "MedtrumPlugin onStart()")
|
||||||
|
medtrumPump.loadVarsFromSP()
|
||||||
val intent = Intent(context, MedtrumService::class.java)
|
val intent = Intent(context, MedtrumService::class.java)
|
||||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE)
|
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
|
|
|
@ -279,7 +279,16 @@ class MedtrumPump @Inject constructor(
|
||||||
var desiredHourlyMaxInsulin: Int = 40
|
var desiredHourlyMaxInsulin: Int = 40
|
||||||
var desiredDailyMaxInsulin: Int = 180
|
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
|
// Load stuff from SP
|
||||||
_patchSessionToken = sp.getLong(R.string.key_session_token, 0L)
|
_patchSessionToken = sp.getLong(R.string.key_session_token, 0L)
|
||||||
_lastConnection = sp.getLong(R.string.key_last_connection, 0L)
|
_lastConnection = sp.getLong(R.string.key_last_connection, 0L)
|
||||||
|
@ -304,16 +313,9 @@ class MedtrumPump @Inject constructor(
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
aapsLogger.warn(LTag.PUMP, "Error decoding basal profile from SP: $encodedString")
|
aapsLogger.warn(LTag.PUMP, "Error decoding basal profile from SP: $encodedString")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun pumpType(): PumpType = pumpType(deviceType)
|
loadUserSettingsFromSP()
|
||||||
|
}
|
||||||
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 loadUserSettingsFromSP() {
|
fun loadUserSettingsFromSP() {
|
||||||
desiredPatchExpiration = sp.getBoolean(R.string.key_patch_expiration, false)
|
desiredPatchExpiration = sp.getBoolean(R.string.key_patch_expiration, false)
|
||||||
|
|
|
@ -145,8 +145,6 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
||||||
handleConnectionStateChange(connectionState)
|
handleConnectionStateChange(connectionState)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
medtrumPump.loadUserSettingsFromSP()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
|
Loading…
Reference in a new issue