prevent NPE
This commit is contained in:
parent
81e4d1604b
commit
b793931186
1 changed files with 44 additions and 44 deletions
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.aps.loop
|
||||
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
@ -12,7 +11,11 @@ import info.nightscout.androidaps.interfaces.Constraint
|
|||
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopSetLastRunGui
|
||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import info.nightscout.androidaps.utils.plusAssign
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.loop_fragment.*
|
||||
|
@ -52,10 +55,8 @@ class LoopFragment : Fragment() {
|
|||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
clearGUI()
|
||||
loop_lastrun.text = it.text
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
loop_lastrun?.text = it.text
|
||||
}, { FabricPrivacy.logException(it) })
|
||||
|
||||
updateGUI()
|
||||
SP.putBoolean(R.string.key_objectiveuseloop, true)
|
||||
|
@ -71,16 +72,16 @@ class LoopFragment : Fragment() {
|
|||
fun updateGUI() {
|
||||
if (loop_request == null) return
|
||||
LoopPlugin.lastRun?.let {
|
||||
loop_request.text = it.request?.toSpanned() ?: ""
|
||||
loop_constraintsprocessed.text = it.constraintsProcessed?.toSpanned() ?: ""
|
||||
loop_source.text = it.source ?: ""
|
||||
loop_lastrun.text = it.lastAPSRun?.let { lastRun -> DateUtil.dateAndTimeString(lastRun.time) }
|
||||
loop_request?.text = it.request?.toSpanned() ?: ""
|
||||
loop_constraintsprocessed?.text = it.constraintsProcessed?.toSpanned() ?: ""
|
||||
loop_source?.text = it.source ?: ""
|
||||
loop_lastrun?.text = it.lastAPSRun?.let { lastRun -> DateUtil.dateAndTimeString(lastRun.time) }
|
||||
?: ""
|
||||
loop_lastenact.text = it.lastAPSRun?.let { lastEnact -> DateUtil.dateAndTimeString(lastEnact.time) }
|
||||
loop_lastenact?.text = it.lastAPSRun?.let { lastEnact -> DateUtil.dateAndTimeString(lastEnact.time) }
|
||||
?: ""
|
||||
loop_tbrsetbypump.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml()) }
|
||||
loop_tbrsetbypump?.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml()) }
|
||||
?: ""
|
||||
loop_smbsetbypump.text = it.smbSetByPump?.let { smbSetByPump -> HtmlHelper.fromHtml(smbSetByPump.toHtml()) }
|
||||
loop_smbsetbypump?.text = it.smbSetByPump?.let { smbSetByPump -> HtmlHelper.fromHtml(smbSetByPump.toHtml()) }
|
||||
?: ""
|
||||
|
||||
val constraints =
|
||||
|
@ -90,20 +91,19 @@ class LoopFragment : Fragment() {
|
|||
constraintsProcessed.smbConstraint?.let { smbConstraint -> allConstraints.copyReasons(smbConstraint) }
|
||||
allConstraints.mostLimitedReasons
|
||||
} ?: ""
|
||||
loop_constraints.text = constraints
|
||||
loop_constraints?.text = constraints
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun clearGUI() {
|
||||
if (loop_request == null) return
|
||||
loop_request.text = ""
|
||||
loop_constraints.text = ""
|
||||
loop_constraintsprocessed.text = ""
|
||||
loop_source.text = ""
|
||||
loop_lastrun.text = ""
|
||||
loop_lastenact.text = ""
|
||||
loop_tbrsetbypump.text = ""
|
||||
loop_smbsetbypump.text = ""
|
||||
loop_request?.text = ""
|
||||
loop_constraints?.text = ""
|
||||
loop_constraintsprocessed?.text = ""
|
||||
loop_source?.text = ""
|
||||
loop_lastrun?.text = ""
|
||||
loop_lastenact?.text = ""
|
||||
loop_tbrsetbypump?.text = ""
|
||||
loop_smbsetbypump?.text = ""
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue