Added condition check for firebase integration enable, for trueheme device, if it enables only the data will upload to firebase, otherwise it will go to molbio server only,

This commit is contained in:
Mariya
2024-04-29 13:41:04 +05:30
parent d7ef2b7ef9
commit 904c0fd2ad
3 changed files with 27 additions and 24 deletions

View File

@@ -22,6 +22,7 @@ object Constants {
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
const val MOLBIO_INTEGRATION = true
const val FIREBASE_INTEGRATION = false
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
const val deviceProvisionPassword = "f2ab0e7f9d69"
const val DEVICE_ID_API = "deviceIDAPI"

View File

@@ -321,8 +321,9 @@ class HomeFragment : Fragment() {
}*/
hemoCubeViewModel.sendDataToMolbio()
// hemoCubeViewModel.sendDataToFirebase()
if(Constants.FIREBASE_INTEGRATION){
hemoCubeViewModel.sendDataToFirebase()
}
} else {
binding.internetAvailableCL.visibility = View.GONE
binding.pendingTest.visibility = View.GONE

View File

@@ -434,29 +434,30 @@ class HemoCubeViewModel @Inject constructor(
"yyyy-MM-dd'T'HH:mm:ssZZZZZ",
Locale.getDefault()
).format(Calendar.getInstance().time)
if(Constants.FIREBASE_INTEGRATION) {
when (val response = repository.addTestToDatabase(testDetails)) {
is Response.Success -> {
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
with(sharedPreference.edit()) {
putInt(Constants.KIT_COUNT, kitCount.plus(1))
apply()
}
Log.i("Testdb", "Data uploaded to Firestore successfully")
fireBaseUpload.postValue("Success")
testDetails.localFlag = true
// when (val response = repository.addTestToDatabase(testDetails)) {
// is Response.Success -> {
// val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
// with(sharedPreference.edit()) {
// putInt(Constants.KIT_COUNT, kitCount.plus(1))
// apply()
// }
// Log.i("Testdb", "Data uploaded to Firestore successfully")
// fireBaseUpload.postValue("Success")
// testDetails.localFlag = true
//
// hemoCubeDao.insertAll(testDetails)
// }
//
// is Response.Error -> {
// Log.e("Testdb", "Error uploading data to Firestore: $response")
// fireBaseUpload.postValue("Error")
// hemoCubeDao.insertAll(testDetails)
// }
//
// else -> {}
// }
hemoCubeDao.updateTest(testDetails)
}
is Response.Error -> {
Log.e("Testdb", "Error uploading data to Firestore: $response")
fireBaseUpload.postValue("Error")
hemoCubeDao.updateTest(testDetails)
}
else -> {}
}
}
if (Constants.MOLBIO_INTEGRATION) {
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
with(sharedPreference.edit()) {