@Override public Bitmap downloadContactImage(Context context, Contact contact) { if (contact != null && TextUtils.isEmpty(contact.getImageURL())) { return null; } Bitmap attachedImage = ImageUtils.getBitMapFromLocalPath(contact.getLocalImageUrl()); if (attachedImage != null) { return attachedImage; } Bitmap bitmap = fileClientService.downloadBitmap(contact, null); if (bitmap != null) { File file = FileClientService.getFilePath(contact.getContactIds(), context.getApplicationContext(), "image", true); String imageLocalPath = ImageUtils.saveImageToInternalStorage(file, bitmap); contact.setLocalImageUrl(imageLocalPath); } if (!TextUtils.isEmpty(contact.getLocalImageUrl())) { updateLocalImageUri(contact); } return bitmap; }
@Override public Bitmap downloadGroupImage(Context context, Channel channel) { if (channel != null && TextUtils.isEmpty(channel.getImageUrl())) { return null; } Bitmap attachedImage = ImageUtils.getBitMapFromLocalPath(channel.getLocalImageUri()); if (attachedImage != null) { return attachedImage; } Bitmap bitmap = fileClientService.downloadBitmap(null, channel); if (bitmap != null) { File file = FileClientService.getFilePath(String.valueOf(channel.getKey()), context.getApplicationContext(), "image", true); String imageLocalPath = ImageUtils.saveImageToInternalStorage(file, bitmap); channel.setLocalImageUri(imageLocalPath); } if (!TextUtils.isEmpty(channel.getLocalImageUri())) { ChannelService.getInstance(context).updateChannelLocalImageURI(channel.getKey(), channel.getLocalImageUri()); } return bitmap; }
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; }