in azure-communication-ui/calling/src/main/java/com/azure/android/communication/ui/calling/presentation/fragment/calling/header/InfoHeaderView.kt [69:161]
fun start(
viewLifecycleOwner: LifecycleOwner,
infoHeaderViewModel: InfoHeaderViewModel,
displayParticipantList: () -> Unit,
) {
this.infoHeaderViewModel = infoHeaderViewModel
this.displayParticipantListCallback = displayParticipantList
setupAccessibility()
viewLifecycleOwner.lifecycleScope.launchAll(
{
infoHeaderViewModel.getIsVisible().collect {
floatingHeader.visibility = if (it) View.VISIBLE else View.GONE
// If we are on television, set the focus to the participants button
if (it && isAndroidTV(context)) {
displayParticipantsImageButton.requestFocus()
}
}
},
{
infoHeaderViewModel.getTitleStateFlow().collect {
if (it.isNullOrEmpty()) {
return@collect
}
participantNumberText.text = it
}
},
{
infoHeaderViewModel.getSubtitleStateFlow().collect {
if (it.isNullOrEmpty()) {
subtitleText.visibility = View.GONE
return@collect
}
subtitleText.text = it
subtitleText.visibility = View.VISIBLE
}
},
{
infoHeaderViewModel.getNumberOfParticipantsFlow().collect {
if (!infoHeaderViewModel.getTitleStateFlow().value.isNullOrEmpty()) {
return@collect
}
participantNumberText.text = when (it) {
0 -> context.getString(R.string.azure_communication_ui_calling_view_info_header_waiting_for_others_to_join)
1 -> context.getString(R.string.azure_communication_ui_calling_view_info_header_call_with_1_person)
else -> resources.getString(
R.string.azure_communication_ui_calling_view_info_header_call_with_n_people,
it
)
}
}
},
{
infoHeaderViewModel.getIsOverlayDisplayedFlow().collect {
if (it) {
ViewCompat.setImportantForAccessibility(
headerView,
ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
)
} else {
ViewCompat.setImportantForAccessibility(
headerView,
ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES
)
}
}
},
{
infoHeaderViewModel.getCustomButton1StateFlow().collect { button ->
updateCustomButton(button, customButton1)
}
},
{
infoHeaderViewModel.getCustomButton2StateFlow().collect { button ->
updateCustomButton(button, customButton2)
}
},
/* <CALL_START_TIME>
{
infoHeaderViewModel.getDisplayCallDurationFlow().collect {
callDurationText.isVisible = it
}
},
{
infoHeaderViewModel.getCallDurationFlow().collect {
callDurationText.text = it
}
}
</CALL_START_TIME> */
)
}