prevent NPE

This commit is contained in:
Milos Kozak 2022-06-25 10:17:59 +02:00
parent 0f92e5409d
commit 0774aa46d0

View file

@ -179,7 +179,7 @@ class CarbsDialog : DialogFragmentWithDate() {
setOnValueChangedListener { eventTime: Long ->
run {
val timeOffset = ((eventTime - eventTimeOriginal) / (1000 * 60)).toDouble()
binding.time.value = timeOffset
if (_binding != null) binding.time.value = timeOffset
}
}
@ -250,7 +250,8 @@ class CarbsDialog : DialogFragmentWithDate() {
val hypoSelected = binding.hypoTt.isChecked
if (hypoSelected)
actions.add(
rh.gs(R.string.temptargetshort) + ": " + (DecimalFormatter.to1Decimal(hypoTT) + " " + unitLabel + " (" + rh.gs(R.string.format_mins, hypoTTDuration) + ")").formatColor( context,
rh.gs(R.string.temptargetshort) + ": " + (DecimalFormatter.to1Decimal(hypoTT) + " " + unitLabel + " (" + rh.gs(R.string.format_mins, hypoTTDuration) + ")").formatColor(
context,
rh,
R.attr.tempTargetConfirmation
)
@ -258,7 +259,7 @@ class CarbsDialog : DialogFragmentWithDate() {
val timeOffset = binding.time.value.toInt()
if (useAlarm && carbs > 0 && timeOffset > 0)
actions.add(rh.gs(R.string.alarminxmin, timeOffset).formatColor(context , rh, R.attr.infoColor))
actions.add(rh.gs(R.string.alarminxmin, timeOffset).formatColor(context, rh, R.attr.infoColor))
val duration = binding.duration.value.toInt()
if (duration > 0)
actions.add(rh.gs(R.string.duration) + ": " + duration + rh.gs(R.string.shorthour))
@ -385,7 +386,7 @@ class CarbsDialog : DialogFragmentWithDate() {
override fun onResume() {
super.onResume()
if(!queryingProtection) {
if (!queryingProtection) {
queryingProtection = true
activity?.let { activity ->
val cancelFail = {