From 7c4717ebb72d9de38475829f88b0bac5733b611d Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Thu, 12 Oct 2023 19:12:40 +0530 Subject: [PATCH 1/2] added view model, laytouts --- .../data/repository/DatabaseRepository.kt | 6 - .../HemoCubeBufferCheckFragment.kt | 36 ---- .../HemoCubeBufferCheckViewModel.kt | 5 - .../HemocubeBufferCheckActivity.kt | 2 +- .../main/res/layout/activity_buffer_check.xml | 41 ++++ .../fragment_hemo_cube_buffer_check.xml | 187 ++++++++++++++++++ 6 files changed, 229 insertions(+), 48 deletions(-) create mode 100644 app/src/main/res/layout/activity_buffer_check.xml create mode 100644 app/src/main/res/layout/fragment_hemo_cube_buffer_check.xml diff --git a/app/src/main/java/com/example/hpostesting/data/repository/DatabaseRepository.kt b/app/src/main/java/com/example/hpostesting/data/repository/DatabaseRepository.kt index 204273e..f9bcee5 100644 --- a/app/src/main/java/com/example/hpostesting/data/repository/DatabaseRepository.kt +++ b/app/src/main/java/com/example/hpostesting/data/repository/DatabaseRepository.kt @@ -52,12 +52,6 @@ class DatabaseRepository : Repository { suspend fun addTestToDatabaseforBufferCheck(data: HemoCubeTestData?): Response { return try { - val userdata = db.collection("patientData").whereEqualTo("_id", data!!._id).get().await() - if (userdata.documents.isNotEmpty()) { - userdata.documents.forEach { - db.collection("patientData").document(it.id).update("testStatus", true) - } - } db.collection("buffers").add(data!!).await() Response.Success(data!!._id) } catch (e: Exception) { diff --git a/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemoCubeBufferCheckFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemoCubeBufferCheckFragment.kt index ed06f03..81ec232 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemoCubeBufferCheckFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemoCubeBufferCheckFragment.kt @@ -142,8 +142,6 @@ class HemoCubeBufferCheckFragment : Fragment() { resultData += fullReadOutput.toString() when { - stringData.contains("ERROR 500") -> showError500Dialog() - stringData.contains("ERROR 501") -> showError501Dialog() stringData.contains("#Buffer Completed") -> showStartSampleDialog() stringData.contains("#Sample Completed") -> { activity?.runOnUiThread { @@ -172,40 +170,6 @@ class HemoCubeBufferCheckFragment : Fragment() { } } - - private fun showError500Dialog() { - UIUtils.createAlertDialog(requireContext(), - "BUFFER ERROR", - "Do you want to continue with existing buffer?", - getString(R.string.noo), - "Yes", - object : MyDialogListener { - override fun onClickNegativeButton() {} - - override fun onClickPositiveButton() { - listenToHemoCube() - startBufferProcess() - } - }) - } - - - private fun showError501Dialog() { - UIUtils.createAlertDialog(requireContext(), - "SAMPLE ERROR", - "Do you want to continue with Sample?", - getString(R.string.noo), - "Yes", - object : MyDialogListener { - override fun onClickNegativeButton() {} - - override fun onClickPositiveButton() { - listenToHemoCube() - startSampleProcess() - } - }) - } - private fun showStartSampleDialog() { activity?.runOnUiThread { UIUtils.createAlertDialog(requireContext(), diff --git a/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemoCubeBufferCheckViewModel.kt b/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemoCubeBufferCheckViewModel.kt index cd7a588..4eb5740 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemoCubeBufferCheckViewModel.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemoCubeBufferCheckViewModel.kt @@ -166,11 +166,6 @@ class HemoCubeBufferCheckViewModel @Inject constructor( when (val response = repository.addTestToDatabaseforBufferCheck(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") } diff --git a/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemocubeBufferCheckActivity.kt b/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemocubeBufferCheckActivity.kt index 6375d39..126936b 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemocubeBufferCheckActivity.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/buffercheck/HemocubeBufferCheckActivity.kt @@ -32,7 +32,7 @@ import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding @AndroidEntryPoint open class HemocubeBufferCheckActivity : AppCompatActivity() { private lateinit var binding: ActivityHemocubeBinding - private val viewModel by viewModels() + private val viewModel by viewModels() private var myMenu: Menu? = null private lateinit var mDriver: UsbSerialDriver diff --git a/app/src/main/res/layout/activity_buffer_check.xml b/app/src/main/res/layout/activity_buffer_check.xml new file mode 100644 index 0000000..cb786da --- /dev/null +++ b/app/src/main/res/layout/activity_buffer_check.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_hemo_cube_buffer_check.xml b/app/src/main/res/layout/fragment_hemo_cube_buffer_check.xml new file mode 100644 index 0000000..5c5c357 --- /dev/null +++ b/app/src/main/res/layout/fragment_hemo_cube_buffer_check.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +