color of download button changed, and try catch block added for download function of csv

This commit is contained in:
Mariya
2023-12-15 16:43:27 +05:30
parent 9093caa9df
commit d25a1bb08a
2 changed files with 16 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
<vector android:height="24dp" android:tint="@color/primary"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,4c4.41,0 8,3.59 8,8s-3.59,8 -8,8s-8,-3.59 -8,-8S7.59,4 12,4M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10c5.52,0 10,-4.48 10,-10C22,6.48 17.52,2 12,2L12,2zM13,12l0,-4h-2l0,4H8l4,4l4,-4H13z"/>
</vector>
<path android:fillColor="@color/primary" android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z"/>
</vector>

View File

@@ -419,6 +419,7 @@ class HomeFragment : Fragment() {
private fun downloadLocalDBData(dialog: DialogInterface) {
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
try {
val downloadList = mutableListOf<HemoCubeTestData>()
userDataList.forEach { userData ->
@@ -427,15 +428,19 @@ class HomeFragment : Fragment() {
}
}
if (downloadList.isNotEmpty()) {
// Call ViewModel function to create CSV with filtered data
hemoCubeViewModel.createCSV(downloadList, requireContext())
Toast.makeText(requireContext(), "CSV file downloaded successfully", Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(requireContext(), "CSV file downloaing failed", Toast.LENGTH_SHORT).show()
if (downloadList.isNotEmpty()) {
// Call ViewModel function to create CSV with filtered data
hemoCubeViewModel.createCSV(downloadList, requireContext())
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()
}
dialog.dismiss()
}
}