@Test public void testReceivesRecursiveThumbnails() { requestManager.load(mockUri("content://first")).thumbnail( requestManager.load(mockUri("content://second")).thumbnail( requestManager.load(mockUri("content://third")).thumbnail( requestManager.load(mockUri("content://fourth"))))) .into(target); verify(target, times(4)).onResourceReady(isA(Drawable.class), isA(Transition.class)); }
@Override public void onBindViewHolder(final PhotoViewHolder holder, final int position) { if (getItemViewType(position) == TYPE_PHOTO) { Uri uri = Uri.fromFile(new File(photoPaths.get(position))); boolean canLoadImage = AndroidLifecycleUtils.canLoadImage(holder.ivPhoto.getContext()); if (canLoadImage) { final RequestOptions options = new RequestOptions(); options.centerCrop() .placeholder(R.drawable.__picker_ic_photo_black_48dp) .error(R.drawable.__picker_ic_broken_image_black_48dp); Glide.with(mContext) .load(uri) .apply(options) .thumbnail(0.1f) .into(holder.ivPhoto); } } }
/** * Loads thumbnail and then replaces it with full image. */ public static void loadFull(ImageView image, int imageId, int thumbId) { // We don't want Glide to crop or resize our image final RequestOptions options = new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.NONE) .override(Target.SIZE_ORIGINAL) .dontTransform(); final RequestBuilder<Drawable> thumbRequest = Glide.with(image) .load(thumbId) .apply(options); Glide.with(image) .load(imageId) .apply(options) .thumbnail(thumbRequest) .into(image); }
public void bindData(PhotoDirectory directory) { final RequestOptions options = new RequestOptions(); options.dontAnimate() .dontTransform() .override(800, 800) .placeholder(R.drawable.__picker_ic_photo_black_48dp) .error(R.drawable.__picker_ic_broken_image_black_48dp); glide.setDefaultRequestOptions(options) .load(directory.getCoverPath()) .thumbnail(0.1f) .into(ivCover); tvName.setText(directory.getName()); tvCount.setText(tvCount.getContext().getString(R.string.__picker_image_count, directory.getPhotos().size())); } }
.error(R.drawable.__picker_ic_broken_image_black_48dp); mGlide.setDefaultRequestOptions(options).load(uri) .thumbnail(0.1f) .into(imageView);
@Test public void testReceivesThumbnails() { String full = mockUri("content://full"); String thumb = mockUri("content://thumb"); requestManager .load(full) .thumbnail(requestManager.load(thumb)) .into(target); verify(target, times(2)).onResourceReady(isA(Drawable.class), isA(Transition.class)); }
public static void loadFlickrThumb(Photo photo, ImageView image) { final RequestOptions options = new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.DATA) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .dontTransform(); final RequestBuilder<Drawable> thumbRequest = Glide.with(image) .load(photo.getThumbnailUrl()) .apply(options) .transition(DrawableTransitionOptions.with(TRANSITION_FACTORY)); Glide.with(image).load(photo.getMediumUrl()) .apply(options) .thumbnail(thumbRequest) .into(image); }
public static void loadFlickrFull(Photo photo, ImageView image, LoadingListener listener) { final String photoUrl = photo.getLargeSize() == null ? photo.getMediumUrl() : photo.getLargeUrl(); final RequestOptions options = new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.DATA) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .dontTransform(); final RequestBuilder<Drawable> thumbRequest = Glide.with(image) .load(photo.getMediumUrl()) .apply(options); Glide.with(image) .load(photoUrl) .apply(new RequestOptions().apply(options).placeholder(image.getDrawable())) .thumbnail(thumbRequest) .listener(new RequestListenerWrapper<>(listener)) .into(image); }
.thumbnail(0.5f) .into(holder.ivPhoto);
public void setBlogImage(String downloadUri, String thumbUri){ blogImageView = mView.findViewById(R.id.blog_image); RequestOptions requestOptions = new RequestOptions(); requestOptions.placeholder(R.drawable.image_placeholder); Glide.with(context).applyDefaultRequestOptions(requestOptions).load(downloadUri).thumbnail( Glide.with(context).load(thumbUri) ).into(blogImageView); }
public void bindData(PhotoDirectory directory) { glide.load(directory.getCoverPath()) .apply(new RequestOptions() .dontAnimate() ) .thumbnail(0.1f) .into(ivCover); tvName.setText(directory.getName()); tvCount.setText(tvCount.getContext().getString(R.string.__picker_image_count, directory.getPhotos().size())); } }
.error(R.mipmap.__picker_ic_broken_image_black_48dp) .thumbnail(0.1f) .into(imageView);
public static void displaySmallPhoto(ImageView imageView, String url, int errorImage) { if (imageView == null) { throw new IllegalArgumentException("argument error"); } Glide.with(ZXApp.getContext()) .asBitmap() .load(url) .apply(new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.ALL) .placeholder(R.mipmap.ic_image_loading) .error(errorImage) ) .thumbnail(0.5f) .into(imageView); }
.centerCrop() .override(800, 800)) .thumbnail(0.5f) .into(holder.imageView); holder.imageView.setOnClickListener(new View.OnClickListener() {
request.thumbnail(0.1f) .apply(options);
.error(R.mipmap.__picker_ic_broken_image_black_48dp) .thumbnail(0.5f) .into(holder.ivPhoto);
.error(R.mipmap.__picker_ic_broken_image_black_48dp) .thumbnail(0.5f) .into(holder.ivPhoto);
.centerCrop() .placeholder(R.drawable.ic_image).error(R.drawable.ic_img_load_fail)) .thumbnail(0.5f) .into(imageHolder.ivImage);