Last active
January 20, 2020 12:41
-
-
Save NinoDLC/6a857e864ee12cff1c19522a9d33ff6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private List<MainUiModel> sortAndFilterMeetings( | |
@Nullable List<Meeting> meetings, | |
@Nullable Map<Room, Boolean> selectedRooms | |
) { | |
List<MainUiModel> result = new ArrayList<>(); | |
if (meetings == null || selectedRooms == null) { | |
return result; | |
} | |
for (Meeting meeting : meetings) { | |
boolean atLeastOneRoomIsSelected = false; | |
for (Map.Entry<Room, Boolean> entry : selectedRooms.entrySet()) { | |
Room room = entry.getKey(); | |
boolean isRoomSelected = entry.getValue() != null && entry.getValue(); | |
if (isRoomSelected) { | |
atLeastOneRoomIsSelected = true; | |
} | |
if (room == meeting.getRoom() && isRoomSelected) { | |
result.add(map(meeting)); | |
} | |
} | |
if (!atLeastOneRoomIsSelected) { | |
result.add(map(meeting)); | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment