Compare commits
2 Commits
2.1.118
...
dev-check-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a31d26bc1 | ||
|
|
3199caae5c |
@@ -19,8 +19,8 @@ android {
|
|||||||
applicationId "in.sminnovations.hpostesting.dev"
|
applicationId "in.sminnovations.hpostesting.dev"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 120
|
versionCode 114
|
||||||
versionName "2.1.120"
|
versionName "2.1.114"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
if(isRegistered) {
|
if(isRegistered) {
|
||||||
try {
|
try {
|
||||||
// unregisterReceiver(downloadReceiver)
|
unregisterReceiver(downloadReceiver)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d("HomeFragment", e.toString())
|
Log.d("HomeFragment", e.toString())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.content.FileProvider
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
@@ -151,7 +150,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now re-subscribe to allUserData
|
// Now re-subscribe to allUserData
|
||||||
hemoCubeViewModel.allLocalData.observe(viewLifecycleOwner) { originalUserDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { originalUserDataList ->
|
||||||
|
|
||||||
Log.d("LOCAL_DB OBSERVE", "OBSERVE CALLED")
|
Log.d("LOCAL_DB OBSERVE", "OBSERVE CALLED")
|
||||||
|
|
||||||
@@ -237,34 +236,30 @@ class HomeFragment : Fragment() {
|
|||||||
logoutUser(requireContext())
|
logoutUser(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnLogout1.setOnClickListener {
|
|
||||||
logoutUser(requireContext())
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.uploadData.setOnClickListener {
|
binding.uploadData.setOnClickListener {
|
||||||
// showUploadDialog(requireContext())
|
// showUploadDialog(requireContext())
|
||||||
}
|
}
|
||||||
// hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
//
|
|
||||||
// val btnSaveLocalVisibility =
|
val btnSaveLocalVisibility =
|
||||||
// if (userData.any { it.testStatus == true }) View.GONE else View.GONE
|
if (userData.any { it.testStatus == true }) View.GONE else View.GONE
|
||||||
//
|
|
||||||
// binding.downloadCSV.visibility = btnSaveLocalVisibility
|
binding.downloadCSV.visibility = btnSaveLocalVisibility
|
||||||
//
|
|
||||||
// binding.downloadCSV.setOnClickListener {
|
binding.downloadCSV.setOnClickListener {
|
||||||
// if (btnSaveLocalVisibility == View.VISIBLE) {
|
if (btnSaveLocalVisibility == View.VISIBLE) {
|
||||||
// // Execute the action when the button is visible (testStatus is true for at least one user)
|
// Execute the action when the button is visible (testStatus is true for at least one user)
|
||||||
// showDownloadDialog(requireContext())
|
showDownloadDialog(requireContext())
|
||||||
// } else {
|
} else {
|
||||||
// // Handle the case when the button is not visible
|
// Handle the case when the button is not visible
|
||||||
// Toast.makeText(
|
Toast.makeText(
|
||||||
// requireContext(),
|
requireContext(),
|
||||||
// "No test details stored locally",
|
"No test details stored locally",
|
||||||
// Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
// ).show()
|
).show()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.btnNewKit.setOnClickListener {
|
binding.btnNewKit.setOnClickListener {
|
||||||
@@ -276,17 +271,6 @@ class HomeFragment : Fragment() {
|
|||||||
startActivity(Intent(requireContext(), KitScanActivity::class.java))
|
startActivity(Intent(requireContext(), KitScanActivity::class.java))
|
||||||
requireActivity().finish()
|
requireActivity().finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.btnNewKitoffline.setOnClickListener {
|
|
||||||
with(sharedPreference.edit()) {
|
|
||||||
putString(Constants.KIT_NUMBER, "")
|
|
||||||
putInt(Constants.KIT_COUNT, 0)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
startActivity(Intent(requireContext(), KitScanActivity::class.java))
|
|
||||||
requireActivity().finish()
|
|
||||||
}
|
|
||||||
binding.btnQuickCapture.setOnClickListener {
|
binding.btnQuickCapture.setOnClickListener {
|
||||||
DataHolder.hemoCubeTestData = HemoCubeTestData()
|
DataHolder.hemoCubeTestData = HemoCubeTestData()
|
||||||
|
|
||||||
@@ -326,7 +310,7 @@ class HomeFragment : Fragment() {
|
|||||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (userID == "deviceIDAPI" && password == "devicePasswordAPI" && deviceId.isNotEmpty()) {
|
} else if (userID.isEmpty() && password.isEmpty() && deviceId.isNotEmpty()) {
|
||||||
fetchDeviceCredentials()
|
fetchDeviceCredentials()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
@@ -862,16 +846,16 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForLocalDBData() {
|
private fun checkForLocalDBData() {
|
||||||
// viewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
viewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// val uploadDataVisibility = if (userDataList.isEmpty()) View.GONE else View.VISIBLE
|
val uploadDataVisibility = if (userDataList.isEmpty()) View.GONE else View.VISIBLE
|
||||||
// binding.uploadData.visibility = uploadDataVisibility
|
binding.uploadData.visibility = uploadDataVisibility
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// val uploadDataVisibility =
|
val uploadDataVisibility =
|
||||||
// if (userDataList.any { !it.localFlag && !it.molbioFlag && it.testStatus == true }) View.VISIBLE else View.GONE
|
if (userDataList.any { !it.localFlag && !it.molbioFlag && it.testStatus == true }) View.VISIBLE else View.GONE
|
||||||
// binding.uploadData.visibility = uploadDataVisibility
|
binding.uploadData.visibility = uploadDataVisibility
|
||||||
// }
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { bufferData ->
|
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { bufferData ->
|
||||||
val uploadDataVisibility =
|
val uploadDataVisibility =
|
||||||
@@ -881,11 +865,11 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkUnprocessedCSVData() {
|
private fun checkUnprocessedCSVData() {
|
||||||
// hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// val downloadDataVisibility =
|
val downloadDataVisibility =
|
||||||
// if (userDataList.any { !it.isCSVCreated && it.testStatus == true }) View.GONE else View.GONE
|
if (userDataList.any { !it.isCSVCreated && it.testStatus == true }) View.GONE else View.GONE
|
||||||
// binding.downloadCSV.visibility = downloadDataVisibility
|
binding.downloadCSV.visibility = downloadDataVisibility
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sanitizeDoubleValues(hemoCubeTestData: HemoCubeTestData): HemoCubeTestData {
|
private fun sanitizeDoubleValues(hemoCubeTestData: HemoCubeTestData): HemoCubeTestData {
|
||||||
@@ -938,23 +922,23 @@ class HomeFragment : Fragment() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
private fun uploadLocalDBData(dialog: DialogInterface) {
|
private fun uploadLocalDBData(dialog: DialogInterface) {
|
||||||
// viewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
viewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// if (userDataList.isEmpty()) {
|
if (userDataList.isEmpty()) {
|
||||||
// dialog.dismiss()
|
dialog.dismiss()
|
||||||
// } else {
|
} else {
|
||||||
// userDataList.forEach { userData ->
|
userDataList.forEach { userData ->
|
||||||
// viewModel.bulkUploadResultToDatabase(userData)
|
viewModel.bulkUploadResultToDatabase(userData)
|
||||||
// viewModel.deleteById(userData._id)
|
viewModel.deleteById(userData._id)
|
||||||
// }
|
}
|
||||||
// dialog.dismiss()
|
dialog.dismiss()
|
||||||
// Toast.makeText(
|
Toast.makeText(
|
||||||
// requireContext(), R.string.upload_success_message, Toast.LENGTH_SHORT
|
requireContext(), R.string.upload_success_message, Toast.LENGTH_SHORT
|
||||||
// ).show()
|
).show()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// val resultList = MolbioV2ResultRequest(mutableListOf(MolbioV2Result()))
|
val resultList = MolbioV2ResultRequest(mutableListOf(MolbioV2Result()))
|
||||||
// userDataList.forEach { userData ->
|
// userDataList.forEach { userData ->
|
||||||
// if (!userData.molbioFlag && isTokenAvailable) {
|
// if (!userData.molbioFlag && isTokenAvailable) {
|
||||||
// resultList.results?.add(
|
// resultList.results?.add(
|
||||||
@@ -983,8 +967,8 @@ class HomeFragment : Fragment() {
|
|||||||
// hemoCubeViewModel.uploadResult(resultList)
|
// hemoCubeViewModel.uploadResult(resultList)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// dialog.dismiss()
|
dialog.dismiss()
|
||||||
// }
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { kitDataList ->
|
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { kitDataList ->
|
||||||
kitDataList.forEach { userData ->
|
kitDataList.forEach { userData ->
|
||||||
@@ -1059,7 +1043,7 @@ class HomeFragment : Fragment() {
|
|||||||
builder.setMessage(R.string.download_db_registration_message)
|
builder.setMessage(R.string.download_db_registration_message)
|
||||||
|
|
||||||
builder.setPositiveButton(R.string.downloadcsv) { dialog, _ ->
|
builder.setPositiveButton(R.string.downloadcsv) { dialog, _ ->
|
||||||
// downloadLocalDBData(dialog)
|
downloadLocalDBData(dialog)
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.setNegativeButton(R.string.cancel) { dialog, _ ->
|
builder.setNegativeButton(R.string.cancel) { dialog, _ ->
|
||||||
@@ -1070,49 +1054,49 @@ class HomeFragment : Fragment() {
|
|||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun downloadLocalDBData(dialog: DialogInterface) {
|
private fun downloadLocalDBData(dialog: DialogInterface) {
|
||||||
// var csvDownloaded = false
|
var csvDownloaded = false
|
||||||
// hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// try {
|
try {
|
||||||
// if (!csvDownloaded) {
|
if (!csvDownloaded) {
|
||||||
// val downloadList = mutableListOf<HemoCubeTestData>()
|
val downloadList = mutableListOf<HemoCubeTestData>()
|
||||||
//
|
|
||||||
// userDataList.forEach { userData ->
|
userDataList.forEach { userData ->
|
||||||
// if (userData.testStatus == true) {
|
if (userData.testStatus == true) {
|
||||||
//// if (!userData.isCSVCreated) {
|
// if (!userData.isCSVCreated) {
|
||||||
// downloadList.add(userData) // Add the userData to downloadList
|
downloadList.add(userData) // Add the userData to downloadList
|
||||||
// }
|
}
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (downloadList.isNotEmpty()) {
|
|
||||||
// // Call ViewModel function to create CSV with filtered data
|
|
||||||
// hemoCubeViewModel.createCSV(downloadList, requireContext())
|
|
||||||
// csvDownloaded = true
|
|
||||||
// Toast.makeText(
|
|
||||||
// requireContext(),
|
|
||||||
// "CSV file downloaded successfully",
|
|
||||||
// Toast.LENGTH_SHORT
|
|
||||||
// ).show()
|
|
||||||
// } else {
|
|
||||||
// Toast.makeText(
|
|
||||||
// requireContext(),
|
|
||||||
// "No data to download",
|
|
||||||
// Toast.LENGTH_SHORT
|
|
||||||
// )
|
|
||||||
// .show()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// } catch (e: Exception) {
|
|
||||||
// e.printStackTrace()
|
|
||||||
// Toast.makeText(requireContext(), "Error downloading CSV file", Toast.LENGTH_SHORT)
|
|
||||||
// .show()
|
|
||||||
// } finally {
|
|
||||||
// dialog.dismiss()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (downloadList.isNotEmpty()) {
|
||||||
|
// Call ViewModel function to create CSV with filtered data
|
||||||
|
hemoCubeViewModel.createCSV(downloadList, requireContext())
|
||||||
|
csvDownloaded = true
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"CSV file downloaded successfully",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"No data to download",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
Toast.makeText(requireContext(), "Error downloading CSV file", Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
} finally {
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getDeviceId() {
|
private fun getDeviceId() {
|
||||||
Log.d("HomeFragmentUSb","getDeviceId")
|
Log.d("HomeFragmentUSb","getDeviceId")
|
||||||
@@ -1174,7 +1158,7 @@ class HomeFragment : Fragment() {
|
|||||||
val deviceUpdateAvailableGlobal= deviceData.deviceUpdateAvailable
|
val deviceUpdateAvailableGlobal= deviceData.deviceUpdateAvailable
|
||||||
val updatePathGlobal= deviceData.updatePath
|
val updatePathGlobal= deviceData.updatePath
|
||||||
|
|
||||||
|
// if(deviceUpdateAvailableGlobal){
|
||||||
db.collection("devices").whereEqualTo("deviceId", deviceId).get().addOnSuccessListener { documentSnapshotNew ->
|
db.collection("devices").whereEqualTo("deviceId", deviceId).get().addOnSuccessListener { documentSnapshotNew ->
|
||||||
if (documentSnapshotNew.documents.isNotEmpty()) {
|
if (documentSnapshotNew.documents.isNotEmpty()) {
|
||||||
documentSnapshotNew.documents.forEach{
|
documentSnapshotNew.documents.forEach{
|
||||||
@@ -1198,24 +1182,14 @@ class HomeFragment : Fragment() {
|
|||||||
Log.d("HomeFragmentUpdate","Device update not available")
|
Log.d("HomeFragmentUpdate","Device update not available")
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(deviceUpdateAvailableGlobal) {
|
|
||||||
if(!globalUpdateDone){
|
if(!globalUpdateDone){
|
||||||
val update =
|
val update = db.collection("devices").document(it.id).update("globalUpdateDone",true)
|
||||||
db.collection("devices").document(it.id)
|
|
||||||
.update("globalUpdateDone", true)
|
|
||||||
update.addOnSuccessListener {
|
update.addOnSuccessListener {
|
||||||
Log.d(
|
Log.d("HomeFragmentUpdate","Device global update done")
|
||||||
"HomeFragmentUpdate",
|
|
||||||
"Device global update done"
|
|
||||||
)
|
|
||||||
|
|
||||||
initiateUpdate(updatePathGlobal)
|
initiateUpdate(updatePathGlobal)
|
||||||
}.addOnFailureListener{
|
}.addOnFailureListener{
|
||||||
Log.e(
|
Log.e("fetchDeviceUpdate", "update fail.")
|
||||||
"fetchDeviceUpdate",
|
|
||||||
"update fail."
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1237,7 +1211,8 @@ class HomeFragment : Fragment() {
|
|||||||
"fetchDeviceCredentials",
|
"fetchDeviceCredentials",
|
||||||
"deviceVersion: $deviceVersion, Password: $deviceUpdateAvailableGlobal, updatePath: $updatePathGlobal"
|
"deviceVersion: $deviceVersion, Password: $deviceUpdateAvailableGlobal, updatePath: $updatePathGlobal"
|
||||||
)
|
)
|
||||||
// ?: Log.e("fetchDeviceUpdate", "Failed to parse device data.")
|
|
||||||
|
// } ?: Log.e("fetchDeviceUpdate", "Failed to parse device data.")
|
||||||
} else {
|
} else {
|
||||||
Log.e("fetchDeviceUpdate", "Document does not exist.")
|
Log.e("fetchDeviceUpdate", "Document does not exist.")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -173,11 +172,10 @@ class HemoCubeFragment : Fragment() {
|
|||||||
it.exception.let { message ->
|
it.exception.let { message ->
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
"$message",
|
"An error occurred: $message",
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
)
|
)
|
||||||
.show()
|
.show()
|
||||||
Log.d("resultuploadfail1", message.toString())
|
|
||||||
}
|
}
|
||||||
handleReadingFinish()
|
handleReadingFinish()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
|||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
import com.example.hpostesting.domain.CheckUpdateWorker
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
import com.google.gson.GsonBuilder
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
@@ -89,7 +88,6 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
|
|
||||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
val allUserData = hemoCubeDao.getAll()
|
val allUserData = hemoCubeDao.getAll()
|
||||||
val allLocalData = hemoCubeDao.getAll()
|
|
||||||
val allPendingUserToUpload = MutableLiveData<List<HemoCubeTestData>>()
|
val allPendingUserToUpload = MutableLiveData<List<HemoCubeTestData>>()
|
||||||
val allKitTestData = hemoCubeBufferDao.getAll()
|
val allKitTestData = hemoCubeBufferDao.getAll()
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
@@ -335,24 +333,20 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
testDetails.localFlag = true
|
testDetails.localFlag = true
|
||||||
if (Constants.MOLBIO_INTEGRATION) {
|
if (Constants.MOLBIO_INTEGRATION) {
|
||||||
// Sanitize testDetails before using it in the API call
|
|
||||||
val sanitizedTestDetails = sanitizeDoubleValues(testDetails)
|
|
||||||
|
|
||||||
// Now, use sanitizedTestDetails for the API call
|
|
||||||
uploadResult(
|
uploadResult(
|
||||||
MolbioV2ResultRequest(
|
MolbioV2ResultRequest(
|
||||||
mutableListOf(
|
mutableListOf(
|
||||||
MolbioV2Result(
|
MolbioV2Result(
|
||||||
rawData = sanitizedTestDetails,
|
rawData = testDetails,
|
||||||
analysisId = sanitizedTestDetails._id,
|
analysisId = testDetails._id,
|
||||||
analysisDate = sanitizedTestDetails.testTime,
|
analysisDate = testDetails.testTime,
|
||||||
analysisStatus = sanitizedTestDetails.classificationResult,
|
analysisStatus = testDetails.classificationResult,
|
||||||
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[sanitizedTestDetails.deviceId]?.toString(),
|
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[testDetails.deviceId].toString(),
|
||||||
interpretation = sanitizedTestDetails.classificationResult,
|
interpretation = testDetails.classificationResult,
|
||||||
testId = sanitizedTestDetails._id,
|
testId = testDetails._id,
|
||||||
testTime = sanitizedTestDetails.testTime,
|
testTime = testDetails.testTime,
|
||||||
collectionTime = sanitizedTestDetails.testTime,
|
collectionTime = testDetails.testTime,
|
||||||
expiryTime = sanitizedTestDetails.testTime,
|
expiryTime = testDetails.testTime,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -381,7 +375,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
userData.reportUploadTime = SimpleDateFormat(
|
userData.reportUploadTime = SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
when (repository.addTestToDatabase(userData)) {
|
when (repository.addTestToDatabasefornew(userData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
fireBaseBulkUpload.postValue("Success")
|
fireBaseBulkUpload.postValue("Success")
|
||||||
updateLocalFlag(userData._id)
|
updateLocalFlag(userData._id)
|
||||||
@@ -394,19 +388,6 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sanitizeDoubleValues(hemoCubeTestData: HemoCubeTestData): HemoCubeTestData {
|
|
||||||
hemoCubeTestData::class.java.declaredFields.forEach { field ->
|
|
||||||
if (field.type == Double::class.javaObjectType || field.type == Double::class.javaPrimitiveType) {
|
|
||||||
field.isAccessible = true
|
|
||||||
val value = field.get(hemoCubeTestData) as Double?
|
|
||||||
if (value != null && (value.isInfinite() || value.isNaN())) {
|
|
||||||
field.set(hemoCubeTestData, 0.0) // Replace with a suitable default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return hemoCubeTestData
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateLocalFlag(userId: String) = viewModelScope.launch {
|
private fun updateLocalFlag(userId: String) = viewModelScope.launch {
|
||||||
hemoCubeDao.updateFieldById(id = userId, true)
|
hemoCubeDao.updateFieldById(id = userId, true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,20 +38,10 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:padding="24dp">
|
android:padding="24dp">
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/btnLogout1"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
android:src="@drawable/baseline_logout_24"
|
|
||||||
app:layout_constraintTop_toTopOf="@+id/internetNotAvailableCL"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_title_no_internet"
|
android:id="@+id/tv_title_no_internet"
|
||||||
style="@style/title1"
|
style="@style/title1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
@@ -135,27 +125,6 @@
|
|||||||
<!-- app:layout_constraintBottom_toBottomOf="@+id/rv_order_offline"-->
|
<!-- app:layout_constraintBottom_toBottomOf="@+id/rv_order_offline"-->
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/label1"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/new_kit"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/btnNewKitoffline"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/btnNewKitoffline"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
android:backgroundTint="@color/primary"
|
|
||||||
android:contentDescription="@string/new_kit"
|
|
||||||
android:src="@drawable/ic_add"
|
|
||||||
app:elevation="1dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<external-files-path name="Updates" path="." />
|
<external-files-path name="downloaded_file" path="." />
|
||||||
</paths>
|
</paths>
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ buildscript {
|
|||||||
kotlin_version = '1.8.21'
|
kotlin_version = '1.8.21'
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:8.2.2'
|
classpath 'com.android.tools.build:gradle:8.3.0'
|
||||||
classpath 'com.google.gms:google-services:4.4.1'
|
classpath 'com.google.gms:google-services:4.4.0'
|
||||||
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.1.0'
|
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.0.1'
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,4 +1,4 @@
|
|||||||
#Mon Mar 04 17:08:24 IST 2024
|
#Tue Feb 27 16:09:58 IST 2024
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||||
|
|||||||
Reference in New Issue
Block a user