prevent NPE

This commit is contained in:
Milos Kozak 2021-10-24 00:58:17 +02:00
parent 5e3db95297
commit 22cad1a761

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.activities.fragments package info.nightscout.androidaps.activities.fragments
import android.annotation.SuppressLint
import android.graphics.Paint import android.graphics.Paint
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -84,6 +85,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View = override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
TreatmentsBolusCarbsFragmentBinding.inflate(inflater, container, false).also { _binding = it }.root TreatmentsBolusCarbsFragmentBinding.inflate(inflater, container, false).also { _binding = it }.root
@SuppressLint("CheckResult")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.recyclerview.setHasFixedSize(true) binding.recyclerview.setHasFixedSize(true)
@ -320,7 +322,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() {
init { init {
binding.calculation.setOnClickListener { binding.calculation.setOnClickListener {
val mealLinkLoaded = it.tag as MealLink val mealLinkLoaded = it.tag as MealLink? ?: return@setOnClickListener
mealLinkLoaded.bolusCalculatorResult?.let { bolusCalculatorResult -> mealLinkLoaded.bolusCalculatorResult?.let { bolusCalculatorResult ->
WizardInfoDialog().also { wizardDialog -> WizardInfoDialog().also { wizardDialog ->
wizardDialog.setData(bolusCalculatorResult) wizardDialog.setData(bolusCalculatorResult)