Replace 'List.get(i)' with iterator to loop over list

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-08-29 19:30:01 +02:00
parent 62fa8c9645
commit f10d74f0ed
No known key found for this signature in database
GPG Key ID: FECE3A7222C52A4E

View File

@ -1707,8 +1707,8 @@ public class CallActivity extends CallBaseActivity {
}
}
for (int i = 0; i < peerConnectionWrapperList.size(); i++) {
endPeerConnection(peerConnectionWrapperList.get(i).getSessionId(), false);
for (PeerConnectionWrapper wrapper : peerConnectionWrapperList) {
endPeerConnection(wrapper.getSessionId(), false);
}
if (localStream != null) {
@ -1887,10 +1887,10 @@ public class CallActivity extends CallBaseActivity {
}
private PeerConnectionWrapper getPeerConnectionWrapperForSessionIdAndType(String sessionId, String type) {
for (int i = 0; i < peerConnectionWrapperList.size(); i++) {
if (peerConnectionWrapperList.get(i).getSessionId().equals(sessionId)
&& peerConnectionWrapperList.get(i).getVideoStreamType().equals(type)) {
return peerConnectionWrapperList.get(i);
for (PeerConnectionWrapper wrapper : peerConnectionWrapperList) {
if (wrapper.getSessionId().equals(sessionId)
&& wrapper.getVideoStreamType().equals(type)) {
return wrapper;
}
}
@ -1980,10 +1980,8 @@ public class CallActivity extends CallBaseActivity {
private void endPeerConnection(String sessionId, boolean justScreen) {
List<PeerConnectionWrapper> peerConnectionWrappers;
PeerConnectionWrapper peerConnectionWrapper;
if (!(peerConnectionWrappers = getPeerConnectionWrapperListForSessionId(sessionId)).isEmpty()) {
for (int i = 0; i < peerConnectionWrappers.size(); i++) {
peerConnectionWrapper = peerConnectionWrappers.get(i);
for (PeerConnectionWrapper peerConnectionWrapper : peerConnectionWrappers) {
if (peerConnectionWrapper.getSessionId().equals(sessionId)) {
if (VIDEO_STREAM_TYPE_SCREEN.equals(peerConnectionWrapper.getVideoStreamType()) || !justScreen) {
runOnUiThread(() -> removeMediaStream(sessionId));
@ -2104,10 +2102,8 @@ public class CallActivity extends CallBaseActivity {
nickChangedPayload.put("userid", conversationUser.getUserId());
nickChangedPayload.put("name", conversationUser.getDisplayName());
dataChannelMessage.setPayload(nickChangedPayload);
final PeerConnectionWrapper peerConnectionWrapper;
for (int i = 0; i < peerConnectionWrapperList.size(); i++) {
if (peerConnectionWrapperList.get(i).isMCUPublisher()) {
peerConnectionWrapper = peerConnectionWrapperList.get(i);
for (PeerConnectionWrapper peerConnectionWrapper : peerConnectionWrapperList) {
if (peerConnectionWrapper.isMCUPublisher()) {
Observable
.interval(1, TimeUnit.SECONDS)
.repeatUntil(() -> (!isConnectionEstablished() || isDestroyed()))