Removed update button.

This commit is contained in:
vsuryakumar
2023-01-30 13:46:05 +05:30
parent 5e2d2ff079
commit d72f6ecaa3
2 changed files with 49 additions and 15 deletions

View File

@@ -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) }
}
}