Search in sources :

Example 6 with OptionalLong

use of com.annimon.stream.OptionalLong in project Lightweight-Stream-API by aNNiMON.

the class OptionalLongMatcherTest method testIsPresent.

@Test
public void testIsPresent() {
    OptionalLong optional = OptionalLong.of(5L);
    assertThat(optional, isPresent());
    assertThat(optional, not(isEmpty()));
    assertThat(isPresent(), description(is("OptionalLong value should be present")));
}
Also used : OptionalLong(com.annimon.stream.OptionalLong) Test(org.junit.Test)

Example 7 with OptionalLong

use of com.annimon.stream.OptionalLong in project Signal-Android by WhisperSystems.

the class CallParticipantsListDialog method updateList.

private void updateList(@NonNull CallParticipantsState callParticipantsState) {
    List<MappingModel<?>> items = new ArrayList<>();
    boolean includeSelf = callParticipantsState.getGroupCallState() == WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED;
    OptionalLong headerCount = callParticipantsState.getParticipantCount();
    headerCount.executeIfPresent(count -> {
        items.add(new CallParticipantsListHeader((int) count));
        if (includeSelf) {
            items.add(new CallParticipantViewState(callParticipantsState.getLocalParticipant()));
        }
        for (CallParticipant callParticipant : callParticipantsState.getAllRemoteParticipants()) {
            items.add(new CallParticipantViewState(callParticipant));
        }
    });
    adapter.submitList(items);
}
Also used : CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) ArrayList(java.util.ArrayList) OptionalLong(com.annimon.stream.OptionalLong) MappingModel(org.thoughtcrime.securesms.util.adapter.mapping.MappingModel)

Example 8 with OptionalLong

use of com.annimon.stream.OptionalLong in project Signal-Android by signalapp.

the class CallParticipantsListDialog method updateList.

private void updateList(@NonNull CallParticipantsState callParticipantsState) {
    List<MappingModel<?>> items = new ArrayList<>();
    boolean includeSelf = callParticipantsState.getGroupCallState() == WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED;
    OptionalLong headerCount = callParticipantsState.getParticipantCount();
    headerCount.executeIfPresent(count -> {
        items.add(new CallParticipantsListHeader((int) count));
        if (includeSelf) {
            items.add(new CallParticipantViewState(callParticipantsState.getLocalParticipant()));
        }
        for (CallParticipant callParticipant : callParticipantsState.getAllRemoteParticipants()) {
            items.add(new CallParticipantViewState(callParticipant));
        }
    });
    adapter.submitList(items);
}
Also used : CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) ArrayList(java.util.ArrayList) OptionalLong(com.annimon.stream.OptionalLong) MappingModel(org.thoughtcrime.securesms.util.adapter.mapping.MappingModel)

Aggregations

OptionalLong (com.annimon.stream.OptionalLong)8 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)2 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)2 MappingModel (org.thoughtcrime.securesms.util.adapter.mapping.MappingModel)2