diff --git a/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt b/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt index f5e6fae..52336aa 100644 --- a/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt +++ b/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt @@ -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" diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt index ccef187..7fb7fb8 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt @@ -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 diff --git a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt index 96cdc62..78b4827 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt @@ -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()) {