public Channel getChannel(Integer channelKey) { Channel channel = channelDatabaseService.getChannelByChannelKey(channelKey); if (channel == null) { channel = new Channel(channelKey); } return channel; }
public static Channel fetchGroup(Context context, Integer groupId, String groupName) { Channel channel = new Channel(groupId, groupName); String where = ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID + "=" + groupId + " AND " + ContactsContract.CommonDataKinds.GroupMembership.MIMETYPE + "='" + ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE + "'"; String[] projection = new String[]{ContactsContract.CommonDataKinds.GroupMembership.CONTACT_ID, ContactsContract.Data.DISPLAY_NAME}; Cursor cursor = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI, projection, where, null, ContactsContract.Data.DISPLAY_NAME + " COLLATE LOCALIZED ASC"); while (cursor.moveToNext()) { channel.getContacts().add(ContactUtils.getContact(context, cursor.getLong(cursor.getColumnIndex(ContactsContract.CommonDataKinds.GroupMembership.CONTACT_ID)))); } cursor.close(); return channel; }
public Channel getChannel(Cursor cursor) { Channel channel = new Channel(); channel.setKey(cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_KEY))); channel.setParentClientGroupId(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.PARENT_CLIENT_GROUP_ID))); channel.setClientGroupId(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.CLIENT_GROUP_ID))); channel.setName(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_DISPLAY_NAME))); channel.setAdminKey(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.ADMIN_ID))); channel.setType(cursor.getShort(cursor.getColumnIndex(MobiComDatabaseHelper.TYPE))); channel.setImageUrl(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_IMAGE_URL))); channel.setLocalImageUri(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_IMAGE_LOCAL_URI))); int count = cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.UNREAD_COUNT)); channel.setNotificationAfterTime(cursor.getLong(cursor.getColumnIndex(MobiComDatabaseHelper.NOTIFICATION_AFTER_TIME))); channel.setDeletedAtTime(cursor.getLong(cursor.getColumnIndex(MobiComDatabaseHelper.DELETED_AT))); channel.setParentKey(cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.PARENT_GROUP_KEY))); String metadata = cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_META_DATA)); channel.setMetadata(((Map<String, String>) GsonUtils.getObjectFromJson(metadata, Map.class))); if (count > 0) { channel.setUnreadCount(count); } return channel; }
@Test public void testDeleteSync_withChannel_returnSuccess() { try { Channel channel = new Channel(); channel.setKey(000); when(messageClientService.syncDeleteConversationThreadFromServer(null, channel)).thenReturn("success"); assertEquals("success", mobiComConversationService.deleteSync(null, channel, null)); Mockito.verify(messageDatabaseService, Mockito.times(1)).deleteChannelConversation(anyInt()); } catch (Exception e) { e.printStackTrace(); } }
channel = new Channel(message.getGroupId()); } else { contact = new Contact(message.getContactIds());
channel = new Channel(message.getGroupId()); } else { contact = new Contact(message.getContactIds());
public Channel getChannel(ChannelFeed channelFeed) { Channel channel = new Channel(channelFeed.getId(), channelFeed.getName(), channelFeed .getAdminName(), channelFeed.getType(), channelFeed.getUnreadCount(), channelFeed .getImageUrl()); channel.setClientGroupId(channelFeed.getClientGroupId()); channel.setNotificationAfterTime(channelFeed.getNotificationAfterTime()); channel.setDeletedAtTime(channelFeed.getDeletedAtTime()); channel.setMetadata(channelFeed.getMetadata()); channel.setParentKey(channelFeed.getParentKey()); channel.setParentClientGroupId(channelFeed.getParentClientGroupId()); return channel; }