Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<Integer> storeDialogs(List<Dialog> newDialogs)
- {
- boolean dialogsUpdated = false;
- List<Integer> updatedIds = new ArrayList<Integer>();
- for (Dialog oldDialog : this.dialogs)
- {
- for (Dialog newDialog : newDialogs)
- {
- if (newDialog.equals(oldDialog) && newDialog.getUpdatedAt().compareTo(oldDialog.getUpdatedAt()) > 0)
- {
- dialogsUpdated = true;
- updatedIds.add(newDialog.getUser().getId());
- }
- }
- }
- if (dialogsUpdated)
- {
- Set<Dialog> dialogsSet = new HashSet<Dialog>(this.dialogs);
- dialogsSet.removeAll(newDialogs);
- dialogsSet.addAll(newDialogs);
- setDialogs(new ArrayList<Dialog>(dialogsSet));
- }
- else if (this.dialogs.size() == 0)
- {
- setDialogs(newDialogs);
- }
- return updatedIds;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement