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; }
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; }
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); } } } }