Adding generating PDF + message

This commit is contained in:
2020-04-15 20:35:57 +02:00
parent 7614a95489
commit 5ce2bb2fe4
8 changed files with 90 additions and 43 deletions

View File

@ -42,7 +42,13 @@ class AddFragment : Fragment() {
it.getContentIfNotHandled()?.let { stringId ->
Snackbar.make(context, stringId, Snackbar.LENGTH_SHORT ).show()
}
});
})
addViewModel.dataMessage.observe(viewLifecycleOwner, Observer {
it.getContentIfNotHandled()?.let { stringId ->
Snackbar.make(context, stringId, Snackbar.LENGTH_SHORT).show()
}
})
}
private fun initializeUi() {

View File

@ -23,10 +23,14 @@ class AddViewModel(
) : ViewModel() {
private val _errorMessage = MutableLiveData<Event<Int>>()
private val _dataMessage = MutableLiveData<Event<Int>>()
val errorMessage: LiveData<Event<Int>>
get() = _errorMessage
val dataMessage: LiveData<Event<Int>>
get() = _dataMessage
val firstName = MutableLiveData<String>()
val lastName = MutableLiveData<String>()
val birthday = MutableLiveData<String>()
@ -53,6 +57,7 @@ class AddViewModel(
if (checkAllValue()) {
profileRepository.insertProfile(getProfileFromView())
attestationRepository.generateAttestation(getAttestation())
_dataMessage.value = Event(R.string.attestation_generated)
} else {
_errorMessage.value = Event(R.string.error_cannot_create_attestation)
Log.e("onGenerateAttestationClick", "Cannot generate Attestation")