mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 11:42:15 -05:00
made iterating over hashmap in notification service thread safe
This commit is contained in:
parent
63704b114c
commit
40c74b432e
@ -1,7 +1,9 @@
|
|||||||
package eu.siacs.conversations.services;
|
package eu.siacs.conversations.services;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -130,7 +132,11 @@ public class NotificationService {
|
|||||||
.getString(R.string.unread_conversations));
|
.getString(R.string.unread_conversations));
|
||||||
StringBuilder names = new StringBuilder();
|
StringBuilder names = new StringBuilder();
|
||||||
Conversation conversation = null;
|
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) {
|
if (messages.size() > 0) {
|
||||||
conversation = messages.get(0).getConversation();
|
conversation = messages.get(0).getConversation();
|
||||||
String name = conversation.getName();
|
String name = conversation.getName();
|
||||||
@ -142,6 +148,7 @@ public class NotificationService {
|
|||||||
names.append(name);
|
names.append(name);
|
||||||
names.append(", ");
|
names.append(", ");
|
||||||
}
|
}
|
||||||
|
it.remove();
|
||||||
}
|
}
|
||||||
if (names.length() >= 2) {
|
if (names.length() >= 2) {
|
||||||
names.delete(names.length() - 2, names.length());
|
names.delete(names.length() - 2, names.length());
|
||||||
|
Loading…
Reference in New Issue
Block a user