public static Bitmap getBitMapFromLocalPath(String imageLocalPath) { if (TextUtils.isEmpty(imageLocalPath)) { return null; } final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; if (imageLocalPath != null) { try { // Calculate inSampleSize options.inSampleSize = ImageUtils.calculateInSampleSize(options, 100, 50); // Decode bitmap with inSampleSize set options.inJustDecodeBounds = false; return BitmapFactory.decodeFile(imageLocalPath, options); } catch (Exception ex) { Utils.printLog(context,TAG, "Image not found on local storage: " + ex.getMessage()); } } return null; }
@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; }
public static Bitmap getPreview(String filePath, int reqWidth, int reqHeight) { File image = new File(filePath); Bitmap bitmap; BitmapFactory.Options bounds = new BitmapFactory.Options(); bounds.inJustDecodeBounds = true; BitmapFactory.decodeFile(image.getPath(), bounds); if ((bounds.outWidth == -1) || (bounds.outHeight == -1)) { return null; } bounds.inSampleSize = calculateInSampleSize(bounds, reqWidth, reqHeight); bounds.inJustDecodeBounds = false; bitmap = BitmapFactory.decodeFile(image.getPath(), bounds); return ImageUtils.getImageRotatedBitmap(bitmap, image.getPath(), bitmap.getWidth(), bitmap.getHeight()); }
imageLocalPath = ImageUtils.saveImageToInternalStorage(file, attachedImage); options.inSampleSize = ImageUtils.calculateInSampleSize(options, 200, reqHeight);
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { super.onActivityResult(requestCode, resultCode, intent); File file = FileClientService.getFilePath(DEFAULT_CONATCT_IMAGE, getContext(), "image", true); if (file == null || !file.exists()) { Utils.printLog(getActivity(),TAG, "file not found,exporting it from drawable"); Bitmap bm = BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.applozic_ic_contact_picture_180_holo_light); String filePath = ImageUtils.saveImageToInternalStorage(FileClientService.getFilePath(DEFAULT_CONATCT_IMAGE, getActivity().getApplicationContext(), "image", true), bm); file = new File(filePath); } handleProfileimageUpload(false, Uri.parse(file.getAbsolutePath()), file); } else { Utils.printLog(getActivity(),TAG, "Activity result failed with code: " + resultCode); } }
public ApplozicContextSpinnerAdapter(final Context context, List<Conversation> conversations) { if (context == null) { return; } mInflater = LayoutInflater.from(context); this.conversationList = conversations; this.fileClientService = new FileClientService(context); this.context = context; productImageLoader = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) context)) { @Override protected Bitmap processBitmap(Object data) { return fileClientService.loadMessageImage(context, (Conversation) data); } }; productImageLoader.addImageCache(((FragmentActivity) context).getSupportFragmentManager(), 0.1f); productImageLoader.setImageFadeIn(false); }
Bitmap previewBitmap = ImageUtils.getPreview(context, uri); if (previewBitmap != null) { setGalleryView(previewBitmap);
Bitmap imageBitmap = ImageUtils.decodeSampledBitmapFromPath(message.getFilePaths().get(0)); mediaImageViewView.setImageBitmap(imageBitmap); } catch (Exception e) {
this.messageList = messageList; geoApiKey = Utils.getMetaDataValue(context.getApplicationContext(), ConversationActivity.GOOGLE_API_KEY_META_DATA); contactImageLoader = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) context)) { @Override protected Bitmap processBitmap(Object data) { contactImageLoader.setImageFadeIn(false); loadImage = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) context)) { @Override protected Bitmap processBitmap(Object data) { loadImage.setImageFadeIn(false); loadImage.addImageCache(((FragmentActivity) context).getSupportFragmentManager(), 0.1f); imageThumbnailLoader = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) context)) { @Override protected Bitmap processBitmap(Object data) {
@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; }
options.inSampleSize = ImageUtils.calculateInSampleSize(options, actualWidth, actualHeight); options.inJustDecodeBounds = false;
public QuickConversationAdapter(final Context context, List<Message> messageList, EmojiconHandler emojiconHandler) { this.context = context; this.emojiconHandler = emojiconHandler; this.contactService = new AppContactService(context); this.messageDatabaseService = new MessageDatabaseService(context); this.messageList = messageList; conversationUIService = new ConversationUIService((FragmentActivity) context); contactImageLoader = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) context)) { @Override protected Bitmap processBitmap(Object data) { return contactService.downloadContactImage((Activity) context, (Contact) data); } }; contactImageLoader.addImageCache(((FragmentActivity) context).getSupportFragmentManager(), 0.1f); contactImageLoader.setImageFadeIn(false); channelImageLoader = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) context)) { @Override protected Bitmap processBitmap(Object data) { return contactService.downloadGroupImage((Activity) context, (Channel) data); } }; channelImageLoader.addImageCache(((FragmentActivity) context).getSupportFragmentManager(), 0.1f); channelImageLoader.setImageFadeIn(false); final String alphabet = context.getString(R.string.alphabet); mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet); highlightTextSpan = new TextAppearanceSpan(context, R.style.searchTextHiglight); }
returnBitmap = ImageUtils.getImageRotatedBitmap(returnBitmap, imagePath, returnBitmap.getWidth(), returnBitmap.getHeight()); mPhotoTask.setImage(returnBitmap);
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; }
inputStream.resetPos(mark); optionsBitmap.inJustDecodeBounds = false; optionsBitmap.inSampleSize = ImageUtils.calculateInSampleSize(optionsBitmap, 100, 50); Bitmap attachedImage = BitmapFactory.decodeStream(inputStream, null, optionsBitmap); inputStream.allowMarksToExpire(true);
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); baseContactService = new AppContactService(getActivity()); final Context context = getActivity().getApplicationContext(); contactImageLoader = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) getContext())) { @Override protected Bitmap processBitmap(Object data) { return baseContactService.downloadContactImage(context, (Contact) data); } }; contactImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_180_holo_light); contactImageLoader.addImageCache((getActivity()).getSupportFragmentManager(), 0.1f); contactImageLoader.setImageFadeIn(false); }
inputStream.resetPos(mark); optionsBitmap.inJustDecodeBounds = false; optionsBitmap.inSampleSize = ImageUtils.calculateInSampleSize(optionsBitmap, 100, 50); Bitmap attachedImage = BitmapFactory.decodeStream(inputStream, null, optionsBitmap); inputStream.allowMarksToExpire(true);
public ScheduledMessageAdapter(Context context, int textViewResourceId, List<Message> smsList) { super(context, textViewResourceId, smsList); baseContactService = new AppContactService(context); mImageLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) { @Override protected Bitmap processBitmap(Object data) { return loadContactPhoto((Uri) data, getImageSize()); } }; mImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_180_holo_light); mImageLoader.setImageFadeIn(false); }
locationImageLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) { @Override protected Bitmap processBitmap(Object data) {
fileClientService = new FileClientService(getActivity()); setHasOptionsMenu(true); imageThumbnailLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) { @Override protected Bitmap processBitmap(Object data) { imageThumbnailLoader.setImageFadeIn(false); imageThumbnailLoader.addImageCache((getActivity()).getSupportFragmentManager(), 0.1f); messageImageLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) { @Override protected Bitmap processBitmap(Object data) {