synchronization for notification
This commit is contained in:
parent
1428628a5d
commit
f063b1c063
|
@ -43,15 +43,16 @@ public class NotificationService {
|
|||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
||||
public synchronized void push(Message message) {
|
||||
|
||||
public void push(Message message) {
|
||||
PowerManager pm = (PowerManager) mXmppConnectionService
|
||||
.getSystemService(Context.POWER_SERVICE);
|
||||
boolean isScreenOn = pm.isScreenOn();
|
||||
|
||||
if (this.mIsInForeground && isScreenOn
|
||||
&& this.mOpenConversation == message.getConversation()) {
|
||||
return;
|
||||
}
|
||||
synchronized (notifications) {
|
||||
String conversationUuid = message.getConversationUuid();
|
||||
if (notifications.containsKey(conversationUuid)) {
|
||||
notifications.get(conversationUuid).add(message);
|
||||
|
@ -60,17 +61,22 @@ public class NotificationService {
|
|||
mList.add(message);
|
||||
notifications.put(conversationUuid, mList);
|
||||
}
|
||||
}
|
||||
updateNotification((!(this.mIsInForeground && this.mOpenConversation == null) || !isScreenOn)
|
||||
&& !inGracePeriod());
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
synchronized (notifications) {
|
||||
notifications.clear();
|
||||
}
|
||||
updateNotification(false);
|
||||
}
|
||||
|
||||
public void clear(Conversation conversation) {
|
||||
synchronized (notifications) {
|
||||
notifications.remove(conversation.getUuid());
|
||||
}
|
||||
updateNotification(false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue