new 125 version, changes in HemoCubeFragment Ip address in home, led1Average at line 1004 change if condition, in home download csv for all.

This commit is contained in:
chandrashekhar reddy
2024-07-15 14:44:19 +05:30
parent 735afbf3c0
commit 5e1283873d
2 changed files with 46 additions and 19 deletions

View File

@@ -138,6 +138,7 @@ class HomeFragment : Fragment() {
viewModel.allUserData.observe(viewLifecycleOwner) { userData ->
deleteIncompleteRegistrations(userData)
}
getLocationIP()
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
deleteHemoCubeIncompleteRegistrations(userData)
if (userData.isNotEmpty()) {
@@ -192,25 +193,26 @@ class HomeFragment : Fragment() {
//// showUploadDialog(requireContext())
// }
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
val btnSaveLocalVisibility =
if (userData.any { it.testStatus == true }) View.VISIBLE else View.GONE
binding.downloadCSV.visibility = btnSaveLocalVisibility
binding.downloadCSV.setOnClickListener {
if (btnSaveLocalVisibility == View.VISIBLE) {
// Execute the action when the button is visible (testStatus is true for at least one user)
showDownloadDialog(requireContext())
} else {
// Handle the case when the button is not visible
Toast.makeText(
requireContext(),
"No test details stored locally",
Toast.LENGTH_SHORT
).show()
}
// if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
//
// }else{
// binding.downloadCSV.visibility = View.GONE
// }
val btnSaveLocalVisibility =
if (userData.any { it.testStatus == true }) View.VISIBLE else View.GONE
binding.downloadCSV.visibility = btnSaveLocalVisibility
binding.downloadCSV.setOnClickListener {
if (btnSaveLocalVisibility == View.VISIBLE) {
// Execute the action when the button is visible (testStatus is true for at least one user)
showDownloadDialog(requireContext())
} else {
// Handle the case when the button is not visible
Toast.makeText(
requireContext(),
"No test details stored locally",
Toast.LENGTH_SHORT
).show()
}
}else{
binding.downloadCSV.visibility = View.GONE
}
}
@@ -256,6 +258,18 @@ class HomeFragment : Fragment() {
checkNetworkStatus()
}
private fun getLocationIP() {
getPublicIpAddr { ipAddress ->
if(ipAddress != "fail"){
DataHolder.ipAddress = ipAddress
with(sharedPreference.edit()) {
putString(Constants.IP_ADDRESS, ipAddress)
apply()
}
}
}
}
@RequiresApi(Build.VERSION_CODES.P)
private fun checkNetworkStatus() {
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isConnected ->

View File

@@ -150,6 +150,7 @@ class HemoCubeFragment : Fragment() {
if (isBufferValueAvailable()){
hemoCubeViewModel.messages.postValue("Ready to test")
isUsingExistingBuffer = true
binding.btnPlacebuffer.apply {
setBackgroundColor(Color.GREEN) // Set button background color to green
text = "Refresh Buffer" // Change button text to "Buffer Exists"
@@ -997,7 +998,19 @@ class HemoCubeFragment : Fragment() {
//used for latest trueheme and v1
val deviceRatio = led2Average / led1Average
val borderlineMetric = (led1Average - led2Average) / deviceRatio
// activity?.runOnUiThread {
// Toast.makeText(requireContext(),"led1Average: $led1Average, led2Average: $led2Average",Toast.LENGTH_LONG).show()
// }
if(led1Average < 0 || led2Average < 0){
hemoCubeViewModel.messages.postValue("Negative Absorbance - Repeat test with reading Buffer first and sample second")
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
binding.testing.visibility = View.GONE
binding.btnPlacebuffer.visibility = View.GONE
binding.btnSamplestart.visibility = View.VISIBLE
binding.btnSamplestart.isClickable = true
binding.btnSamplestart.isEnabled = true
return
}
if(Constants.ABS_FLAGS_ENABLED){
val inRange2mmLed1: Boolean
val inRange2mmLed2: Boolean