Improved unread chat message count

This commit is contained in:
Sylvain Berfini 2018-11-12 17:39:37 +01:00
parent 9cf6769713
commit c20ebad33d
2 changed files with 3 additions and 11 deletions

View file

@ -1803,8 +1803,8 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
public int getUnreadMessageCount() { public int getUnreadMessageCount() {
int count = 0; int count = 0;
for (Integer unread : mUnreadChatsPerRoom.values()) { for (ChatRoom room : mLc.getChatRooms()) {
count += unread; count += room.getUnreadMessagesCount();
} }
return count; return count;
} }
@ -1819,14 +1819,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
updateUnreadCountForChatRoom(key, value); updateUnreadCountForChatRoom(key, value);
} }
public int getUnreadCountForChatRoom(ChatRoom cr) {
String key = cr.getPeerAddress().asStringUriOnly();
if (mUnreadChatsPerRoom.containsKey(key)) {
return mUnreadChatsPerRoom.get(key);
}
return 0;
}
private void increaseUnreadCountForChatRoom(ChatRoom cr) { private void increaseUnreadCountForChatRoom(ChatRoom cr) {
String key = cr.getPeerAddress().asStringUriOnly(); String key = cr.getPeerAddress().asStringUriOnly();
if (mUnreadChatsPerRoom.containsKey(key)) { if (mUnreadChatsPerRoom.containsKey(key)) {

View file

@ -101,7 +101,7 @@ public class ChatRoomViewHolder extends RecyclerView.ViewHolder implements View.
} }
displayName.setText(getContact(mRoom)); displayName.setText(getContact(mRoom));
unreadMessages.setText(String.valueOf(LinphoneManager.getInstance().getUnreadCountForChatRoom(mRoom))); unreadMessages.setText(String.valueOf(mRoom.getUnreadMessagesCount()));
getAvatar(mRoom); getAvatar(mRoom);
} }