color of download button changed, and try catch block added for download function of csv
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user