fun update()

in azure-communication-ui/calling/src/main/java/com/azure/android/communication/ui/calling/presentation/fragment/calling/notification/UpperMessageBarNotificationLayoutViewModel.kt [30:99]


    fun update(callDiagnosticsState: CallDiagnosticsState) {

        when (callDiagnosticsState.mediaCallDiagnostic?.diagnosticKind) {
            MediaCallDiagnostic.NO_SPEAKER_DEVICES_AVAILABLE -> {
                if (mediaDiagnosticNotificationViewModels[MediaCallDiagnostic.NO_SPEAKER_DEVICES_AVAILABLE] == null &&
                    callDiagnosticsState.mediaCallDiagnostic.diagnosticValue
                ) {
                    var upperMessageBarNotificationModel = UpperMessageBarNotificationModel(
                        R.drawable.azure_communication_ui_calling_ic_fluent_speaker_mute_24_regular,
                        R.string.azure_communication_ui_calling_diagnostics_unable_to_locate_speaker,
                        MediaCallDiagnostic.NO_SPEAKER_DEVICES_AVAILABLE,
                    )
                    addNewNotification(upperMessageBarNotificationModel)
                } else if (mediaDiagnosticNotificationViewModels[MediaCallDiagnostic.NO_SPEAKER_DEVICES_AVAILABLE] != null &&
                    !callDiagnosticsState.mediaCallDiagnostic.diagnosticValue
                ) {
                    dismissNotification(MediaCallDiagnostic.NO_SPEAKER_DEVICES_AVAILABLE)
                }
            }
            MediaCallDiagnostic.NO_MICROPHONE_DEVICES_AVAILABLE -> {
                if (mediaDiagnosticNotificationViewModels[MediaCallDiagnostic.NO_MICROPHONE_DEVICES_AVAILABLE] == null &&
                    callDiagnosticsState.mediaCallDiagnostic.diagnosticValue
                ) {
                    var upperMessageBarNotificationModel = UpperMessageBarNotificationModel(
                        R.drawable.azure_communication_ui_calling_ic_fluent_mic_prohibited_24_regular,
                        R.string.azure_communication_ui_calling_diagnostics_unable_to_locate_microphone,
                        MediaCallDiagnostic.NO_MICROPHONE_DEVICES_AVAILABLE
                    )
                    addNewNotification(upperMessageBarNotificationModel)
                } else if (mediaDiagnosticNotificationViewModels[MediaCallDiagnostic.NO_MICROPHONE_DEVICES_AVAILABLE] != null &&
                    !callDiagnosticsState.mediaCallDiagnostic.diagnosticValue
                ) {
                    dismissNotification(MediaCallDiagnostic.NO_MICROPHONE_DEVICES_AVAILABLE)
                }
            }
            MediaCallDiagnostic.MICROPHONE_NOT_FUNCTIONING -> {
                if (mediaDiagnosticNotificationViewModels[MediaCallDiagnostic.MICROPHONE_NOT_FUNCTIONING] == null &&
                    callDiagnosticsState.mediaCallDiagnostic.diagnosticValue
                ) {
                    var upperMessageBarNotificationModel = UpperMessageBarNotificationModel(
                        R.drawable.azure_communication_ui_calling_ic_fluent_mic_prohibited_24_regular,
                        R.string.azure_communication_ui_calling_diagnostics_microphone_not_working_as_expected,
                        MediaCallDiagnostic.MICROPHONE_NOT_FUNCTIONING
                    )
                    addNewNotification(upperMessageBarNotificationModel)
                } else if (mediaDiagnosticNotificationViewModels[MediaCallDiagnostic.MICROPHONE_NOT_FUNCTIONING] != null &&
                    !callDiagnosticsState.mediaCallDiagnostic.diagnosticValue
                ) {
                    dismissNotification(MediaCallDiagnostic.MICROPHONE_NOT_FUNCTIONING)
                }
            }
            MediaCallDiagnostic.SPEAKER_NOT_FUNCTIONING -> {
                if (mediaDiagnosticNotificationViewModels[MediaCallDiagnostic.SPEAKER_NOT_FUNCTIONING] == null &&
                    callDiagnosticsState.mediaCallDiagnostic.diagnosticValue
                ) {
                    var upperMessageBarNotificationModel = UpperMessageBarNotificationModel(
                        R.drawable.azure_communication_ui_calling_ic_fluent_speaker_mute_24_regular,
                        R.string.azure_communication_ui_calling_diagnostics_speaker_not_working_as_expected,
                        MediaCallDiagnostic.SPEAKER_NOT_FUNCTIONING
                    )
                    addNewNotification(upperMessageBarNotificationModel)
                } else if (mediaDiagnosticNotificationViewModels[MediaCallDiagnostic.SPEAKER_NOT_FUNCTIONING] != null &&
                    !callDiagnosticsState.mediaCallDiagnostic.diagnosticValue
                ) {
                    dismissNotification(MediaCallDiagnostic.SPEAKER_NOT_FUNCTIONING)
                }
            }
            else -> {}
        }
    }