Adding generating PDF + message
This commit is contained in:
@ -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() {
|
||||
|
@ -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")
|
||||
|
Reference in New Issue
Block a user