aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-10-21 23:59:02 +0200
committeriNPUTmice <daniel@gultsch.de>2014-10-21 23:59:02 +0200
commit40c74b432ed5151538fd50218a19e6973524d98e (patch)
tree0c2c778181fed74147afe69f5148c7d4aa8f529a /src/eu
parent63704b114c858e45cbbd765e713f6fea76fd1595 (diff)
made iterating over hashmap in notification service thread safe
Diffstat (limited to 'src/eu')
-rw-r--r--src/eu/siacs/conversations/services/NotificationService.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/eu/siacs/conversations/services/NotificationService.java b/src/eu/siacs/conversations/services/NotificationService.java
index 8eba49a9..7a116ed4 100644
--- a/src/eu/siacs/conversations/services/NotificationService.java
+++ b/src/eu/siacs/conversations/services/NotificationService.java
@@ -1,7 +1,9 @@
package eu.siacs.conversations.services;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -130,7 +132,11 @@ public class NotificationService {
.getString(R.string.unread_conversations));
StringBuilder names = new StringBuilder();
Conversation conversation = null;
- for (ArrayList<Message> messages : notifications.values()) {
+ Iterator<Entry<String, ArrayList<Message>>> it = notifications
+ .entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, ArrayList<Message>> entry = it.next();
+ ArrayList<Message> messages = entry.getValue();
if (messages.size() > 0) {
conversation = messages.get(0).getConversation();
String name = conversation.getName();
@@ -142,6 +148,7 @@ public class NotificationService {
names.append(name);
names.append(", ");
}
+ it.remove();
}
if (names.length() >= 2) {
names.delete(names.length() - 2, names.length());