Skip to content

Instantly share code, notes, and snippets.

@Dima564
Last active November 1, 2016 11:33
Show Gist options
  • Save Dima564/61c0f0e71932250f2d608abb28a42fab to your computer and use it in GitHub Desktop.
Save Dima564/61c0f0e71932250f2d608abb28a42fab to your computer and use it in GitHub Desktop.
private fun getUnreadCountFromUsers() {
val conversations = datasource.getConversations()
var count = 0
for (conversation in conversations) {
if (conversation.recipientId != null) {
for (message in conversation.messages) {
if (message.unread) {
count += 1
}
}
}
}
}
private fun getNumberOfUnreadAttachmentsInGroupConversations() {
val conversations = datasource.getConversations()
var count = 0
for (conversation in conversations) {
if (conversation.groupId != null) {
for (message in conversation.messages) {
if (message.unread && message.type == MessageType.ATTACHMENT) {
count += 1
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment