public void read(Contact contact, Channel channel) { try { int unreadCount = 0; if (contact != null) { Contact newContact = baseContactService.getContactById(contact.getContactIds()); unreadCount = newContact.getUnreadCount(); messageDatabaseService.updateReadStatusForContact(contact.getContactIds()); } else if (channel != null) { Channel newChannel = channelService.getChannelByChannelKey(channel.getKey()); unreadCount = newChannel.getUnreadCount(); messageDatabaseService.updateReadStatusForChannel(String.valueOf(newChannel.getKey())); } Intent intent = new Intent(context, UserIntentService.class); intent.putExtra(UserIntentService.CONTACT, contact); intent.putExtra(UserIntentService.CHANNEL, channel); intent.putExtra(UserIntentService.UNREAD_COUNT, unreadCount); UserIntentService.enqueueWork(context, intent); } catch (Exception e) { } }
public static void markAsRead(Context context, String userId, Integer groupId) { try { int unreadCount = 0; Contact contact = null; Channel channel = null; if (userId != null) { contact = new AppContactService(context).getContactById(userId); unreadCount = contact.getUnreadCount(); new MessageDatabaseService(context).updateReadStatusForContact(userId); } else if (groupId != null && groupId != 0) { channel = ChannelService.getInstance(context).getChannelByChannelKey(groupId); unreadCount = channel.getUnreadCount(); new MessageDatabaseService(context).updateReadStatusForChannel(String.valueOf(groupId)); } Intent intent = new Intent(context, UserIntentService.class); intent.putExtra(UserIntentService.CONTACT, contact); intent.putExtra(UserIntentService.CHANNEL, channel); intent.putExtra(UserIntentService.UNREAD_COUNT, unreadCount); UserIntentService.enqueueWork(context, intent); } catch (Exception e) { } } }
contentValues.put(MobiComDatabaseHelper.USER_COUNT, channel.getUserCount()); if (channel.getUnreadCount() != 0) { contentValues.put(MobiComDatabaseHelper.UNREAD_COUNT, channel.getUnreadCount());
if (messageString.getGroupId() != null) { Channel unreadChannel = ChannelService.getInstance(context).getChannelByChannelKey(messageString.getGroupId()); if (unreadChannel != null && unreadChannel.getUnreadCount() == 0) { continue;