changes related to csv added
This commit is contained in:
@@ -418,22 +418,33 @@ class HomeFragment : Fragment() {
|
||||
|
||||
|
||||
private fun downloadLocalDBData(dialog: DialogInterface) {
|
||||
var csvDownloaded = false
|
||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||
try {
|
||||
val downloadList = mutableListOf<HemoCubeTestData>()
|
||||
if (!csvDownloaded) {
|
||||
|
||||
userDataList.forEach { userData ->
|
||||
if (!userData.isCSVCreated) {
|
||||
downloadList.add(userData) // Add the userData to downloadList
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
val downloadList = mutableListOf<HemoCubeTestData>()
|
||||
|
||||
userDataList.forEach { userData ->
|
||||
// if (!userData.isCSVCreated) {
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user