prevent NPE
This commit is contained in:
parent
8ff9985b6e
commit
561ba72bf0
|
@ -58,7 +58,7 @@ class CalibrationDialog : DialogFragmentWithDate() {
|
||||||
val units = profileFunction.getUnits()
|
val units = profileFunction.getUnits()
|
||||||
val unitLabel = if (units == Constants.MMOL) resourceHelper.gs(R.string.mmol) else resourceHelper.gs(R.string.mgdl)
|
val unitLabel = if (units == Constants.MMOL) resourceHelper.gs(R.string.mmol) else resourceHelper.gs(R.string.mgdl)
|
||||||
val actions: LinkedList<String?> = LinkedList()
|
val actions: LinkedList<String?> = LinkedList()
|
||||||
val bg = overview_calibration_bg.value
|
val bg = overview_calibration_bg?.value ?: return false
|
||||||
actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, bg) + " " + unitLabel)
|
actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, bg) + " " + unitLabel)
|
||||||
if (bg > 0) {
|
if (bg > 0) {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
|
|
|
@ -150,7 +150,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
val carbs = overview_carbs_carbs.value.toInt()
|
val carbs = overview_carbs_carbs?.value?.toInt() ?: return false
|
||||||
val carbsAfterConstraints = constraintChecker.applyCarbsConstraints(Constraint(carbs)).value()
|
val carbsAfterConstraints = constraintChecker.applyCarbsConstraints(Constraint(carbs)).value()
|
||||||
val units = profileFunction.getUnits()
|
val units = profileFunction.getUnits()
|
||||||
val activityTTDuration = defaultValueHelper.determineActivityTTDuration()
|
val activityTTDuration = defaultValueHelper.determineActivityTTDuration()
|
||||||
|
|
|
@ -62,7 +62,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
val insulin = SafeParse.stringToDouble(actions_extendedbolus_insulin.text)
|
val insulin = SafeParse.stringToDouble(actions_extendedbolus_insulin?.text ?: return false)
|
||||||
val durationInMinutes = actions_extendedbolus_duration.value.toInt()
|
val durationInMinutes = actions_extendedbolus_duration.value.toInt()
|
||||||
val actions: LinkedList<String> = LinkedList()
|
val actions: LinkedList<String> = LinkedList()
|
||||||
val insulinAfterConstraint = constraintChecker.applyExtendedBolusConstraints(Constraint(insulin)).value()
|
val insulinAfterConstraint = constraintChecker.applyExtendedBolusConstraints(Constraint(insulin)).value()
|
||||||
|
|
|
@ -85,7 +85,7 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
val insulin = SafeParse.stringToDouble(fill_insulinamount.text)
|
val insulin = SafeParse.stringToDouble(fill_insulinamount?.text ?: return false)
|
||||||
val actions: LinkedList<String?> = LinkedList()
|
val actions: LinkedList<String?> = LinkedList()
|
||||||
|
|
||||||
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(insulin)).value()
|
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(insulin)).value()
|
||||||
|
|
|
@ -129,7 +129,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
val pumpDescription = activePlugin.activePump.pumpDescription
|
val pumpDescription = activePlugin.activePump.pumpDescription
|
||||||
val insulin = SafeParse.stringToDouble(overview_insulin_amount.text)
|
val insulin = SafeParse.stringToDouble(overview_insulin_amount?.text ?: return false)
|
||||||
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(insulin)).value()
|
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(insulin)).value()
|
||||||
val actions: LinkedList<String?> = LinkedList()
|
val actions: LinkedList<String?> = LinkedList()
|
||||||
val units = profileFunction.getUnits()
|
val units = profileFunction.getUnits()
|
||||||
|
|
|
@ -91,7 +91,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
||||||
?: return false
|
?: return false
|
||||||
|
|
||||||
val actions: LinkedList<String> = LinkedList()
|
val actions: LinkedList<String> = LinkedList()
|
||||||
val duration = overview_profileswitch_duration.value.toInt()
|
val duration = overview_profileswitch_duration?.value?.toInt() ?: return false
|
||||||
if (duration > 0)
|
if (duration > 0)
|
||||||
actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, duration))
|
actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, duration))
|
||||||
val profile = overview_profileswitch_profile.selectedItem.toString()
|
val profile = overview_profileswitch_profile.selectedItem.toString()
|
||||||
|
|
|
@ -84,7 +84,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
var percent = 0
|
var percent = 0
|
||||||
var absolute = 0.0
|
var absolute = 0.0
|
||||||
val durationInMinutes = actions_tempbasal_duration.value.toInt()
|
val durationInMinutes = actions_tempbasal_duration?.value?.toInt() ?: return false
|
||||||
val profile = profileFunction.getProfile() ?: return false
|
val profile = profileFunction.getProfile() ?: return false
|
||||||
val actions: LinkedList<String> = LinkedList()
|
val actions: LinkedList<String> = LinkedList()
|
||||||
if (isPercentPump) {
|
if (isPercentPump) {
|
||||||
|
|
|
@ -116,7 +116,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
val actions: LinkedList<String> = LinkedList()
|
val actions: LinkedList<String> = LinkedList()
|
||||||
val reason = overview_temptarget_reason.selectedItem.toString()
|
val reason = overview_temptarget_reason?.selectedItem?.toString() ?: return false
|
||||||
val unitResId = if (profileFunction.getUnits() == Constants.MGDL) R.string.mgdl else R.string.mmol
|
val unitResId = if (profileFunction.getUnits() == Constants.MGDL) R.string.mgdl else R.string.mmol
|
||||||
val target = overview_temptarget_temptarget.value
|
val target = overview_temptarget_temptarget.value
|
||||||
val duration = overview_temptarget_duration.value.toInt()
|
val duration = overview_temptarget_duration.value.toInt()
|
||||||
|
|
|
@ -94,7 +94,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
val pumpDescription = activePlugin.activePump.pumpDescription
|
val pumpDescription = activePlugin.activePump.pumpDescription
|
||||||
val insulin = SafeParse.stringToDouble(overview_treatment_insulin.text)
|
val insulin = SafeParse.stringToDouble(overview_treatment_insulin?.text ?: return false)
|
||||||
val carbs = SafeParse.stringToInt(overview_treatment_carbs.text)
|
val carbs = SafeParse.stringToInt(overview_treatment_carbs.text)
|
||||||
val recordOnlyChecked = overview_treatment_record_only.isChecked
|
val recordOnlyChecked = overview_treatment_record_only.isChecked
|
||||||
val actions: LinkedList<String?> = LinkedList()
|
val actions: LinkedList<String?> = LinkedList()
|
||||||
|
|
|
@ -113,7 +113,7 @@ class EditEventDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
// check for title
|
// check for title
|
||||||
val title = automation_inputEventTitle.text.toString()
|
val title = automation_inputEventTitle?.text?.toString() ?: return false
|
||||||
if (title.isEmpty()) {
|
if (title.isEmpty()) {
|
||||||
ToastUtils.showToastInUiThread(context, R.string.automation_missing_task_name)
|
ToastUtils.showToastInUiThread(context, R.string.automation_missing_task_name)
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in a new issue