From 1e0bc51fa20758f566cd70f3fcbf67b967f2d094 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 11 Sep 2020 17:09:30 +0200 Subject: [PATCH] Remove singletin instance from callback param --- .../app/features/call/VectorCallViewModel.kt | 18 +++++++++--------- .../call/WebRtcPeerConnectionManager.kt | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt b/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt index e87e7b10d2..edb75441c8 100644 --- a/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt @@ -90,17 +90,17 @@ class VectorCallViewModel @AssistedInject constructor( override fun onCurrentCallChange(call: MxCall?) { } - override fun onCaptureStateChanged(mgr: WebRtcPeerConnectionManager) { + override fun onCaptureStateChanged() { setState { copy( - isVideoCaptureInError = mgr.capturerIsInError, - isHD = mgr.currentCaptureFormat() is CaptureFormat.HD + isVideoCaptureInError = webRtcPeerConnectionManager.capturerIsInError, + isHD = webRtcPeerConnectionManager.currentCaptureFormat() is CaptureFormat.HD ) } } - override fun onAudioDevicesChange(mgr: WebRtcPeerConnectionManager) { - val currentSoundDevice = mgr.callAudioManager.getCurrentSoundDevice() + override fun onAudioDevicesChange() { + val currentSoundDevice = webRtcPeerConnectionManager.callAudioManager.getCurrentSoundDevice() if (currentSoundDevice == CallAudioManager.SoundDevice.PHONE) { proximityManager.start() } else { @@ -109,17 +109,17 @@ class VectorCallViewModel @AssistedInject constructor( setState { copy( - availableSoundDevices = mgr.callAudioManager.getAvailableSoundDevices(), + availableSoundDevices = webRtcPeerConnectionManager.callAudioManager.getAvailableSoundDevices(), soundDevice = currentSoundDevice ) } } - override fun onCameraChange(mgr: WebRtcPeerConnectionManager) { + override fun onCameraChange() { setState { copy( - canSwitchCamera = mgr.canSwitchCamera(), - isFrontCamera = mgr.currentCameraType() == CameraType.FRONT + canSwitchCamera = webRtcPeerConnectionManager.canSwitchCamera(), + isFrontCamera = webRtcPeerConnectionManager.currentCameraType() == CameraType.FRONT ) } } diff --git a/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt b/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt index 916df8892b..c47ec4e35a 100644 --- a/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt +++ b/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt @@ -79,9 +79,9 @@ class WebRtcPeerConnectionManager @Inject constructor( interface CurrentCallListener { fun onCurrentCallChange(call: MxCall?) - fun onCaptureStateChanged(mgr: WebRtcPeerConnectionManager) {} - fun onAudioDevicesChange(mgr: WebRtcPeerConnectionManager) {} - fun onCameraChange(mgr: WebRtcPeerConnectionManager) {} + fun onCaptureStateChanged() {} + fun onAudioDevicesChange() {} + fun onCameraChange() {} } private val currentCallsListeners = emptyList().toMutableList() @@ -95,7 +95,7 @@ class WebRtcPeerConnectionManager @Inject constructor( val callAudioManager = CallAudioManager(context.applicationContext) { currentCallsListeners.forEach { - tryThis { it.onAudioDevicesChange(this) } + tryThis { it.onAudioDevicesChange() } } } @@ -174,7 +174,7 @@ class WebRtcPeerConnectionManager @Inject constructor( set(value) { field = value currentCallsListeners.forEach { - tryThis { it.onCaptureStateChanged(this) } + tryThis { it.onCaptureStateChanged() } } } @@ -741,7 +741,7 @@ class WebRtcPeerConnectionManager @Inject constructor( Timber.v("## VOIP onCameraSwitchDone isFront $isFrontCamera") cameraInUse = availableCamera.first { if (isFrontCamera) it.type == CameraType.FRONT else it.type == CameraType.BACK } currentCallsListeners.forEach { - tryThis { it.onCameraChange(this@WebRtcPeerConnectionManager) } + tryThis { it.onCameraChange() } } } @@ -767,7 +767,7 @@ class WebRtcPeerConnectionManager @Inject constructor( // videoCapturer?.stopCapture() videoCapturer?.changeCaptureFormat(format.width, format.height, format.fps) currentCaptureMode = format - currentCallsListeners.forEach { tryThis { it.onCaptureStateChanged(this) } } + currentCallsListeners.forEach { tryThis { it.onCaptureStateChanged() } } } }