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