add popup for sample reading
This commit is contained in:
@@ -4,5 +4,5 @@ enum class HemoCubeCommands(val command: String) {
|
|||||||
startBuffer("B\r"),
|
startBuffer("B\r"),
|
||||||
getBuffer("Q\r"),
|
getBuffer("Q\r"),
|
||||||
startSample("S\r"),
|
startSample("S\r"),
|
||||||
getSample("R\r"),
|
getSample("P\r"),
|
||||||
}
|
}
|
||||||
@@ -185,6 +185,26 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
resultData += fullReadOutput.toString()
|
resultData += fullReadOutput.toString()
|
||||||
DataHolder.hemoCubeTestData?.resultData
|
DataHolder.hemoCubeTestData?.resultData
|
||||||
|
|
||||||
|
if (stringData.contains("#Buffer Completed")) {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
UIUtils.createAlertDialog(requireContext(),
|
||||||
|
"Start Sample",
|
||||||
|
"Do you want to start sample reading",
|
||||||
|
getString(R.string.no),
|
||||||
|
"Yes",
|
||||||
|
object : MyDialogListener {
|
||||||
|
override fun onClickNegativeButton() {}
|
||||||
|
|
||||||
|
override fun onClickPositiveButton() {
|
||||||
|
listenToHemoCube()
|
||||||
|
startSample()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (stringData.contains("#Sample Completed")) {
|
if (stringData.contains("#Sample Completed")) {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.btnSubmit.isEnabled = true
|
binding.btnSubmit.isEnabled = true
|
||||||
@@ -209,7 +229,6 @@ class HemoCubeFragment : Fragment() {
|
|||||||
validString = parseResult(results)
|
validString = parseResult(results)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!validString.isNullOrEmpty()) {
|
if (!validString.isNullOrEmpty()) {
|
||||||
val result = validString.split(" ")
|
val result = validString.split(" ")
|
||||||
if (result.size == 8) {
|
if (result.size == 8) {
|
||||||
@@ -247,41 +266,42 @@ class HemoCubeFragment : Fragment() {
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: merge
|
||||||
|
if (isOnline) {
|
||||||
|
resultRatio?.let { ratio ->
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSubmit.isEnabled = false
|
||||||
|
binding.btnSubmit.isClickable = false
|
||||||
|
}
|
||||||
|
|
||||||
|
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
||||||
|
isOnline, true, kitSerial
|
||||||
|
)
|
||||||
|
}
|
||||||
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
|
// findNavController().navigate(R.id.action_hemocubeFragment_to_homeFragment)
|
||||||
|
} else {
|
||||||
|
resultRatio?.let { ratio ->
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSubmit.isEnabled = false
|
||||||
|
binding.btnSubmit.isClickable = false
|
||||||
|
}
|
||||||
|
|
||||||
|
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
||||||
|
isOnline, true, kitSerial
|
||||||
|
)
|
||||||
|
// findNavController().navigate(R.id.action_hemocubeFragment_to_homeFragment)
|
||||||
|
}
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"Internet not available, Test Data added to Local DB.",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hemoCubeViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
// TODO
|
|
||||||
if (isOnline) {
|
|
||||||
resultRatio?.let { ratio ->
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.btnSubmit.isEnabled = false
|
|
||||||
binding.btnSubmit.isClickable = false
|
|
||||||
}
|
|
||||||
|
|
||||||
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
|
||||||
isOnline, true, kitSerial
|
|
||||||
)
|
|
||||||
}
|
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
|
||||||
findNavController().navigate(R.id.action_hemocubeFragment_to_homeFragment)
|
|
||||||
} else {
|
|
||||||
resultRatio?.let { ratio ->
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.btnSubmit.isEnabled = false
|
|
||||||
binding.btnSubmit.isClickable = false
|
|
||||||
}
|
|
||||||
|
|
||||||
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
|
||||||
isOnline, true, kitSerial
|
|
||||||
)
|
|
||||||
findNavController().navigate(R.id.action_hemocubeFragment_to_homeFragment)
|
|
||||||
}
|
|
||||||
Toast.makeText(
|
|
||||||
requireContext(),
|
|
||||||
"Internet not available, Test Data added to Local DB.",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
|
|
||||||
when (val response = repository.addTestToDatabase(testDetails)) {
|
when (val response = repository.addTestToDatabase(testDetails)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
val kitCount = sharedPreference.getString(Constants.KIT_COUNT, "")?.toInt()
|
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putInt(Constants.KIT_COUNT, kitCount?.plus(1) ?: 0)
|
putInt(Constants.KIT_COUNT, kitCount?.plus(1) ?: 0)
|
||||||
apply()
|
apply()
|
||||||
|
|||||||
Reference in New Issue
Block a user