mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Add "reaction" event to CallParticipantModel observer
The CallParticipantModel observer now also emits one-time events that are not reflected in the model state. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
0a54fd6127
commit
92d655080d
@ -2861,6 +2861,10 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
addParticipantDisplayItem(callParticipantModel, "screen");
|
addParticipantDisplayItem(callParticipantModel, "screen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReaction(String reaction) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class InternalSignalingMessageSender implements SignalingMessageSender {
|
private class InternalSignalingMessageSender implements SignalingMessageSender {
|
||||||
|
@ -34,7 +34,16 @@ public class ParticipantDisplayItem {
|
|||||||
|
|
||||||
private final CallParticipantModel callParticipantModel;
|
private final CallParticipantModel callParticipantModel;
|
||||||
|
|
||||||
private final CallParticipantModel.Observer callParticipantModelObserver = this::updateFromModel;
|
private final CallParticipantModel.Observer callParticipantModelObserver = new CallParticipantModel.Observer() {
|
||||||
|
@Override
|
||||||
|
public void onChange() {
|
||||||
|
updateFromModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReaction(String reaction) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private String userId;
|
private String userId;
|
||||||
private PeerConnection.IceConnectionState iceConnectionState;
|
private PeerConnection.IceConnectionState iceConnectionState;
|
||||||
|
@ -42,6 +42,7 @@ public class CallParticipant {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReaction(String reaction) {
|
public void onReaction(String reaction) {
|
||||||
|
callParticipantModel.emitReaction(reaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,11 +42,15 @@ import java.util.Objects;
|
|||||||
* Getters called after receiving a notification are guaranteed to provide at least the value that triggered the
|
* Getters called after receiving a notification are guaranteed to provide at least the value that triggered the
|
||||||
* notification, but it may return even a more up to date one (so getting the value again on the following
|
* notification, but it may return even a more up to date one (so getting the value again on the following
|
||||||
* notification may return the same value as before).
|
* notification may return the same value as before).
|
||||||
|
*
|
||||||
|
* Besides onChange(), which notifies about changes in the model values, CallParticipantModel.Observer provides
|
||||||
|
* additional methods to be notified about one-time events that are not reflected in the model values, like reactions.
|
||||||
*/
|
*/
|
||||||
public class CallParticipantModel {
|
public class CallParticipantModel {
|
||||||
|
|
||||||
public interface Observer {
|
public interface Observer {
|
||||||
void onChange();
|
void onChange();
|
||||||
|
void onReaction(String reaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class Data<T> {
|
protected class Data<T> {
|
||||||
@ -68,7 +72,7 @@ public class CallParticipantModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final CallParticipantModelNotifier callParticipantModelNotifier = new CallParticipantModelNotifier();
|
protected final CallParticipantModelNotifier callParticipantModelNotifier = new CallParticipantModelNotifier();
|
||||||
|
|
||||||
protected final String sessionId;
|
protected final String sessionId;
|
||||||
|
|
||||||
|
@ -83,4 +83,16 @@ class CallParticipantModelNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void notifyReaction(String reaction) {
|
||||||
|
for (CallParticipantModelObserverOn observerOn : new ArrayList<>(callParticipantModelObserversOn)) {
|
||||||
|
if (observerOn.handler == null || observerOn.handler.getLooper() == Looper.myLooper()) {
|
||||||
|
observerOn.observer.onReaction(reaction);
|
||||||
|
} else {
|
||||||
|
observerOn.handler.post(() -> {
|
||||||
|
observerOn.observer.onReaction(reaction);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,4 +72,8 @@ public class MutableCallParticipantModel extends CallParticipantModel {
|
|||||||
public void setScreenMediaStream(MediaStream screenMediaStream) {
|
public void setScreenMediaStream(MediaStream screenMediaStream) {
|
||||||
this.screenMediaStream.setValue(screenMediaStream);
|
this.screenMediaStream.setValue(screenMediaStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void emitReaction(String reaction) {
|
||||||
|
this.callParticipantModelNotifier.notifyReaction(reaction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,4 +55,11 @@ class CallParticipantModelTest {
|
|||||||
callParticipantModel!!.setRaisedHand(true, 4815162342L)
|
callParticipantModel!!.setRaisedHand(true, 4815162342L)
|
||||||
Mockito.verify(mockedCallParticipantModelObserver, Mockito.only())?.onChange()
|
Mockito.verify(mockedCallParticipantModelObserver, Mockito.only())?.onChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testEmitReaction() {
|
||||||
|
callParticipantModel!!.addObserver(mockedCallParticipantModelObserver)
|
||||||
|
callParticipantModel!!.emitReaction("theReaction")
|
||||||
|
Mockito.verify(mockedCallParticipantModelObserver, Mockito.only())?.onReaction("theReaction")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user