mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Extract methods to add and remove call participants
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
ed5e8fc82e
commit
2cb7572dbc
@ -1973,7 +1973,28 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
if (!publisher) {
|
if (!publisher) {
|
||||||
CallParticipant callParticipant = callParticipants.get(sessionId);
|
CallParticipant callParticipant = callParticipants.get(sessionId);
|
||||||
if (callParticipant == null) {
|
if (callParticipant == null) {
|
||||||
callParticipant = new CallParticipant(sessionId);
|
callParticipant = addCallParticipant(sessionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("screen".equals(type)) {
|
||||||
|
callParticipant.setScreenPeerConnectionWrapper(peerConnectionWrapper);
|
||||||
|
} else {
|
||||||
|
callParticipant.setPeerConnectionWrapper(peerConnectionWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (publisher) {
|
||||||
|
peerConnectionWrapper.addObserver(selfPeerConnectionObserver);
|
||||||
|
|
||||||
|
startSendingNick();
|
||||||
|
}
|
||||||
|
|
||||||
|
return peerConnectionWrapper;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CallParticipant addCallParticipant(String sessionId) {
|
||||||
|
CallParticipant callParticipant = new CallParticipant(sessionId);
|
||||||
callParticipants.put(sessionId, callParticipant);
|
callParticipants.put(sessionId, callParticipant);
|
||||||
|
|
||||||
SignalingMessageReceiver.CallParticipantMessageListener callParticipantMessageListener =
|
SignalingMessageReceiver.CallParticipantMessageListener callParticipantMessageListener =
|
||||||
@ -1998,23 +2019,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
addParticipantDisplayItem(callParticipantModel, "video");
|
addParticipantDisplayItem(callParticipantModel, "video");
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if ("screen".equals(type)) {
|
return callParticipant;
|
||||||
callParticipant.setScreenPeerConnectionWrapper(peerConnectionWrapper);
|
|
||||||
} else {
|
|
||||||
callParticipant.setPeerConnectionWrapper(peerConnectionWrapper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (publisher) {
|
|
||||||
peerConnectionWrapper.addObserver(selfPeerConnectionObserver);
|
|
||||||
|
|
||||||
startSendingNick();
|
|
||||||
}
|
|
||||||
|
|
||||||
return peerConnectionWrapper;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PeerConnectionWrapper> getPeerConnectionWrapperListForSessionId(String sessionId) {
|
private List<PeerConnectionWrapper> getPeerConnectionWrapperListForSessionId(String sessionId) {
|
||||||
@ -2055,8 +2061,16 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!justScreen) {
|
if (!justScreen) {
|
||||||
|
removeCallParticipant(sessionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeCallParticipant(String sessionId) {
|
||||||
CallParticipant callParticipant = callParticipants.remove(sessionId);
|
CallParticipant callParticipant = callParticipants.remove(sessionId);
|
||||||
if (callParticipant != null) {
|
if (callParticipant == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ScreenParticipantDisplayItemManager screenParticipantDisplayItemManager =
|
ScreenParticipantDisplayItemManager screenParticipantDisplayItemManager =
|
||||||
screenParticipantDisplayItemManagers.remove(sessionId);
|
screenParticipantDisplayItemManagers.remove(sessionId);
|
||||||
callParticipant.getCallParticipantModel().removeObserver(screenParticipantDisplayItemManager);
|
callParticipant.getCallParticipantModel().removeObserver(screenParticipantDisplayItemManager);
|
||||||
@ -2074,8 +2088,6 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
|
|
||||||
runOnUiThread(() -> removeParticipantDisplayItem(sessionId, "video"));
|
runOnUiThread(() -> removeParticipantDisplayItem(sessionId, "video"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeParticipantDisplayItem(String sessionId, String videoStreamType) {
|
private void removeParticipantDisplayItem(String sessionId, String videoStreamType) {
|
||||||
Log.d(TAG, "removeParticipantDisplayItem");
|
Log.d(TAG, "removeParticipantDisplayItem");
|
||||||
|
Loading…
Reference in New Issue
Block a user