Repository: corona-warn-app/cwa-app-android
File: Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/MainActivity.kt (Kotlin)

Code before:
        viewModel.isCertificatesConsentGiven.observe(this) { isConsentGiven ->
            startCertificatesNestedGraphDestination(navController, isConsentGiven)
        }

        viewModel.activeCheckIns.observe(this) { count ->
            Timber.tag(TAG).d("activeCheckIns=$count")
            binding.mainBottomNavigation.updateCountBadge(R.id.trace_location_attendee_nav_graph, count)
        }

        viewModel.personsBadgeCount.observe(this) { count ->
            Timber.tag(TAG).d("personsBadgeCount=$count")
            binding.mainBottomNavigation.updateCountBadge(R.id.covid_certificates_graph, count)
        }

        viewModel.mainBadgeCount.observe(this) { count ->
            Timber.tag(TAG).d("mainBadgeCount=$count")
            binding.mainBottomNavigation.updateCountBadge(R.id.status_nav_graph, count)
        }

        viewModel.event.observe(this) { event ->
            when (event) {
                is MainActivityEvent.GoToCheckInsFragment -> navController.navigate(
                    CheckInsFragment.createDeepLink(event.uriString)
                )
                is MainActivityEvent.Error -> displayDialog {
                    event.error.toErrorDialogBuilder(context)
                }
                is MainActivityEvent.OpenScanner -> navigateToScanner()
            }
        }

        viewModel.coronaTestResult.observe(this) { handleCoronaTestResult(coronaTestResult = it) }
        viewModel.coronaTestRestoreEvent.observe(this) { handCoronaTestRestoreEvent(event = it) }

        if (savedInstanceState == null) {
            processExtraParameters()
        }
    }

    private fun handleCoronaTestResult(coronaTestResult: CoronaTestQRCodeHandler.Result) = when (coronaTestResult) {
        is CoronaTestQRCodeHandler.InRecycleBin -> {
            showRestoreCoronaTestConfirmation(coronaTestResult.recycledCoronaTest)
            null
        }
        is CoronaTestQRCodeHandler.TestRegistrationSelection ->
            NavGraphDirections.actionGlobalTestRegistrationSelectionFragment(
                coronaTestQrCode = coronaTestResult.coronaTestQrCode
            )
    }?.let { navController.doNavigate(it) }

    private fun showRestoreCoronaTestConfirmation(recycledCoronaTest: BaseCoronaTest) =

Review comment (refactor):
this should be passed as `dialog=event.error.toErrorDialogBuilder(context)` otherwise it does not have an effect , right?

I think we need to refactor this part , it is problematic, you can basically add anything in this block and it fools you as if it is fine 

Code after:
        viewModel.isCertificatesConsentGiven.observe(this) { isConsentGiven ->
            startCertificatesNestedGraphDestination(navController, isConsentGiven)
        }

        viewModel.activeCheckIns.observe(this) { count ->
            Timber.tag(TAG).d("activeCheckIns=$count")
            binding.mainBottomNavigation.updateCountBadge(R.id.trace_location_attendee_nav_graph, count)
        }

        viewModel.personsBadgeCount.observe(this) { count ->
            Timber.tag(TAG).d("personsBadgeCount=$count")
            binding.mainBottomNavigation.updateCountBadge(R.id.covid_certificates_graph, count)
        }

        viewModel.mainBadgeCount.observe(this) { count ->
            Timber.tag(TAG).d("mainBadgeCount=$count")
            binding.mainBottomNavigation.updateCountBadge(R.id.status_nav_graph, count)
        }

        viewModel.event.observe(this) { event ->
            when (event) {
                is MainActivityEvent.GoToCheckInsFragment -> navController.navigate(
                    CheckInsFragment.createDeepLink(event.uriString)
                )
                is MainActivityEvent.Error -> displayDialog(dialog = event.error.toErrorDialogBuilder(baseContext))
                is MainActivityEvent.OpenScanner -> navigateToScanner()
            }
        }

        viewModel.coronaTestResult.observe(this) { handleCoronaTestResult(coronaTestResult = it) }
        viewModel.coronaTestRestoreEvent.observe(this) { handCoronaTestRestoreEvent(event = it) }

        if (savedInstanceState == null) {
            processExtraParameters()
        }
    }

    private fun handleCoronaTestResult(coronaTestResult: CoronaTestQRCodeHandler.Result) = when (coronaTestResult) {
        is CoronaTestQRCodeHandler.InRecycleBin -> {
            showRestoreCoronaTestConfirmation(coronaTestResult.recycledCoronaTest)
            null
        }
        is CoronaTestQRCodeHandler.TestRegistrationSelection ->
            NavGraphDirections.actionGlobalTestRegistrationSelectionFragment(
                coronaTestQrCode = coronaTestResult.coronaTestQrCode
            )
    }?.let { navController.doNavigate(it) }

    private fun showRestoreCoronaTestConfirmation(recycledCoronaTest: BaseCoronaTest) =
        displayDialog(cancelable = false) {
            setTitle(R.string.recycle_bin_restore_corona_test_dialog_title)