com.bumptech.glide.RequestBuilder.thumbnail()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中com.bumptech.glide.RequestBuilder.thumbnail方法的一些代码示例,展示了RequestBuilder.thumbnail的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RequestBuilder.thumbnail方法的具体详情如下:
包路径:com.bumptech.glide.RequestBuilder
类名称:RequestBuilder
方法名:thumbnail

RequestBuilder.thumbnail介绍

[英]Loads a resource in an identical manner to this request except with the dimensions of the target multiplied by the given size multiplier. If the thumbnail load completes before the full size load, the thumbnail will be shown. If the thumbnail load completes after the full size load, the thumbnail will not be shown.

Note - The thumbnail resource will be smaller than the size requested so the target (or ImageView) must be able to scale the thumbnail appropriately. See android.widget.ImageView.ScaleType.

Almost all options will be copied from the original load, including the com.bumptech.glide.load.model.ModelLoader, com.bumptech.glide.load.ResourceDecoder, and com.bumptech.glide.load.Transformations. However, com.bumptech.glide.request.RequestOptions#placeholder(int) and com.bumptech.glide.request.RequestOptions#error(int), and #listener(RequestListener) will only be used on the full size load and will not be copied for the thumbnail load.

Recursive calls to thumbnail are supported.

Overrides any previous calls to this method, #thumbnail(RequestBuilder[]), and #thumbnail(RequestBuilder).
[中]以与此请求相同的方式加载资源,除非目标的维度乘以给定的大小乘数。如果缩略图加载在全尺寸加载之前完成,将显示缩略图。如果缩略图加载在全尺寸加载后完成,则不会显示缩略图。
注意-缩略图资源将小于请求的大小,因此目标(或ImageView)必须能够适当缩放缩略图。看看安卓。小装置。ImageView。鳞片。
几乎所有选项都将从原始加载中复制,包括com。邦普泰克。滑行负载模型ModelLoader,com。邦普泰克。滑行负载ResourceDecoder和com。邦普泰克。滑行负载转变。然而,com。邦普泰克。滑行要求请求选项#占位符(int)和com。邦普泰克。滑行要求RequestOptions#error(int)和#listener(RequestListener)仅在全尺寸加载时使用,不会在缩略图加载时复制。
支持对缩略图的递归调用。
覆盖以前对该方法#缩略图(RequestBuilder[])和#缩略图(RequestBuilder[])的任何调用。

代码示例

代码示例来源:origin: bumptech/glide

@Nullable RequestBuilder<TranscodeType>... thumbnails) {
if (thumbnails == null || thumbnails.length == 0) {
 return thumbnail((RequestBuilder<TranscodeType>) null);
 } else {
  previous = current.thumbnail(previous);
return thumbnail(previous);

代码示例来源:origin: bumptech/glide

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

代码示例来源:origin: donglua/PhotoPicker

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

代码示例来源:origin: bumptech/glide

@Test
public void testReceivesRecursiveThumbnailWithPercentage() {
 requestManager.load(mockUri("content://first"))
   .thumbnail(requestManager.load(mockUri("content://second")).thumbnail(0.5f))
   .into(target);
 verify(target, times(3)).onResourceReady(isA(Drawable.class), isA(Transition.class));
}

代码示例来源:origin: alexvasilkov/GestureViews

/**
 * 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);
}

代码示例来源:origin: donglua/PhotoPicker

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

代码示例来源:origin: donglua/PhotoPicker

.error(R.drawable.__picker_ic_broken_image_black_48dp);
mGlide.setDefaultRequestOptions(options).load(uri)
    .thumbnail(0.1f)
    .into(imageView);

代码示例来源:origin: bumptech/glide

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

代码示例来源:origin: alexvasilkov/GestureViews

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

代码示例来源:origin: alexvasilkov/GestureViews

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

代码示例来源:origin: donglua/PhotoPicker

.thumbnail(0.5f)
.into(holder.ivPhoto);

代码示例来源:origin: akshayejh/PhotoBlog-Android-Blog-App

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

代码示例来源:origin: StannyBing/ZXUtils

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

代码示例来源:origin: StannyBing/ZXUtils

.error(R.mipmap.__picker_ic_broken_image_black_48dp)
.thumbnail(0.1f)
.into(imageView);

代码示例来源:origin: StannyBing/ZXUtils

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

代码示例来源:origin: wj576038874/PhotoSelector

.centerCrop()
        .override(800, 800))
    .thumbnail(0.5f)
    .into(holder.imageView);
holder.imageView.setOnClickListener(new View.OnClickListener() {

代码示例来源:origin: Leeii/LeeFream

request.thumbnail(0.1f)
    .apply(options);

代码示例来源:origin: StannyBing/ZXUtils

.error(R.mipmap.__picker_ic_broken_image_black_48dp)
.thumbnail(0.5f)
.into(holder.ivPhoto);

代码示例来源:origin: StannyBing/ZXUtils

.error(R.mipmap.__picker_ic_broken_image_black_48dp)
.thumbnail(0.5f)
.into(holder.ivPhoto);

代码示例来源:origin: wj576038874/PhotoSelector

.centerCrop()
    .placeholder(R.drawable.ic_image).error(R.drawable.ic_img_load_fail))
.thumbnail(0.5f)
.into(imageHolder.ivImage);

相关文章