diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-05-26 12:00:38 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-05-26 12:00:38 +0200 |
commit | 6059ed47388c174db4d4eaa7e5d0b70e16dab6ac (patch) | |
tree | 5412b03e60c1efd68d4be320e73007be0f92e9fc /src/main | |
parent | 9debf8037b5def6c634d72042566fe63ab9e9ce1 (diff) |
update unread count badge only when necessary
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index ebb14669d..cfb2d50d7 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -227,7 +227,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa private final List<String> mInProgressAvatarFetches = new ArrayList<>(); private MessageArchiveService mMessageArchiveService = new MessageArchiveService(this); private OnConversationUpdate mOnConversationUpdate = null; - private Integer convChangedListenerCount = 0; + private int convChangedListenerCount = 0; + private int unreadCount = 0; private OnAccountUpdate mOnAccountUpdate = null; private OnStatusChanged statusListener = new OnStatusChanged() { @@ -2277,13 +2278,16 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa updateUnreadCountBadge(); } - public void updateUnreadCountBadge() { + public synchronized void updateUnreadCountBadge() { int count = unreadCount(); - Log.d(Config.LOGTAG, "update unread count to " + count); - if (count > 0) { - ShortcutBadger.with(getApplicationContext()).count(count); - } else { - ShortcutBadger.with(getApplicationContext()).remove(); + if (unreadCount != count) { + Log.d(Config.LOGTAG, "update unread count to " + count); + if (count > 0) { + ShortcutBadger.with(getApplicationContext()).count(count); + } else { + ShortcutBadger.with(getApplicationContext()).remove(); + } + unreadCount = count; } } |