fun update()

in azure-communication-ui/calling/src/main/java/com/azure/android/communication/ui/calling/presentation/fragment/calling/participant/grid/ParticipantGridViewModel.kt [78:124]


    fun update(
        remoteParticipantsMapUpdatedTimestamp: Number,
        remoteParticipantsMap: Map<String, ParticipantInfoModel>,
        dominantSpeakersInfo: List<String>,
        dominantSpeakersModifiedTimestamp: Number,
        visibilityStatus: VisibilityStatus,
        rttState: RttState,
        isOverlayDisplayedOverGrid: Boolean,
        deviceConfigurationState: DeviceConfigurationState,
        captionsState: CaptionsState,
    ) {

        isOverlayDisplayedFlow.value = isOverlayDisplayedOverGrid
        isVerticalStyleGridMutableFlow.value = shouldUseVerticalStyleGrid(deviceConfigurationState, rttState, captionsState)

        if (remoteParticipantsMapUpdatedTimestamp == remoteParticipantStateModifiedTimeStamp &&
            dominantSpeakersModifiedTimestamp == dominantSpeakersStateModifiedTimestamp &&
            this.visibilityStatus == visibilityStatus
        ) {
            return
        }

        remoteParticipantStateModifiedTimeStamp = remoteParticipantsMapUpdatedTimestamp
        dominantSpeakersStateModifiedTimestamp = dominantSpeakersModifiedTimestamp
        this.visibilityStatus = visibilityStatus

        var remoteParticipantsMapSorted = remoteParticipantsMap
        val participantSharingScreen = getParticipantSharingScreen(remoteParticipantsMap)

        if (participantSharingScreen.isNullOrEmpty()) {
            if (remoteParticipantsMap.size > getMaxRemoteParticipantsSize()) {
                remoteParticipantsMapSorted =
                    sortRemoteParticipants(remoteParticipantsMap, dominantSpeakersInfo)
            }
        } else {
            remoteParticipantsMapSorted = mapOf(
                Pair(
                    participantSharingScreen,
                    remoteParticipantsMap[participantSharingScreen]!!
                )
            )
        }

        updateRemoteParticipantsVideoStreams(remoteParticipantsMapSorted)

        updateDisplayedParticipants(remoteParticipantsMapSorted.toMutableMap())
    }