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