Trying to ensure IncomingCallActivity is left when there is no more calls
This commit is contained in:
parent
00d5a780db
commit
1f6269e46d
1 changed files with 21 additions and 0 deletions
|
@ -25,6 +25,7 @@ import androidx.lifecycle.ViewModelProvider
|
|||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.core.*
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class IncomingCallViewModelFactory(private val call: Call) :
|
||||
ViewModelProvider.NewInstanceFactory() {
|
||||
|
@ -42,7 +43,22 @@ class IncomingCallViewModel(call: Call) : CallViewModel(call) {
|
|||
|
||||
val inviteWithVideo = MutableLiveData<Boolean>()
|
||||
|
||||
private val listener = object : CoreListenerStub() {
|
||||
override fun onCallStateChanged(
|
||||
core: Core,
|
||||
call: Call,
|
||||
state: Call.State,
|
||||
message: String
|
||||
) {
|
||||
if (core.callsNb == 0) {
|
||||
callEndedEvent.value = Event(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
coreContext.core.addListener(listener)
|
||||
|
||||
screenLocked.value = false
|
||||
inviteWithVideo.value = call.remoteParams?.videoEnabled()
|
||||
earlyMediaVideoEnabled.value = corePreferences.acceptEarlyMedia &&
|
||||
|
@ -50,6 +66,11 @@ class IncomingCallViewModel(call: Call) : CallViewModel(call) {
|
|||
call.currentParams.videoEnabled()
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
coreContext.core.removeListener(listener)
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
fun answer(doAction: Boolean) {
|
||||
if (doAction) coreContext.answerCall(call)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue