From e9f7513c85a8dfd28b5f95fdb6916f46432e9a12 Mon Sep 17 00:00:00 2001 From: mohamedkaif356 Date: Thu, 20 Jul 2023 18:14:12 +0530 Subject: [PATCH] Check negative absorbance --- .../presentation/testRight/TestRightExpSample.kt | 12 ++++++++---- .../presentation/testRight/TestRightViewModel.kt | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightExpSample.kt b/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightExpSample.kt index 000ec30..fac6293 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightExpSample.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightExpSample.kt @@ -8,6 +8,7 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Toast import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import com.example.hpostesting.data.DataHolder @@ -247,10 +248,13 @@ class TestRightExpSample : Fragment() { // viewModel.mapWavelengthToAbsorbance() // viewModel.calculateResults() - viewModel.progressBar.postValue(false) -// binding.progressBar.visibility = View.GONE - parentFragmentManager.beginTransaction().replace(R.id.fl_main, TestRightResults()) - .commit() + if (viewModel.calculationData.absorbanceOne!! < 0 || viewModel.calculationData.absorbanceTwo!! < 0) { + Toast.makeText(requireContext(), " ", Toast.LENGTH_SHORT).show() + viewModel.progressBar.postValue(false) + } else { + parentFragmentManager.beginTransaction().replace(R.id.fl_main, TestRightResults()) + .commit() + } } private fun saveDataLocally() { diff --git a/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightViewModel.kt b/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightViewModel.kt index 4229800..158ae55 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightViewModel.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightViewModel.kt @@ -68,7 +68,7 @@ class TestRightViewModel @Inject constructor( val allUserData = userDao.getAll() - private lateinit var calculationData: TestRightCalculationData + lateinit var calculationData: TestRightCalculationData /* (For exp sample) Contains pixel no. -> Intensity of light falling on that pixel */ val intensitySampleArray = ArrayList()