Merge pull request #2788 from jbr7rr/medtrum-fixes
Medtrum: Move Initializers to onStart()
This commit is contained in:
commit
7bed95f131
|
@ -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,15 +313,8 @@ 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() {
|
||||||
|
|
|
@ -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