added changes related to save local data in csv file format

This commit is contained in:
Mariya
2023-12-14 21:11:36 +05:30
parent c7a82fa6c6
commit a00bd6e99e
3 changed files with 13 additions and 2 deletions

View File

@@ -123,7 +123,7 @@ class HomeFragment : Fragment() {
}
binding.btnSaveLocal.setOnClickListener {
context?.let { it1 -> showDownloadDialog(context = it1) }
showDownloadDialog(requireContext())
}
binding.btnNewKit.setOnClickListener {
with(sharedPreference.edit()) {

View File

@@ -19,10 +19,12 @@ import com.example.hpostesting.data.model.patient.DeviceData
import com.example.hpostesting.data.model.patient.HemoCubeTestData
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
import com.example.hpostesting.data.repository.DatabaseRepository
import com.example.hpostesting.data.repository.LocalFileRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date
import java.util.Locale
import javax.inject.Inject
@@ -30,7 +32,7 @@ import javax.inject.Inject
class HemoCubeViewModel @Inject constructor(
private val hemoCubeDao: HemoCubeDao,
private val repository: DatabaseRepository,
private val localFileDataSource: LocalFileDataSource,
private val localFileDataSource: LocalFileRepository,
context: Context,
) : ViewModel() {
var isServiceConnected = false
@@ -227,6 +229,11 @@ class HemoCubeViewModel @Inject constructor(
return true // Assuming success, you might want to modify this based on your actual logic
}
private fun getCurrentDate(): String {
val dateFormat = SimpleDateFormat("dd-MM-yy", Locale.getDefault())
val currentDate = Date()
return dateFormat.format(currentDate)
}
fun deleteById(userId: String) = viewModelScope.launch {
hemoCubeDao.deleteById(id = userId)

View File

@@ -188,6 +188,10 @@
<string name="upload_db_registration_message">Do you want to upload the local DB tests to the cloud?</string>
<string name="upload">Upload</string>
<string name="cancel">Cancel</string>
<string name="downloadcsv">Download CSV</string>
<string name="download_db_registration_title">Download DB Tests</string>
<string name="download_db_registration_message">Do you want to download the local DB tests in CSV format?</string>
<string name="upload_success_message">Upload done successfully</string>
<string name="test_completed">Test Completed</string>
<string name="select_blood_group">Select Blood Group</string>