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.view.ViewGroup
import android.widget.Button import android.widget.Button
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.children
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import com.example.refactoredapp.R 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.constant.TestRightCommands
import com.example.refactoredapp.data.model.PatientData import com.example.refactoredapp.data.model.PatientData
import com.example.refactoredapp.data.model.TestRightResultType
import com.example.refactoredapp.databinding.FragmentTestRightExpSampleBinding import com.example.refactoredapp.databinding.FragmentTestRightExpSampleBinding
import com.example.refactoredapp.presentation.UsbServiceListener import com.example.refactoredapp.presentation.UsbServiceListener
@@ -30,7 +34,14 @@ class TestRightExpSample : Fragment() {
): View { ): View {
// Inflate the layout for this fragment // Inflate the layout for this fragment
binding = FragmentTestRightExpSampleBinding.inflate(inflater, container, false) 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 return binding.root
} }
@@ -42,8 +53,12 @@ class TestRightExpSample : Fragment() {
viewModel.progressBar.observe(viewLifecycleOwner) { viewModel.progressBar.observe(viewLifecycleOwner) {
if (it) { if (it) {
binding.progressBar.visibility = View.VISIBLE binding.progressBar.visibility = View.VISIBLE
binding.clParent.alpha = 0.5f
binding.btnAcquire.isEnabled = false
} else { } else {
binding.progressBar.visibility = View.GONE 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) binding.ddGender.error = getString(R.string.gender_error)
return null 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() { private fun sendCmdToRun() {
Log.d(TAG, "sendCmdToRun() called")
viewModel.progressBar.postValue(true) viewModel.progressBar.postValue(true)
val fullReadOutput = StringBuilder() val fullReadOutput = StringBuilder()
(activity as TestRightActivity).mService.eventDrivenWrite( (activity as TestRightActivity).mService.eventDrivenWrite(
@@ -125,6 +141,7 @@ class TestRightExpSample : Fragment() {
} }
private fun sendCmdToFetchLightIntensities() { private fun sendCmdToFetchLightIntensities() {
Log.d(TAG, "sendCmdToFetchLightIntensities() called")
viewModel.progressBar.postValue(true) viewModel.progressBar.postValue(true)
val fullReadOutput = StringBuilder() val fullReadOutput = StringBuilder()
(activity as TestRightActivity).mService.eventDrivenWrite(TestRightCommands.printAll, (activity as TestRightActivity).mService.eventDrivenWrite(TestRightCommands.printAll,
@@ -150,7 +167,9 @@ class TestRightExpSample : Fragment() {
} }
private fun showResultsAfterAcquiring() { private fun showResultsAfterAcquiring() {
viewModel.mapWavelengthToAbsorbance()
viewModel.calculateResults() viewModel.calculateResults()
viewModel.progressBar.postValue(false) viewModel.progressBar.postValue(false)
// binding.progressBar.visibility = View.GONE // binding.progressBar.visibility = View.GONE
parentFragmentManager.beginTransaction().replace(R.id.fl_main, TestRightResults()) parentFragmentManager.beginTransaction().replace(R.id.fl_main, TestRightResults())
@@ -167,4 +186,9 @@ class TestRightExpSample : Fragment() {
// background.setColorFilter(Color.BLUE, PorterDuff.Mode.MULTIPLY) // background.setColorFilter(Color.BLUE, PorterDuff.Mode.MULTIPLY)
isClickable = true isClickable = true
} }
fun View.setAllEnabled(enabled: Boolean) {
isEnabled = enabled
if (this is ViewGroup) children.forEach { child -> child.setAllEnabled(enabled) }
}
} }

View File

@@ -9,20 +9,28 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_parent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<Button <!-- <Button-->
android:id="@+id/btn_update_reference" <!-- android:id="@+id/btn_update_reference"-->
android:layout_width="216dp" <!-- android:layout_width="216dp"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:layout_marginHorizontal="24dp" <!-- android:layout_marginHorizontal="24dp"-->
android:layout_marginTop="24dp" <!-- android:layout_marginTop="24dp"-->
android:clickable="false" <!-- android:clickable="false"-->
android:text="@string/update_reference" <!-- android:text="@string/update_reference"-->
android:textColor="@color/white" <!-- android:textColor="@color/white"-->
app:layout_constraintStart_toStartOf="parent" <!-- app:layout_constraintStart_toStartOf="parent"-->
app:layout_constraintTop_toTopOf="parent" /> <!-- app:layout_constraintTop_toTopOf="parent" />-->
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
<!-- android:id="@+id/cl_instructions"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@id/btn_update_reference">-->
<TextView <TextView
android:id="@+id/tv_title" android:id="@+id/tv_title"
@@ -33,7 +41,7 @@
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:text="@string/Instructions" android:text="@string/Instructions"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn_update_reference" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/tv_subtitle1" android:id="@+id/tv_subtitle1"
@@ -207,15 +215,17 @@
<!-- app:layout_constraintTop_toBottomOf="@id/btn_set_reference"--> <!-- app:layout_constraintTop_toBottomOf="@id/btn_set_reference"-->
<!-- app:layout_constraintStart_toStartOf="parent" />--> <!-- app:layout_constraintStart_toStartOf="parent" />-->
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
<ProgressBar <ProgressBar
android:id="@+id/progressBar" android:id="@+id/progressBar"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:elevation="12dp"
android:indeterminate="true" android:indeterminate="true"
android:indeterminateDrawable="@drawable/progressbar_drawable" android:indeterminateDrawable="@drawable/progressbar_drawable"
android:visibility="gone" android:visibility="gone"
android:elevation="12dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"