From b95692bdf336875cf37c6a1bc7fa9056cca6e563 Mon Sep 17 00:00:00 2001 From: Mathieu Sanchez Date: Fri, 17 Apr 2020 08:59:14 +0200 Subject: [PATCH] Add No Attestations when attestations DB is empty --- .../ui/attestations/AttestationsViewModel.kt | 13 ++++++++++++- app/src/main/res/layout/fragment_attestations.xml | 10 ++++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsViewModel.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsViewModel.kt index 8177937..4d277bb 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsViewModel.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/ui/attestations/AttestationsViewModel.kt @@ -1,5 +1,6 @@ package fr.sanchezm.attestationsCovid19.ui.attestations +import android.view.View import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel @@ -13,13 +14,23 @@ class AttestationsViewModel(attestationRepository: AttestationRepository) : View private var _attestations = attestationRepository.getAttestations() as MutableLiveData> + private var _displayNoAttestation = MutableLiveData() + val attestations: LiveData> = _attestations val startActivity: LiveData> = _startActivity + val displayNoAttestation: LiveData = + _displayNoAttestation + init { - _attestations = attestationRepository.getAttestations() as MutableLiveData> + if (_attestations.value == null || _attestations.value?.size == 0) { + _displayNoAttestation.value = View.VISIBLE + } else { + _displayNoAttestation.value = View.GONE + } } + } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_attestations.xml b/app/src/main/res/layout/fragment_attestations.xml index f2f0f47..803175b 100644 --- a/app/src/main/res/layout/fragment_attestations.xml +++ b/app/src/main/res/layout/fragment_attestations.xml @@ -29,6 +29,16 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + #RestonsChezNous Erreur lors de la génération de l\'attestation, tout les champs ne sont pas compléter Attestation générer + Aucune attestation, veuillez en générer une. Prénom