From f86caf044884a8e0b41c8c1b2c0cdfa701c6c16b Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Thu, 16 Nov 2023 07:04:51 +0530 Subject: [PATCH] move if conditions outside apply --- .../presentation/hemocube/HemoCubeFragment.kt | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt index bf6e7bf..9260185 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt @@ -504,22 +504,24 @@ class HemoCubeFragment : Fragment() { this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio) hemoCubeViewModel.messages.postValue(this.classificationResult) this.resultData = deviceLog - if (!isUsingExistingBuffer) { - with(sharedPreferences.edit()) { - putString(Constants.BUFFER_VALUE_1, led1BufferForDevice.toString()) - putString(Constants.BUFFER_VALUE_2, led2BufferForDevice.toString()) - putString(Constants.BUFFER_VALUE_3, led3BufferForDevice.toString()) - putString(Constants.BUFFER_VALUE_4, led4BufferForDevice.toString()) - apply() - } + } + + if (!isUsingExistingBuffer) { + with(sharedPreferences.edit()) { + putString(Constants.BUFFER_VALUE_1, led1BufferForDevice.toString()) + putString(Constants.BUFFER_VALUE_2, led2BufferForDevice.toString()) + putString(Constants.BUFFER_VALUE_3, led3BufferForDevice.toString()) + putString(Constants.BUFFER_VALUE_4, led4BufferForDevice.toString()) + apply() } - if (!validationError) { - activity?.runOnUiThread { - binding.btnSubmit.visibility = View.VISIBLE - binding.btnSubmit.isEnabled = true - binding.btnSubmit.isClickable = true - binding.clParent.setBackgroundColor(Color.parseColor("#edfffd")) - } + } + + if (!validationError) { + activity?.runOnUiThread { + binding.btnSubmit.visibility = View.VISIBLE + binding.btnSubmit.isEnabled = true + binding.btnSubmit.isClickable = true + binding.clParent.setBackgroundColor(Color.parseColor("#edfffd")) } } } catch (e: Exception) {