Check if lateinit conference was initialized

This commit is contained in:
Sylvain Berfini 2025-03-24 09:44:47 +01:00
parent 2b040c9c72
commit 8ef5adc06d

View file

@ -366,6 +366,7 @@ class ConferenceViewModel
@UiThread @UiThread
fun goToConversation() { fun goToConversation() {
if (::conference.isInitialized) {
coreContext.postOnCoreThread { core -> coreContext.postOnCoreThread { core ->
Log.i("$TAG Navigating to conference's conversation") Log.i("$TAG Navigating to conference's conversation")
val chatRoom = conference.chatRoom val chatRoom = conference.chatRoom
@ -378,6 +379,7 @@ class ConferenceViewModel
} }
} }
} }
}
@UiThread @UiThread
fun showLayoutMenu() { fun showLayoutMenu() {
@ -393,6 +395,7 @@ class ConferenceViewModel
@UiThread @UiThread
fun inviteSipUrisIntoConference(uris: List<String>) { fun inviteSipUrisIntoConference(uris: List<String>) {
if (::conference.isInitialized) {
coreContext.postOnCoreThread { core -> coreContext.postOnCoreThread { core ->
val addresses = arrayListOf<Address>() val addresses = arrayListOf<Address>()
for (uri in uris) { for (uri in uris) {
@ -404,7 +407,10 @@ class ConferenceViewModel
Log.e( Log.e(
"$TAG Failed to parse SIP URI [$uri] into address, can't add it to the conference!" "$TAG Failed to parse SIP URI [$uri] into address, can't add it to the conference!"
) )
showRedToast(R.string.conference_failed_to_add_participant_invalid_address_toast, R.drawable.warning_circle) showRedToast(
R.string.conference_failed_to_add_participant_invalid_address_toast,
R.drawable.warning_circle
)
} }
} }
val addressesArray = arrayOfNulls<Address>(addresses.size) val addressesArray = arrayOfNulls<Address>(addresses.size)
@ -413,9 +419,11 @@ class ConferenceViewModel
conference.addParticipants(addressesArray) conference.addParticipants(addressesArray)
} }
} }
}
@WorkerThread @WorkerThread
fun kickParticipant(participant: Participant) { fun kickParticipant(participant: Participant) {
if (::conference.isInitialized) {
coreContext.postOnCoreThread { coreContext.postOnCoreThread {
Log.i( Log.i(
"$TAG Kicking participant [${participant.address.asStringUriOnly()}] out of conference" "$TAG Kicking participant [${participant.address.asStringUriOnly()}] out of conference"
@ -423,9 +431,11 @@ class ConferenceViewModel
conference.removeParticipant(participant) conference.removeParticipant(participant)
} }
} }
}
@WorkerThread @WorkerThread
fun setNewLayout(newLayout: Int) { fun setNewLayout(newLayout: Int) {
if (::conference.isInitialized) {
val call = conference.call val call = conference.call
if (call != null) { if (call != null) {
val params = call.core.createCallParams(call) val params = call.core.createCallParams(call)
@ -437,10 +447,12 @@ class ConferenceViewModel
Log.i("$TAG Changing conference layout to [Audio Only]") Log.i("$TAG Changing conference layout to [Audio Only]")
params.isVideoEnabled = false params.isVideoEnabled = false
} }
ACTIVE_SPEAKER_LAYOUT -> { ACTIVE_SPEAKER_LAYOUT -> {
Log.i("$TAG Changing conference layout to [Active Speaker]") Log.i("$TAG Changing conference layout to [Active Speaker]")
params.conferenceVideoLayout = Conference.Layout.ActiveSpeaker params.conferenceVideoLayout = Conference.Layout.ActiveSpeaker
} }
GRID_LAYOUT -> { GRID_LAYOUT -> {
Log.i("$TAG Changing conference layout to [Grid]") Log.i("$TAG Changing conference layout to [Grid]")
params.conferenceVideoLayout = Conference.Layout.Grid params.conferenceVideoLayout = Conference.Layout.Grid
@ -471,6 +483,7 @@ class ConferenceViewModel
Log.e("$TAG Failed to get call from conference, aborting layout change") Log.e("$TAG Failed to get call from conference, aborting layout change")
} }
} }
}
@WorkerThread @WorkerThread
private fun getCurrentLayout(call: Call): Int { private fun getCurrentLayout(call: Call): Int {
@ -691,6 +704,7 @@ class ConferenceViewModel
@WorkerThread @WorkerThread
private fun addParticipant(participant: Participant) { private fun addParticipant(participant: Participant) {
if (::conference.isInitialized) {
val list = arrayListOf<ConferenceParticipantModel>() val list = arrayListOf<ConferenceParticipantModel>()
list.addAll(participants.value.orEmpty()) list.addAll(participants.value.orEmpty())
@ -722,6 +736,7 @@ class ConferenceViewModel
) )
) )
} }
}
@WorkerThread @WorkerThread
private fun addParticipantDevice(participantDevice: ParticipantDevice) { private fun addParticipantDevice(participantDevice: ParticipantDevice) {