From d72f6ecaa36d390d612fbe9e477be1279a00a269 Mon Sep 17 00:00:00 2001 From: vsuryakumar Date: Mon, 30 Jan 2023 13:46:05 +0530 Subject: [PATCH] Removed update button. --- .../testRight/TestRightExpSample.kt | 28 +++++++++++++-- .../layout/fragment_test_right_exp_sample.xml | 36 ++++++++++++------- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightExpSample.kt b/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightExpSample.kt index 2a027b0..d2feece 100644 --- a/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightExpSample.kt +++ b/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightExpSample.kt @@ -9,11 +9,15 @@ import android.view.View import android.view.ViewGroup import android.widget.Button import androidx.core.content.ContextCompat +import androidx.core.view.children import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import com.example.refactoredapp.R +import com.example.refactoredapp.data.DataHolder +import com.example.refactoredapp.data.constant.Constants import com.example.refactoredapp.data.constant.TestRightCommands import com.example.refactoredapp.data.model.PatientData +import com.example.refactoredapp.data.model.TestRightResultType import com.example.refactoredapp.databinding.FragmentTestRightExpSampleBinding import com.example.refactoredapp.presentation.UsbServiceListener @@ -30,7 +34,14 @@ class TestRightExpSample : Fragment() { ): View { // Inflate the layout for this fragment binding = FragmentTestRightExpSampleBinding.inflate(inflater, container, false) - binding.btnUpdateReference.disable() +// if (DataHolder.sampleReadCounter > Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE) { +// binding.btnUpdateReference.enable() +// binding.clInstructions.setAllEnabled(false) +// } else { +// binding.btnUpdateReference.disable() +// binding.clInstructions.setAllEnabled(false) +// } + return binding.root } @@ -42,8 +53,12 @@ class TestRightExpSample : Fragment() { viewModel.progressBar.observe(viewLifecycleOwner) { if (it) { binding.progressBar.visibility = View.VISIBLE + binding.clParent.alpha = 0.5f + binding.btnAcquire.isEnabled = false } else { binding.progressBar.visibility = View.GONE + binding.clParent.alpha = 1f + binding.btnAcquire.isEnabled = true } } @@ -78,7 +93,7 @@ class TestRightExpSample : Fragment() { binding.ddGender.error = getString(R.string.gender_error) return null } - return PatientData(name.toString(), age.toString().toInt(), gender.toString(), null) + return PatientData(name.toString(), age.toString().toInt(), gender.toString(), TestRightResultType.UNDEFINED) } /** @@ -92,6 +107,7 @@ class TestRightExpSample : Fragment() { } private fun sendCmdToRun() { + Log.d(TAG, "sendCmdToRun() called") viewModel.progressBar.postValue(true) val fullReadOutput = StringBuilder() (activity as TestRightActivity).mService.eventDrivenWrite( @@ -125,6 +141,7 @@ class TestRightExpSample : Fragment() { } private fun sendCmdToFetchLightIntensities() { + Log.d(TAG, "sendCmdToFetchLightIntensities() called") viewModel.progressBar.postValue(true) val fullReadOutput = StringBuilder() (activity as TestRightActivity).mService.eventDrivenWrite(TestRightCommands.printAll, @@ -150,7 +167,9 @@ class TestRightExpSample : Fragment() { } private fun showResultsAfterAcquiring() { + viewModel.mapWavelengthToAbsorbance() viewModel.calculateResults() + viewModel.progressBar.postValue(false) // binding.progressBar.visibility = View.GONE parentFragmentManager.beginTransaction().replace(R.id.fl_main, TestRightResults()) @@ -167,4 +186,9 @@ class TestRightExpSample : Fragment() { // background.setColorFilter(Color.BLUE, PorterDuff.Mode.MULTIPLY) isClickable = true } + + fun View.setAllEnabled(enabled: Boolean) { + isEnabled = enabled + if (this is ViewGroup) children.forEach { child -> child.setAllEnabled(enabled) } + } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_test_right_exp_sample.xml b/app/src/main/res/layout/fragment_test_right_exp_sample.xml index b005c97..42e5746 100644 --- a/app/src/main/res/layout/fragment_test_right_exp_sample.xml +++ b/app/src/main/res/layout/fragment_test_right_exp_sample.xml @@ -9,20 +9,28 @@ android:layout_height="match_parent"> -