refactor
This commit is contained in:
@@ -65,88 +65,26 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
binding.btnSubmit.setOnClickListener {
|
binding.btnSubmit.setOnClickListener {
|
||||||
// val bloodGroupText = binding.etBloodGroup.text.toString()
|
activity?.runOnUiThread {
|
||||||
// if (bloodGroupText.isEmpty()) {
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
// binding.etBloodGroup.error = "Please enter your blood group"
|
}
|
||||||
// } else {
|
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
||||||
activity?.runOnUiThread {
|
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, "")
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
)
|
||||||
}
|
|
||||||
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
|
||||||
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, "")
|
|
||||||
)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
if (isTestOngoing) {
|
if (isTestOngoing) {
|
||||||
// binding.btnKit.visibility = View.GONE
|
// binding.btnKit.visibility = View.GONE
|
||||||
// binding.btnKit.isEnabled = false
|
// binding.btnKit.isEnabled = false
|
||||||
// binding.btnKit.isClickable = false
|
// binding.btnKit.isClickable = false
|
||||||
|
|
||||||
}
|
}
|
||||||
binding.btnSubmit.isEnabled = false
|
binding.btnSubmit.isEnabled = false
|
||||||
binding.btnSubmit.isClickable = false
|
binding.btnSubmit.isClickable = false
|
||||||
|
|
||||||
|
|
||||||
binding.tvName.text = "Name: ${testDetails?.name}\n ID: ${testDetails?._id}"
|
binding.tvName.text = "Name: ${testDetails?.name}\n ID: ${testDetails?._id}"
|
||||||
Log.e("nametext",binding.tvName.text.toString())
|
Log.e("nametext", binding.tvName.text.toString())
|
||||||
|
|
||||||
// binding.btnKit.setOnClickListener {
|
|
||||||
// if (isTestOngoing) {
|
|
||||||
// val title = "WARNING"
|
|
||||||
// val message = "There is a on going test, do you want to stop it"
|
|
||||||
// val negativeText = getString(R.string.no)
|
|
||||||
// val positiveText = "Yes"
|
|
||||||
//
|
|
||||||
// UIUtils.createAlertDialog(requireContext(),
|
|
||||||
// title,
|
|
||||||
// message,
|
|
||||||
// negativeText,
|
|
||||||
// positiveText,
|
|
||||||
// object : MyDialogListener {
|
|
||||||
// override fun onClickNegativeButton() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onClickPositiveButton() {
|
|
||||||
// resetKitCount()
|
|
||||||
// val intent = Intent(context, KitScanActivity::class.java)
|
|
||||||
// startActivity(intent)
|
|
||||||
// (activity as HemocubeActivity).finish()
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// } else {
|
|
||||||
// resetKitCount()
|
|
||||||
// val intent = Intent(context, KitScanActivity::class.java)
|
|
||||||
// startActivity(intent)
|
|
||||||
// (activity as HemocubeActivity).finish()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private suspend fun checkBloodGroup() {
|
|
||||||
// binding.apply {
|
|
||||||
// val bloodGroup = etBloodGroup.text.toString()
|
|
||||||
// if (bloodGroup.isEmpty()) {
|
|
||||||
// etBloodGroup.error = "Please enter your blood group"
|
|
||||||
// } else {
|
|
||||||
// val db: FirebaseFirestore = Firebase.firestore
|
|
||||||
// val userdata = db.collection("patientData")
|
|
||||||
// .whereEqualTo("_id", hemoCubeViewModel.testDetails?._id).get().await()
|
|
||||||
// if (userdata.documents.isNotEmpty()) {
|
|
||||||
// db.collection("patientData").document(userdata.documents[0].id)
|
|
||||||
// .update("bloodGroup", bloodGroup)
|
|
||||||
// withContext(Dispatchers.Main) {
|
|
||||||
// val i = Intent(
|
|
||||||
// requireContext().applicationContext, DashboardActivity::class.java
|
|
||||||
// )
|
|
||||||
// startActivity(i)
|
|
||||||
// (activity as HemocubeActivity).finish()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
private fun observeViewModel() {
|
private fun observeViewModel() {
|
||||||
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
@@ -182,7 +120,6 @@ class HemoCubeFragment : Fragment() {
|
|||||||
val coefficient1 = coefficients[0]
|
val coefficient1 = coefficients[0]
|
||||||
val coefficient2 = coefficients[1]
|
val coefficient2 = coefficients[1]
|
||||||
val result = coefficient1 * coefficient2
|
val result = coefficient1 * coefficient2
|
||||||
// showToast("coefficients: $coefficient1, $coefficient2")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isOnline = isNetworkAvailable
|
isOnline = isNetworkAvailable
|
||||||
@@ -577,12 +514,4 @@ class HemoCubeFragment : Fragment() {
|
|||||||
""
|
""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resetKitCount() {
|
|
||||||
with(sharedPreferences.edit()) {
|
|
||||||
putString(Constants.KIT_NUMBER, "")
|
|
||||||
putInt(Constants.KIT_COUNT, 0)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user