Added placebuffer and sample buttons for the new feature

This commit is contained in:
smileomi18@gmail.com
2023-09-15 17:03:03 +05:30
parent 1d542f5562
commit f019e1897d
4 changed files with 76 additions and 20 deletions

View File

@@ -91,7 +91,8 @@ class HomeFragment : Fragment() {
}
}
private fun loadUserData() {
val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false).orderBy("createdAt", Query.Direction.DESCENDING)
// val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false).orderBy("createdAt", Query.Direction.DESCENDING)
val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false)
query.get().addOnSuccessListener {
if (it.documents.isEmpty()) {
binding.pendingTest.visibility = View.VISIBLE

View File

@@ -57,7 +57,7 @@ class HemoCubeFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
initViews()
observeViewModel()
checkAndStartProcess()
// checkAndStartProcess()
}
private fun initViews() {
@@ -78,6 +78,17 @@ class HemoCubeFragment : Fragment() {
binding.btnSubmit.isEnabled = false
binding.btnSubmit.isClickable = false
binding.btnSamplestart.setOnClickListener {
startSampleProcess()
it.visibility = View.GONE
}
binding.btnPlacebuffer.setOnClickListener {
checkAndStartProcess()
it.visibility = View.GONE
}
binding.btnKit.setOnClickListener {
if (isTestOngoing) {
val title = "WARNING"
@@ -155,7 +166,7 @@ class HemoCubeFragment : Fragment() {
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
currentDeviceData = it
showToast(calculateRatio(0.17).toString())
// showToast(calculateRatio(0.17).toString())
}
@@ -169,12 +180,12 @@ class HemoCubeFragment : Fragment() {
}
private fun checkAndStartProcess() {
if (isBufferValueAvailable()) {
showBufferAlertDialog()
} else {
listenToHemoCube()
startBufferProcess()
}
// if (isBufferValueAvailable()) {
// showBufferAlertDialog()
// } else {
listenToHemoCube()
startBufferProcess()
// }
}
private fun isBufferValueAvailable(): Boolean {
@@ -249,7 +260,12 @@ class HemoCubeFragment : Fragment() {
when {
stringData.contains("ERROR 500") -> showError500Dialog()
stringData.contains("ERROR 501") -> showError501Dialog()
stringData.contains("#Buffer Completed") -> showStartSampleDialog()
stringData.contains("#Buffer Completed") ->
activity?.runOnUiThread {
binding.btnSamplestart.visibility = View.VISIBLE
binding.btnSamplestart.isClickable = true
}
stringData.contains("#Sample Completed") -> {
activity?.runOnUiThread {
binding.btnSubmit.isEnabled = true
@@ -320,7 +336,7 @@ class HemoCubeFragment : Fragment() {
override fun onClickNegativeButton() {}
override fun onClickPositiveButton() {
startSampleProcess()
}
})
}
@@ -366,7 +382,7 @@ class HemoCubeFragment : Fragment() {
this.led1Average = led1Average
this.led2Average = led2Average
this.deviceRatio = deviceRatio
this.calculatedRatio = calculateRatio(deviceRatio)
// this.calculatedRatio = calculateRatio(deviceRatio)
this.resultData = fullReadOutput
if (!isBufferValueAvailable()) {
with(sharedPreferences.edit()) {
@@ -382,7 +398,11 @@ class HemoCubeFragment : Fragment() {
}
} catch (_: Exception) {
Toast.makeText( requireContext(), "Error while processing device data", Toast.LENGTH_SHORT).show()
Toast.makeText(
requireContext(),
"Error while processing device data",
Toast.LENGTH_SHORT
).show()
}
}
@@ -430,11 +450,11 @@ class HemoCubeFragment : Fragment() {
})
}
private fun calculateRatio(ratio: Double): Double {
val coefficient1 = currentDeviceData?.coefficients?.get(0) ?: 0.0
val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 0.0
return coefficient1 * ratio + coefficient2
}
// private fun calculateRatio(ratio: Double): Double {
// val coefficient1 = currentDeviceData?.coefficients?.get(0) ?: 0.0
// val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 0.0
// return coefficient1 * ratio + coefficient2
// }
private fun parseResult(frames: List<String>): String {
val lines = mutableListOf<String>()

View File

@@ -58,6 +58,40 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_subtitle3" />
<Button
android:visibility="gone"
android:id="@+id/btn_samplestart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="24dp"
android:clickable="false"
android:text="@string/Start_Sample"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/til_blood_group" />
<Button
android:id="@+id/btn_placebuffer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="24dp"
android:clickable="false"
android:text="@string/place_buffer"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
<Button
android:id="@+id/btn_submit"
android:layout_width="wrap_content"
@@ -69,8 +103,7 @@
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/til_blood_group" />
app:layout_constraintTop_toBottomOf="@id/btn_samplestart" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_blood_group"

View File

@@ -112,6 +112,8 @@
<string name="sickle_cert">Sickle Cert</string>
<string name="sickle_find">Sickle Find</string>
<string name="submit">Submit</string>
<string name="place_buffer">Start Buffer</string>
<string name="Start_Sample">Start Sample</string>
<string name="new_kit">New Kit</string>
<string name="new_buffer">New Buffer</string>
<string name="name_error_2">Invalid character, Allowed characters are Letters, Numbers and ( ) _ - , . only</string>