From 22cad1a761b1955a628355d9006ceca34036b99e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 24 Oct 2021 00:58:17 +0200 Subject: [PATCH] prevent NPE --- .../activities/fragments/TreatmentsBolusCarbsFragment.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsBolusCarbsFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsBolusCarbsFragment.kt index e73dde72e6..e8c653ba33 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsBolusCarbsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsBolusCarbsFragment.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.activities.fragments +import android.annotation.SuppressLint import android.graphics.Paint import android.os.Bundle import android.view.LayoutInflater @@ -84,6 +85,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View = TreatmentsBolusCarbsFragmentBinding.inflate(inflater, container, false).also { _binding = it }.root + @SuppressLint("CheckResult") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding.recyclerview.setHasFixedSize(true) @@ -320,7 +322,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { init { binding.calculation.setOnClickListener { - val mealLinkLoaded = it.tag as MealLink + val mealLinkLoaded = it.tag as MealLink? ?: return@setOnClickListener mealLinkLoaded.bolusCalculatorResult?.let { bolusCalculatorResult -> WizardInfoDialog().also { wizardDialog -> wizardDialog.setData(bolusCalculatorResult)