update unread count badge only when necessary
This commit is contained in:
parent
9debf8037b
commit
6059ed4738
|
@ -227,7 +227,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
private final List<String> mInProgressAvatarFetches = new ArrayList<>();
|
private final List<String> mInProgressAvatarFetches = new ArrayList<>();
|
||||||
private MessageArchiveService mMessageArchiveService = new MessageArchiveService(this);
|
private MessageArchiveService mMessageArchiveService = new MessageArchiveService(this);
|
||||||
private OnConversationUpdate mOnConversationUpdate = null;
|
private OnConversationUpdate mOnConversationUpdate = null;
|
||||||
private Integer convChangedListenerCount = 0;
|
private int convChangedListenerCount = 0;
|
||||||
|
private int unreadCount = 0;
|
||||||
private OnAccountUpdate mOnAccountUpdate = null;
|
private OnAccountUpdate mOnAccountUpdate = null;
|
||||||
private OnStatusChanged statusListener = new OnStatusChanged() {
|
private OnStatusChanged statusListener = new OnStatusChanged() {
|
||||||
|
|
||||||
|
@ -2277,14 +2278,17 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
updateUnreadCountBadge();
|
updateUnreadCountBadge();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateUnreadCountBadge() {
|
public synchronized void updateUnreadCountBadge() {
|
||||||
int count = unreadCount();
|
int count = unreadCount();
|
||||||
|
if (unreadCount != count) {
|
||||||
Log.d(Config.LOGTAG, "update unread count to " + count);
|
Log.d(Config.LOGTAG, "update unread count to " + count);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
ShortcutBadger.with(getApplicationContext()).count(count);
|
ShortcutBadger.with(getApplicationContext()).count(count);
|
||||||
} else {
|
} else {
|
||||||
ShortcutBadger.with(getApplicationContext()).remove();
|
ShortcutBadger.with(getApplicationContext()).remove();
|
||||||
}
|
}
|
||||||
|
unreadCount = count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendReadMarker(final Conversation conversation) {
|
public void sendReadMarker(final Conversation conversation) {
|
||||||
|
|
Loading…
Reference in a new issue