diff --git a/wallet/src/main/java/ch/admin/bag/covidcertificate/wallet/homescreen/pager/TransferCodePagerFragment.kt b/wallet/src/main/java/ch/admin/bag/covidcertificate/wallet/homescreen/pager/TransferCodePagerFragment.kt index 9f5fbebd..7343c493 100644 --- a/wallet/src/main/java/ch/admin/bag/covidcertificate/wallet/homescreen/pager/TransferCodePagerFragment.kt +++ b/wallet/src/main/java/ch/admin/bag/covidcertificate/wallet/homescreen/pager/TransferCodePagerFragment.kt @@ -87,8 +87,10 @@ class TransferCodePagerFragment : Fragment(R.layout.fragment_transfer_code_pager // Before that call, the fragment root will be measured with the entire screen size and not the reduced viewpager size view.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { override fun onGlobalLayout() { - vaccinationHintViewModel.displayVaccinationHint.observe(viewLifecycleOwner) { shouldDisplayVaccinationHint -> - displayVaccinationHint(shouldDisplayVaccinationHint) + if (isAdded) { + vaccinationHintViewModel.displayVaccinationHint.observe(viewLifecycleOwner) { shouldDisplayVaccinationHint -> + displayVaccinationHint(shouldDisplayVaccinationHint) + } } view.viewTreeObserver.removeOnGlobalLayoutListener(this)