aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/entities/Conversation.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/entities/Conversation.java')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java45
1 files changed, 31 insertions, 14 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index fe89009d3..cc995a30b 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -165,47 +165,61 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
}
public void findWaitingMessages(OnMessageFound onMessageFound) {
+ final ArrayList<Message> results = new ArrayList<>();
synchronized (this.messages) {
for (Message message : this.messages) {
if (message.getStatus() == Message.STATUS_WAITING) {
- onMessageFound.onMessageFound(message);
+ results.add(message);
}
}
}
+ for (Message result : results) {
+ onMessageFound.onMessageFound(result);
+ }
}
public void findUnreadMessages(OnMessageFound onMessageFound) {
+ final ArrayList<Message> results = new ArrayList<>();
synchronized (this.messages) {
for (Message message : this.messages) {
if (!message.isRead()) {
- onMessageFound.onMessageFound(message);
+ results.add(message);
}
}
}
+ for (Message result : results) {
+ onMessageFound.onMessageFound(result);
+ }
}
public void findMessagesWithFiles(final OnMessageFound onMessageFound) {
+ final ArrayList<Message> results = new ArrayList<>();
synchronized (this.messages) {
- for (final Message message : this.messages) {
- if ((message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE)
- && message.getEncryption() != Message.ENCRYPTION_PGP) {
- onMessageFound.onMessageFound(message);
+ for (final Message m : this.messages) {
+ if (m.isFileOrImage() && m.getEncryption() != Message.ENCRYPTION_PGP) {
+ results.add(m);
}
}
}
+ for (Message result : results) {
+ onMessageFound.onMessageFound(result);
+ }
}
public void findFailedMessagesWithFiles(final OnMessageFound onMessageFound) {
+ final ArrayList<Message> results = new ArrayList<>();
synchronized (this.messages) {
- for (final Message message : this.messages) {
- if ((message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE)
- && message.getEncryption() != Message.ENCRYPTION_PGP) {
- if (message.getStatus() == Message.STATUS_SEND_FAILED && !message.isDeleted() && message.needsUploading()) {
- onMessageFound.onMessageFound(message);
+ for (final Message m : this.messages) {
+ if (m.isFileOrImage() && m.getEncryption() != Message.ENCRYPTION_PGP) {
+ if (m.getStatus() == Message.STATUS_SEND_FAILED && !m.isDeleted() && m.needsUploading()) {
+ results.add(m);
}
}
}
}
+ for(Message result : results) {
+ onMessageFound.onMessageFound(result);
+ }
}
public Message findMessageWithFileAndUuid(final String uuid) {
@@ -281,14 +295,17 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
}
public void findUnsentTextMessages(OnMessageFound onMessageFound) {
+ final ArrayList<Message> results = new ArrayList<>();
synchronized (this.messages) {
for (Message message : this.messages) {
- if (message.getType() != Message.TYPE_IMAGE
- && message.getStatus() == Message.STATUS_UNSEND) {
- onMessageFound.onMessageFound(message);
+ if (message.getType() != Message.TYPE_IMAGE && message.getStatus() == Message.STATUS_UNSEND) {
+ results.add(message);
}
}
}
+ for(Message result : results) {
+ onMessageFound.onMessageFound(result);
+ }
}
public Message findSentMessageWithUuidOrRemoteId(String id) {