Java 类com.bumptech.glide.GenericRequestBuilder 实例源码

项目:EasyEmoji    文件:ImageLoader.java   
public void displayImage(final String uri, final ImageView imageView, int defaultIcon, final DisplayListener listener) {
    GenericRequestBuilder req = Glide.with(imageView.getContext().getApplicationContext()).load(uri).asBitmap().diskCacheStrategy(mDiskCacheStrategy);
    if (defaultIcon > 0) {
        req.placeholder(defaultIcon);
    }
    req.into(new BitmapImageViewTarget(imageView) {
        @Override
        public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
            super.onResourceReady(resource, glideAnimation);
            if (listener != null) {
                listener.onLoadCompleted(uri, imageView, resource);
            }
        }

        @Override
        public void onLoadFailed(Exception e, Drawable errorDrawable) {
            super.onLoadFailed(e, errorDrawable);
            if (listener != null) {
                listener.onLoadFailed(uri, imageView);
            }
        }
    });
}
项目:tumblr3d    文件:GifFrameLoader.java   
private static GenericRequestBuilder<GifDecoder, GifDecoder, Bitmap, Bitmap> getRequestBuilder(Context context,
                                                                                               GifDecoder gifDecoder, int width, int height, BitmapPool bitmapPool) {
    GifFrameResourceDecoder frameResourceDecoder = new GifFrameResourceDecoder(bitmapPool);
    GifFrameModelLoader frameLoader = new GifFrameModelLoader();
    Encoder<GifDecoder> sourceEncoder = NullEncoder.get();
    return Glide.with(context)
            .using(frameLoader, GifDecoder.class)
            .load(gifDecoder)
            .as(Bitmap.class)
            .sourceEncoder(sourceEncoder)
            .decoder(frameResourceDecoder)
            .skipMemoryCache(true)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .override(width, height);

}
项目:EasyEmoji    文件:ImageLoader.java   
/**
 * 核心图片加载函数
 * context : Context/Activity/Fragment 最好传activity 可与生命周期绑定
 * 参数uri : 网络图片url/本地图片path/资源文件ID/byte[]
 * view   : 要展示图片的控件
 * defaultIcon : 默认占位图
 */
public void displayImage(Context context, String uri, ImageView view , int defaultIcon){
    GenericRequestBuilder req =  Glide.with(context)
            .load(uri)
            .diskCacheStrategy(mDiskCacheStrategy);
            if(defaultIcon >0 ){
                req.placeholder(defaultIcon)
                        .error(defaultIcon);
            }
    req.into(view);
}
项目:EasyEmoji    文件:ImageLoader.java   
/**
 * 重载方法 加载展示圆角图片
 * @param round 圆角矢量 由调用方控制
 */
public void displayImage(Context context, String uri, ImageView view, int defaultIcon, int round) {
    GenericRequestBuilder req =  Glide.with(context)
            .load(uri)
            .diskCacheStrategy(mDiskCacheStrategy)
            .transform(new GlideRoundTransform(context,round));
            if(defaultIcon >0) {
                req.placeholder(defaultIcon)
                        .error(defaultIcon);
            }
            req.into(view);
}
项目:PeSanKita-android    文件:ThumbnailView.java   
private GenericRequestBuilder buildThumbnailGlideRequest(@NonNull Slide slide, @NonNull MasterSecret masterSecret) {
  @SuppressWarnings("ConstantConditions")
  DrawableRequestBuilder<DecryptableUri> builder = Glide.with(getContext())
                                                        .load(new DecryptableUri(masterSecret, slide.getThumbnailUri()))
                                                        .diskCacheStrategy(DiskCacheStrategy.NONE)
                                                        .crossFade()
                                                        .transform(new RoundedCorners(getContext(), true, radius, backgroundColorHint));

  if (slide.isInProgress()) return builder;
  else                      return builder.error(R.drawable.ic_missing_thumbnail_picture);
}
项目:PeSanKita-android    文件:ThumbnailView.java   
private GenericRequestBuilder buildPlaceholderGlideRequest(Slide slide) {
  return Glide.with(getContext())
              .load(slide.getPlaceholderRes(getContext().getTheme()))
              .asBitmap()
              .diskCacheStrategy(DiskCacheStrategy.NONE)
              .fitCenter();
}
项目:tenor-android-core    文件:GlideLoader.java   
public static GenericRequestBuilder applyDimens(@NonNull GenericRequestBuilder requestBuilder,
                                                @NonNull GlideTaskParams payload) {
    final Media media = payload.getMedia();
    if (media != null) {
        requestBuilder.override(media.getWidth(), media.getHeight());
    }
    return requestBuilder;
}
项目:tenor-android-core    文件:GlideLoader.java   
public static <T extends ImageView> void load(@NonNull final GenericRequestBuilder requestBuilder,
                                              @NonNull final GlideTaskParams<T> payload) {

    if (payload.isThumbnail()) {
        requestBuilder.thumbnail(payload.getThumbnailMultiplier());
    }

    requestBuilder.placeholder(payload.getPlaceholder())
            .into(new GlideDrawableImageViewTarget(payload.getTarget()) {
                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    if (payload.getCurrentRetry() < payload.getMaxRetry()) {
                        payload.incrementCurrentRetry();
                        load(requestBuilder, payload);
                    } else {
                        super.onLoadFailed(e, errorDrawable);
                        payload.getListener().failure(payload.getTarget(), errorDrawable);
                    }
                }

                @Override
                public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    payload.getListener().success(payload.getTarget(), resource);
                }
            });
}
项目:mvvm-template    文件:DrawableGetter.java   
@Override public Drawable getDrawable(@NonNull String url) {
    final UrlDrawable urlDrawable = new UrlDrawable();
    if (container != null && container.get() != null) {
        Context context = container.get().getContext();
        final GenericRequestBuilder load = Glide.with(context)
                .load(url)
                .dontAnimate();
        final GlideDrawableTarget target = new GlideDrawableTarget(urlDrawable, container, width);
        load.into(target);
        cachedTargets.add(target);
    }
    return urlDrawable;
}
项目:Cable-Android    文件:ThumbnailView.java   
private GenericRequestBuilder buildThumbnailGlideRequest(@NonNull Slide slide, @NonNull MasterSecret masterSecret) {
  @SuppressWarnings("ConstantConditions")
  DrawableRequestBuilder<DecryptableUri> builder = Glide.with(getContext())
                                                        .load(new DecryptableUri(masterSecret, slide.getThumbnailUri()))
                                                        .diskCacheStrategy(DiskCacheStrategy.NONE)
                                                        .crossFade()
                                                        .transform(new RoundedCorners(getContext(), true, radius, backgroundColorHint));

  if (slide.isInProgress()) return builder;
  else                      return builder.error(R.drawable.ic_missing_thumbnail_picture);
}
项目:Cable-Android    文件:ThumbnailView.java   
private GenericRequestBuilder buildPlaceholderGlideRequest(Slide slide) {
  return Glide.with(getContext())
              .load(slide.getPlaceholderRes(getContext().getTheme()))
              .asBitmap()
              .diskCacheStrategy(DiskCacheStrategy.NONE)
              .fitCenter();
}
项目:Gallery    文件:ViewerModule.java   
@Singleton
@Provides
GenericRequestBuilder<Media, InputStream, byte[], GifDrawable> provideGifRequestBuilder(
        RequestManager requestManager) {

    return requestManager.using(new MediaLoader(mView), InputStream.class)
            .from(Media.class)
            .as(byte[].class)
            .transcode(new GifDrawableBytesTranscoder(), GifDrawable.class)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .decoder(new StreamByteArrayResourceDecoder())
            .sourceEncoder(new StreamEncoder())
            .cacheDecoder(new FileToStreamDecoder<>(new StreamByteArrayResourceDecoder()));
}
项目:stepik-android    文件:GlideSvgRequestFactory.java   
public static GenericRequestBuilder<Uri, InputStream, SVG, PictureDrawable> create(Context context, Drawable placeholder) {
    return Glide.with(context.getApplicationContext())
            .using(Glide.buildStreamModelLoader(Uri.class, context), InputStream.class)
            .from(Uri.class)
            .as(SVG.class)
            .transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
            .sourceEncoder(new StreamEncoder())
            .cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder()))
            .decoder(new SvgDecoder())
            .placeholder(placeholder)
            .listener(new SvgSoftwareLayerSetter());
}
项目:TextSecureSMP    文件:ThumbnailView.java   
private GenericRequestBuilder buildGlideRequest(@NonNull Slide slide,
                                                @Nullable MasterSecret masterSecret)
{
  final GenericRequestBuilder builder;
  if (slide.getPart().isPendingPush()) {
    builder = buildPendingGlideRequest(slide);
  } else if (slide.getThumbnailUri() != null) {
    builder = buildThumbnailGlideRequest(slide, masterSecret);
  } else {
    builder = buildPlaceholderGlideRequest(slide);
  }

  return builder.error(R.drawable.ic_missing_thumbnail_picture);
}
项目:TextSecureSMP    文件:ThumbnailView.java   
private GenericRequestBuilder buildThumbnailGlideRequest(Slide slide, MasterSecret masterSecret) {

    final GenericRequestBuilder builder;
    if (slide.isDraft()) builder = buildDraftGlideRequest(slide);
    else                 builder = buildEncryptedPartGlideRequest(slide, masterSecret);
    return builder;
  }
项目:TextSecureSMP    文件:ThumbnailView.java   
private GenericRequestBuilder buildEncryptedPartGlideRequest(Slide slide, MasterSecret masterSecret) {
  if (masterSecret == null) {
    throw new IllegalStateException("null MasterSecret when loading non-draft thumbnail");
  }

  return  Glide.with(getContext()).load(new DecryptableUri(masterSecret, slide.getThumbnailUri()))
               .transform(new ThumbnailTransform(getContext()));
}
项目:Silence    文件:ThumbnailView.java   
private GenericRequestBuilder buildThumbnailGlideRequest(@NonNull Slide slide, @NonNull MasterSecret masterSecret) {
  @SuppressWarnings("ConstantConditions")
  DrawableRequestBuilder<DecryptableUri> builder = Glide.with(getContext()).load(new DecryptableUri(masterSecret, slide.getThumbnailUri()))
                                                                           .crossFade()
                                                                           .transform(new RoundedCorners(getContext(), true, radius, backgroundColorHint));

  if (slide.isInProgress()) return builder;
  else                      return builder.error(R.drawable.ic_missing_thumbnail_picture);
}
项目:MoeGallery    文件:MainModule.java   
@Singleton
@Provides
GenericRequestBuilder<GlideUrl, InputStream, byte[], GifDrawable> provideGifRequestBuilder(
        RequestManager requestManager, OkHttpClient okHttpClient) {

    return requestManager.using(new OkHttpUrlLoader(okHttpClient), InputStream.class)
            .from(GlideUrl.class)
            .as(byte[].class)
            .transcode(new GifDrawableBytesTranscoder(), GifDrawable.class)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .decoder(new StreamByteArrayResourceDecoder())
            .sourceEncoder(new StreamEncoder())
            .cacheDecoder(new FileToStreamDecoder<>(new StreamByteArrayResourceDecoder()));
}
项目:Jockey    文件:ArtistViewModel.java   
@Bindable
public GenericRequestBuilder getHeroImage() {
    if (mLfmReference != null) {
        Image hero = mLfmReference.getImageBySize(Image.Size.MEGA);

        if (hero != null) {
            return Glide.with(getContext())
                    .load(hero.getUrl())
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    .centerCrop()
                    .animate(android.R.anim.fade_in);
        }
    }
    return null;
}
项目:tumblr3d    文件:GifFrameLoader.java   
GifFrameLoader(FrameCallback callback, GifDecoder gifDecoder, Handler handler,
               GenericRequestBuilder<GifDecoder, GifDecoder, Bitmap, Bitmap>  requestBuilder) {
    if (handler == null) {
        handler = new Handler(Looper.getMainLooper(), new FrameLoaderCallback());
    }
    this.callback = callback;
    this.gifDecoder = gifDecoder;
    this.handler = handler;
    this.requestBuilder = requestBuilder;
}
项目:GlidePlus    文件:GlidePlus.java   
public GenericRequestBuilder<String, InputStream, ImageWrapper, Drawable> glide() {
    return mRequestBuilder;
}
项目:glide-support    文件:LoadCycler.java   
public LoadCycler(GenericRequestBuilder<M, ?, ?, T> request, ImageView imageView) {
    this(request, new DrawableImageViewTarget(imageView));
}
项目:glide-support    文件:LoadCycler.java   
public LoadCycler(GenericRequestBuilder<M, ?, ?, T> request, Target<? super T> target) {
    this.target = target;
    prev = copy(request);
    curr = copy(request);
    next = copy(request);
}
项目:glide-support    文件:LoadCycler.java   
private GenericRequestBuilder<M, ?, ?, T> copy(GenericRequestBuilder<M, ?, ?, T> request) {
    return request.clone().dontAnimate().thumbnail(null).listener(null).load(null);
}
项目:glide-support    文件:LoadCycler.java   
private void rotate() {
    GenericRequestBuilder<M, ?, ?, T> temp = prev;
    prev = curr;
    curr = next;
    next = temp;
}
项目:TextSecureSMP    文件:ThumbnailView.java   
private GenericRequestBuilder buildPendingGlideRequest(Slide slide) {
  return Glide.with(getContext()).load(R.drawable.stat_sys_download_anim0)
                                 .dontTransform()
                                 .skipMemoryCache(true)
                                 .crossFade();
}
项目:TextSecureSMP    文件:ThumbnailView.java   
private GenericRequestBuilder buildDraftGlideRequest(Slide slide) {
  return Glide.with(getContext()).load(slide.getThumbnailUri()).asBitmap()
                                 .fitCenter()
                                 .listener(new PduThumbnailSetListener(slide.getPart()));
}
项目:TextSecureSMP    文件:ThumbnailView.java   
private GenericRequestBuilder buildPlaceholderGlideRequest(Slide slide) {
  return Glide.with(getContext()).load(slide.getPlaceholderRes(getContext().getTheme()))
                                 .fitCenter()
                                 .crossFade();
}
项目:Silence    文件:ThumbnailView.java   
private GenericRequestBuilder buildPlaceholderGlideRequest(Slide slide) {
  return Glide.with(getContext()).load(slide.getPlaceholderRes(getContext().getTheme()))
                                 .asBitmap()
                                 .fitCenter();
}
项目:Jockey    文件:GlideBindingAdapters.java   
@BindingAdapter("android:src")
public static void bindImage(ImageView imageView, GenericRequestBuilder request) {
    if (request != null) {
        request.into(imageView);
    }
}
项目:Jockey    文件:AlbumViewModel.java   
@Bindable
public GenericRequestBuilder getHeroImage() {
    return Glide.with(getContext()).load(mAlbum.getArtUri()).centerCrop();
}
项目:Fo.dex    文件:FodexBaseFragment.java   
@Override
public GenericRequestBuilder getPreloadRequestBuilder(FodexLayoutSpecItem item) {
    return mPreloadRequest.load(item.fodexItem.uri);
}
项目:saarang-iosched    文件:SessionsFragment.java   
@Override
protected GenericRequestBuilder getRequestBuilder(String url) {
    return mImageLoader.beginImageLoad(url, null, true /*crop*/);
}
项目:AppDevFestSudeste2015    文件:SessionsFragment.java   
@Override
protected GenericRequestBuilder getRequestBuilder(String url) {
    return mImageLoader.beginImageLoad(url, null, true /*crop*/);
}
项目:RichText    文件:GlideImageGetter.java   
@Override
public Drawable getDrawable(ImageHolder holder, final RichTextConfig config, TextView textView) {
    final ImageTarget target;
    final GenericRequestBuilder load;
    DrawableTypeRequest dtr;
    DrawableWrapper drawableWrapper = new DrawableWrapper();
    byte[] src = Base64.decode(holder.getSource());
    if (src != null) {
        dtr = Glide.with(textView.getContext()).load(src);
    } else {
        dtr = Glide.with(textView.getContext()).load(holder.getSource());
    }
    Rect rect = null;
    if (config.cacheType >= CacheType.LAYOUT) {
        rect = loadCache(holder.getSource());
        if (rect != null) {
            drawableWrapper.setBounds(rect);
        }
    } else {
        drawableWrapper.setBounds(0, 0, holder.getWidth(), holder.getHeight());
    }
    if (holder.isGif()) {
        target = new ImageTargetGif(textView, drawableWrapper, holder, config, this, rect);
        load = dtr.asGif();
    } else {
        target = new ImageTargetBitmap(textView, drawableWrapper, holder, config, this, rect);
        load = dtr.asBitmap().atMost();
    }
    checkTag(textView);
    targets.add(target);
    if (!config.resetSize && holder.isInvalidateSize()) {
        load.override(holder.getWidth(), holder.getHeight());
    }
    if (holder.getScaleType() == ImageHolder.ScaleType.CENTER_CROP) {
        if (holder.isGif()) {
            //noinspection ConstantConditions
            ((GifTypeRequest) load).centerCrop();
        } else {
            //noinspection ConstantConditions
            ((BitmapTypeRequest) load).centerCrop();
        }
    } else if (holder.getScaleType() == ImageHolder.ScaleType.FIT_CENTER) {
        if (holder.isGif()) {
            //noinspection ConstantConditions
            ((GifTypeRequest) load).fitCenter();
        } else {
            //noinspection ConstantConditions
            ((BitmapTypeRequest) load).fitCenter();
        }
    }
    textView.post(new Runnable() {
        @Override
        public void run() {
            load.placeholder(config.placeHolder).error(config.errorImage).into(target);
        }
    });
    drawableWrapper.setCallback(textView);
    return drawableWrapper;
}
项目:gankmaku    文件:FuliAdapter.java   
@Override public GenericRequestBuilder getPreloadRequestBuilder(Entry item) {
  return Glide.with(mContext).load(item.getUrl()).bitmapTransform(new CenterCrop(mPool),
      new RoundedCornersTransformation(mPool, 8, 0))
      //.crossFade()
      .diskCacheStrategy(DiskCacheStrategy.ALL);
}
项目:devfestnorte-app    文件:SessionsFragment.java   
@Override
protected GenericRequestBuilder getRequestBuilder(String url) {
    return mImageLoader.beginImageLoad(url, null, true /*crop*/);
}
项目:saarang-iosched    文件:SessionsFragment.java   
@Override
protected GenericRequestBuilder getRequestBuilder(String url) {
    return mImageLoader.beginImageLoad(url, null, true /*crop*/);
}