@Override public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long l) { if (conversations != null && conversations.size() > 0) { Conversation conversation = conversations.get(pos); BroadcastService.currentConversationId = conversation.getId(); if (onSelected) { currentConversationId = conversation.getId(); if (messageList != null) { messageList.clear(); } downloadConversation = new DownloadConversation(recyclerView, true, 1, 0, 0, contact, channel, conversation.getId()); downloadConversation.execute(); } } }
public void updateConversation(Conversation conversation) { try { ContentValues contentValues = prepareConversationValue(conversation); dbHelper.getWritableDatabase().update(MobiComDatabaseHelper.CONVERSATION, contentValues, MobiComDatabaseHelper.KEY + "=?", new String[]{String.valueOf(conversation.getId())}); } catch (Exception e) { e.printStackTrace(); } }
public Integer isConversationExit(String userId, String topicId) { Conversation conversation = null; SQLiteDatabase database = dbHelper.getReadableDatabase(); String conversationParameters = ""; List<String> structuredNameParamsList = new ArrayList<>(); conversationParameters += "userId = ? "; structuredNameParamsList.add(userId); conversationParameters += " and topicId = ? "; structuredNameParamsList.add(topicId); Cursor cursor = database.query(MobiComDatabaseHelper.CONVERSATION, null, conversationParameters, structuredNameParamsList.toArray(new String[structuredNameParamsList.size()]), null, null, null); if (cursor.moveToFirst()) { conversation = getConversation(cursor); cursor.close(); return conversation.getId(); } if (cursor != null) { cursor.close(); } return null; }
public synchronized void addConversation(Conversation conversation) { if (conversation != null) { if (conversationDatabaseService.isConversationPresent(conversation.getId())) { conversationDatabaseService.updateConversation(conversation); } else { conversationDatabaseService.addConversation(conversation); } } }
public ContentValues prepareConversationValue(Conversation conversation) { ContentValues contentValues = new ContentValues(); if (conversation != null) { if (conversation.getId() != null) { contentValues.put(MobiComDatabaseHelper.KEY, conversation.getId()); } if (!TextUtils.isEmpty(conversation.getTopicId())) { contentValues.put(MobiComDatabaseHelper.TOPIC_ID, conversation.getTopicId()); } if (conversation.getGroupId() != null) { contentValues.put(MobiComDatabaseHelper.CHANNEL_KEY, conversation.getGroupId()); } if (!TextUtils.isEmpty(conversation.getUserId())) { contentValues.put(MobiComDatabaseHelper.USERID, conversation.getUserId()); } if (!TextUtils.isEmpty(conversation.getTopicDetail())) { contentValues.put(MobiComDatabaseHelper.TOPIC_DETAIL, conversation.getTopicDetail()); } if (!TextUtils.isEmpty(conversation.getTopicLocalImageUri())) { contentValues.put(MobiComDatabaseHelper.TOPIC_LOCAL_IMAGE_URL, conversation.getTopicLocalImageUri()); } } return contentValues; }
public Bitmap loadMessageImage(Context context, Conversation conversation) { try { if (conversation == null) { return null; } Bitmap attachedImage = ImageUtils.getBitMapFromLocalPath(conversation.getTopicLocalImageUri()); if (attachedImage != null) { return attachedImage; } Bitmap bitmap = downloadProductImage(conversation); if (bitmap != null) { File file = FileClientService.getFilePath("topic_" + conversation.getId(), context.getApplicationContext(), "image", true); String imageLocalPath = ImageUtils.saveImageToInternalStorage(file, bitmap); conversation.setTopicLocalImageUri(imageLocalPath); } if (!TextUtils.isEmpty(conversation.getTopicLocalImageUri())) { ConversationService.getInstance(context).updateTopicLocalImageUri(conversation.getTopicLocalImageUri(), conversation.getId()); } return bitmap; } catch (Exception e) { } return null; }
public synchronized Integer createConversation(Conversation conversation) { ChannelFeed channelFeed = conversationClientService.createConversation(conversation); if (channelFeed != null) { if (conversation.getSupportIds() != null) { ChannelFeed[] channelFeeds = new ChannelFeed[1]; channelFeeds[0] = channelFeed; ChannelService.getInstance(context).processChannelFeedList(channelFeeds, false); ; } if (channelFeed.getConversationPxy() != null) { addConversation(channelFeed.getConversationPxy()); return channelFeed.getConversationPxy().getId(); } } return null; }
public synchronized void processConversationArray(Conversation[] conversations, Channel channel, Contact contact) { if (conversations != null && conversations.length > 0) { for (Conversation conversation : conversations) { if (channel != null) { conversation.setGroupId(channel.getKey()); } else if (contact != null) { conversation.setUserId(contact.getUserId()); conversation.setGroupId(0); } if (conversationDatabaseService.isConversationPresent(conversation.getId())) { conversationDatabaseService.updateConversation(conversation); } else { conversationDatabaseService.addConversation(conversation); } } } }