Update Kotlin Version
Remove Room library Adding QRUtils and PdfUtils
This commit is contained in:
@@ -33,7 +33,7 @@ class AddFragment : Fragment() {
|
||||
this.viewModel = addViewModel
|
||||
}
|
||||
|
||||
bindMessage(binding.context)
|
||||
bindMessage(binding.constraintContext)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
@@ -7,6 +7,7 @@ import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import fr.sanchezm.attestationsCovid19.R
|
||||
import fr.sanchezm.attestationsCovid19.data.db.entity.Attestation
|
||||
import fr.sanchezm.attestationsCovid19.data.db.entity.Profile
|
||||
import fr.sanchezm.attestationsCovid19.data.repository.AttestationRepository
|
||||
import fr.sanchezm.attestationsCovid19.data.repository.ProfileRepository
|
||||
@@ -51,6 +52,7 @@ class AddViewModel(
|
||||
fun onGenerateAttestationClick() {
|
||||
if (checkAllValue()) {
|
||||
profileRepository.insertProfile(getProfileFromView())
|
||||
attestationRepository.generateAttestation(getAttestation())
|
||||
} else {
|
||||
_errorMessage.value = Event(R.string.error_cannot_create_attestation)
|
||||
Log.e("onGenerateAttestationClick", "Cannot generate Attestation")
|
||||
@@ -99,6 +101,30 @@ class AddViewModel(
|
||||
)
|
||||
}
|
||||
|
||||
private fun getAttestation(): Attestation {
|
||||
return Attestation(
|
||||
getProfileFromView(),
|
||||
exitDate.value.toString(),
|
||||
exitHour.value.toString(),
|
||||
Date().time,
|
||||
getReasons()
|
||||
)
|
||||
}
|
||||
|
||||
private fun getReasons(): List<Int> {
|
||||
val reasons = ArrayList<Int>()
|
||||
|
||||
if (reason1.value!!) reasons.add(1)
|
||||
if (reason2.value!!) reasons.add(2)
|
||||
if (reason3.value!!) reasons.add(3)
|
||||
if (reason4.value!!) reasons.add(4)
|
||||
if (reason5.value!!) reasons.add(5)
|
||||
if (reason6.value!!) reasons.add(6)
|
||||
if (reason7.value!!) reasons.add(7)
|
||||
|
||||
return reasons
|
||||
}
|
||||
|
||||
private fun checkAllValue(): Boolean {
|
||||
return !firstName.value.isNullOrEmpty()
|
||||
&& !lastName.value.isNullOrEmpty()
|
||||
|
Reference in New Issue
Block a user