prevent NPE

This commit is contained in:
Milos Kozak 2022-04-11 11:49:28 +02:00
parent 7f91a17d00
commit fa6b0a222c
2 changed files with 13 additions and 1 deletions

View file

@ -753,6 +753,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
fun updateBg() { fun updateBg() {
_binding ?: return
val units = profileFunction.getUnits() val units = profileFunction.getUnits()
binding.infoLayout.bg.text = overviewData.lastBg?.valueToUnitsString(units) binding.infoLayout.bg.text = overviewData.lastBg?.valueToUnitsString(units)
?: rh.gs(R.string.notavailable) ?: rh.gs(R.string.notavailable)
@ -802,6 +803,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
} }
fun updateProfile() { fun updateProfile() {
_binding ?: return
val profileBackgroundColor = val profileBackgroundColor =
profileFunction.getProfile()?.let { profileFunction.getProfile()?.let {
if (it is ProfileSealed.EPS) { if (it is ProfileSealed.EPS) {
@ -834,6 +836,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
} }
private fun updateTemporaryBasal() { private fun updateTemporaryBasal() {
_binding ?: return
binding.infoLayout.baseBasal.text = overviewData.temporaryBasalText(iobCobCalculator) binding.infoLayout.baseBasal.text = overviewData.temporaryBasalText(iobCobCalculator)
binding.infoLayout.baseBasal.setTextColor(overviewData.temporaryBasalColor(context, iobCobCalculator)) binding.infoLayout.baseBasal.setTextColor(overviewData.temporaryBasalColor(context, iobCobCalculator))
binding.infoLayout.baseBasalIcon.setImageResource(overviewData.temporaryBasalIcon(iobCobCalculator)) binding.infoLayout.baseBasalIcon.setImageResource(overviewData.temporaryBasalIcon(iobCobCalculator))
@ -843,6 +846,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
} }
private fun updateExtendedBolus() { private fun updateExtendedBolus() {
_binding ?: return
val pump = activePlugin.activePump val pump = activePlugin.activePump
binding.infoLayout.extendedBolus.text = overviewData.extendedBolusText(iobCobCalculator) binding.infoLayout.extendedBolus.text = overviewData.extendedBolusText(iobCobCalculator)
binding.infoLayout.extendedLayout.setOnClickListener { binding.infoLayout.extendedLayout.setOnClickListener {
@ -852,6 +856,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
} }
fun updateTime() { fun updateTime() {
_binding ?: return
binding.infoLayout.time.text = dateUtil.timeString(dateUtil.now()) binding.infoLayout.time.text = dateUtil.timeString(dateUtil.now())
// Status lights // Status lights
val pump = activePlugin.activePump val pump = activePlugin.activePump
@ -883,6 +888,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
} }
fun updateIobCob() { fun updateIobCob() {
_binding ?: return
binding.infoLayout.iob.text = overviewData.iobText(iobCobCalculator) binding.infoLayout.iob.text = overviewData.iobText(iobCobCalculator)
binding.infoLayout.iobLayout.setOnClickListener { binding.infoLayout.iobLayout.setOnClickListener {
activity?.let { OKDialog.show(it, rh.gs(R.string.iob), overviewData.iobDialogText(iobCobCalculator)) } activity?.let { OKDialog.show(it, rh.gs(R.string.iob), overviewData.iobDialogText(iobCobCalculator)) }
@ -910,6 +916,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
fun updateTemporaryTarget() { fun updateTemporaryTarget() {
_binding ?: return
val units = profileFunction.getUnits() val units = profileFunction.getUnits()
val tempTarget = overviewData.temporaryTarget val tempTarget = overviewData.temporaryTarget
if (tempTarget != null) { if (tempTarget != null) {
@ -936,6 +943,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
} }
private fun updateGraph() { private fun updateGraph() {
_binding ?: return
val pump = activePlugin.activePump val pump = activePlugin.activePump
val graphData = GraphData(injector, binding.graphsLayout.bgGraph, overviewData) val graphData = GraphData(injector, binding.graphsLayout.bgGraph, overviewData)
val menuChartSettings = overviewMenus.setting val menuChartSettings = overviewMenus.setting
@ -1016,11 +1024,13 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
} }
private fun updateCalcProgress() { private fun updateCalcProgress() {
_binding ?: return
binding.progressBar.progress = overviewData.calcProgressPct binding.progressBar.progress = overviewData.calcProgressPct
binding.progressBar.visibility = (overviewData.calcProgressPct != 100).toVisibility() binding.progressBar.visibility = (overviewData.calcProgressPct != 100).toVisibility()
} }
private fun updateSensitivity() { private fun updateSensitivity() {
_binding ?: return
if (sp.getBoolean(R.string.key_openapsama_useautosens, false) && constraintChecker.isAutosensModeEnabled().value()) { if (sp.getBoolean(R.string.key_openapsama_useautosens, false) && constraintChecker.isAutosensModeEnabled().value()) {
binding.infoLayout.sensitivityIcon.setImageResource(R.drawable.ic_swap_vert_black_48dp_green) binding.infoLayout.sensitivityIcon.setImageResource(R.drawable.ic_swap_vert_black_48dp_green)
} else { } else {
@ -1034,12 +1044,14 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
} }
private fun updatePumpStatus() { private fun updatePumpStatus() {
_binding ?: return
val status = overviewData.pumpStatus val status = overviewData.pumpStatus
binding.pumpStatus.text = status binding.pumpStatus.text = status
binding.pumpStatusLayout.visibility = (status != "").toVisibility() binding.pumpStatusLayout.visibility = (status != "").toVisibility()
} }
private fun updateNotification() { private fun updateNotification() {
_binding ?: return
binding.notifications.let { notificationStore.updateNotifications(it) } binding.notifications.let { notificationStore.updateNotifications(it) }
} }
} }

View file

@ -42,7 +42,7 @@ buildscript {
maven { url "https://plugins.gradle.org/m2/" } // jacoco 0.2 maven { url "https://plugins.gradle.org/m2/" } // jacoco 0.2
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.1.2' classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.google.gms:google-services:4.3.10' classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'