public static Conversation getConversation(Cursor cursor) { Conversation conversation = new Conversation(); conversation.setId(cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.KEY))); conversation.setGroupId(cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_KEY))); String topicId = cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.TOPIC_ID)); if (!TextUtils.isEmpty(topicId)) { conversation.setTopicId(topicId); } String topicDetail = cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.TOPIC_DETAIL)); if (!TextUtils.isEmpty(topicDetail)) { conversation.setTopicDetail(topicDetail); } String userId = cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.USERID)); if (!TextUtils.isEmpty(userId)) { conversation.setUserId(userId); } conversation.setTopicLocalImageUri(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.TOPIC_LOCAL_IMAGE_URL))); return 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; }
@Override protected void onPreExecute() { super.onPreExecute(); if (conversation != null) { conversationId = conversationService.isConversationExist(conversation.getUserId(), conversation.getTopicId()); } }
private Conversation buildConversation() { Conversation conversation = new Conversation(); conversation.setUserId("usertest2"); conversation.setTopicId("Topic#Id#Test"); TopicDetail topic = new TopicDetail(); topic.setTitle(getResources().getString(R.string.TestTopic2)); topic.setSubtitle(getResources().getString(R.string.Topic_1)); topic.setLink("https://www.applozic.com/resources/sidebox/images/applozic.png"); topic.setKey1(getResources().getString(R.string.Qty)); topic.setValue1("1000"); topic.setKey2(getResources().getString(R.string.Price)); topic.setValue2(getResources().getString(R.string.rs)); conversation.setSenderSmsFormat(MobiComUserPreference.getInstance(this).getUserId(), "SENDER SMS FORMAT"); conversation.setReceiverSmsFormat("usertest2", "RECEIVER SMS FORMAT"); conversation.setTopicDetail(topic.getJson()); return conversation; }
Conversation conversation = new Conversation(); TopicDetail topic = new TopicDetail(); topic.setTitle(channel.getMetadata().get(Channel.GroupMetaDataType.TITLE.getValue())); topic.setSubtitle(channel.getMetadata().get(Channel.GroupMetaDataType.PRICE.getValue())); topic.setLink(channel.getMetadata().get(Channel.GroupMetaDataType.LINK.getValue())); conversation.setTopicDetail(topic.getJson()); conversationList = new ArrayList<>(); conversationList.add(conversation); for (Conversation c : conversationList) { i++; if (c.getId() != null && c.getId().equals(conversationId)) { break;
public void updateContextBasedGroup() { if (channel != null) { Channel channelInfo = ChannelService.getInstance(getActivity()).getChannelInfo(channel.getKey()); if ((Channel.GroupType.GROUPOFTWO.getValue().equals(channelInfo.getType())) && channel.isContextBasedChat()) { Conversation conversation = new Conversation(); TopicDetail topic = new TopicDetail(); topic.setTitle(channelInfo.getMetadata().get(Channel.GroupMetaDataType.TITLE.getValue())); topic.setSubtitle(channelInfo.getMetadata().get(Channel.GroupMetaDataType.PRICE.getValue())); topic.setLink(channelInfo.getMetadata().get(Channel.GroupMetaDataType.LINK.getValue())); conversation.setTopicDetail(topic.getJson()); conversationList.get(0).setTopicDetail(topic.getJson()); applozicContextSpinnerAdapter.notifyDataSetChanged(); } } }
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); } } } }
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; }
String topicId = conversation.getTopicId(); String topicDetailJson = conversation.getTopicDetail(); if (!TextUtils.isEmpty(topicDetailJson)) { TopicDetail topicDetail = (TopicDetail) GsonUtils.getObjectFromJson(topicDetailJson, TopicDetail.class);
@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 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 Bitmap downloadProductImage(Conversation conversation) { TopicDetail topicDetail = (TopicDetail) GsonUtils.getObjectFromJson(conversation.getTopicDetail(), TopicDetail.class); if (TextUtils.isEmpty(topicDetail.getLink())) { return null;
if (currentConversationId != null) { Conversation conversation = ConversationService.getInstance(this).getConversationByConversationId(currentConversationId); callIntent.putExtra(ConversationUIService.TOPIC_ID, conversation.getTopicId());
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); } } }