reversed ordering of Yes & No buttons + Added alert dialog in sample page + Updated text of alert dialog and a button in sample page. (Update based on feedback)
This commit is contained in:
@@ -61,16 +61,16 @@ class TestRightExpReference : Fragment() {
|
||||
requireContext(),
|
||||
getString(R.string.have_you_placed),
|
||||
getString(R.string.please_place),
|
||||
getString(R.string.yes),
|
||||
getString(R.string.no),
|
||||
getString(R.string.yes),
|
||||
object : MyDialogListener {
|
||||
override fun onClickBtnOne() {
|
||||
startTakingReference()
|
||||
}
|
||||
override fun onClickBtnTwo() {
|
||||
override fun onClickNegativeButton() {
|
||||
// Todo: Only for testing
|
||||
// viewModel.progressBar.postValue(true)
|
||||
}
|
||||
override fun onClickPositiveButton() {
|
||||
startTakingReference()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -284,6 +284,7 @@ class TestRightExpReference : Fragment() {
|
||||
}
|
||||
|
||||
private fun moveToSamplePage() {
|
||||
Toast.makeText(requireContext(), "Reference taken successfully.", Toast.LENGTH_SHORT).show()
|
||||
parentFragmentManager.beginTransaction().replace(R.id.fl_main, TestRightExpSample())
|
||||
.commit()
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.children
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.example.hpos.R
|
||||
@@ -18,6 +16,7 @@ import com.example.hpos.data.model.PatientData
|
||||
import com.example.hpos.data.model.TestRightResultType
|
||||
import com.example.hpos.databinding.FragmentTestRightExpSampleBinding
|
||||
import com.example.hpos.presentation.UsbServiceListener
|
||||
import com.example.hpos.presentation.utils.MyDialogListener
|
||||
import com.example.hpos.presentation.utils.UIUtils
|
||||
|
||||
class TestRightExpSample : Fragment() {
|
||||
@@ -53,11 +52,11 @@ class TestRightExpSample : Fragment() {
|
||||
if (it) {
|
||||
binding.progressBar.visibility = View.VISIBLE
|
||||
binding.clParent.alpha = 0.5f
|
||||
binding.btnAcquire.isEnabled = false
|
||||
binding.btnSubmit.isEnabled = false
|
||||
} else {
|
||||
binding.progressBar.visibility = View.GONE
|
||||
binding.clParent.alpha = 1f
|
||||
binding.btnAcquire.isEnabled = true
|
||||
binding.btnSubmit.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,11 +66,23 @@ class TestRightExpSample : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
binding.btnAcquire.setOnClickListener {
|
||||
val details = isValidInput()
|
||||
binding.btnSubmit.setOnClickListener {
|
||||
val details = checkAndReturnPatientDetails()
|
||||
if (details != null) {
|
||||
viewModel.patientDetails = details
|
||||
startAcquiring()
|
||||
|
||||
UIUtils.createAlertDialog(
|
||||
requireContext(),
|
||||
getString(R.string.have_you_placed_sample),
|
||||
getString(R.string.please_place_sample),
|
||||
getString(R.string.no),
|
||||
getString(R.string.yes_and_run),
|
||||
object : MyDialogListener {
|
||||
override fun onClickNegativeButton() {}
|
||||
override fun onClickPositiveButton() {
|
||||
startAcquiring()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
binding.etNameBlock.setOnClickListener { binding.etName.isErrorEnabled = false }
|
||||
@@ -79,7 +90,7 @@ class TestRightExpSample : Fragment() {
|
||||
binding.etGenderBlock.setOnClickListener { binding.ddGender.isErrorEnabled = false }
|
||||
}
|
||||
|
||||
private fun isValidInput(): PatientData? {
|
||||
private fun checkAndReturnPatientDetails(): PatientData? {
|
||||
val name = binding.etName.editText?.text?.trim()
|
||||
if (name.isNullOrEmpty()) {
|
||||
binding.etName.error = getString(R.string.name_error)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.example.hpos.presentation.utils
|
||||
|
||||
interface MyDialogListener {
|
||||
fun onClickBtnOne()
|
||||
fun onClickBtnTwo()
|
||||
fun onClickNegativeButton()
|
||||
fun onClickPositiveButton()
|
||||
}
|
||||
@@ -18,10 +18,10 @@ object UIUtils {
|
||||
.setTitle(title)
|
||||
.setMessage(subtitle)
|
||||
.setNegativeButton(btnOneText) { _, _ ->
|
||||
listener.onClickBtnOne()
|
||||
listener.onClickNegativeButton()
|
||||
}
|
||||
.setPositiveButton(btnTwoText) { _, _ ->
|
||||
listener.onClickBtnTwo()
|
||||
listener.onClickPositiveButton()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user