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

项目:MvpPlus    文件:GlideImageLoaderStrategy.java   
/**
 * DrawableRequestBuilder 的通行配置
 * @param ctx 上下文
 * @param img ImageLoader封装器
 * @param typeRequest url or resource
 * @param <T> String or Integer
 * @return DrawableRequestBuilder<T>
 */
private <T> DrawableRequestBuilder<T> getDrawableRequestBuilder(Context ctx, ImageLoader img, DrawableTypeRequest<T> typeRequest) {
    DrawableRequestBuilder<T> builder = typeRequest
            .placeholder(img.placeHolder)
            .error(img.errorHolder)
            .diskCacheStrategy(DiskCacheStrategy.ALL);

    // transform image type
    int transType = img.transType;
    if (transType == LoaderConfig.TRANS_CIRCLE) {
        builder = builder.transform(new GlideCircleTransform(ctx));
    } else if (transType == LoaderConfig.TRANS_ROUND) {
        builder = builder.transform(new GlideRoundTransform(ctx));
    }

    // SCALE type
    if (img.scaleType == LoaderConfig.SCALE_CENTER_CROP) {
        builder = builder.centerCrop();
    } else if (img.scaleType == LoaderConfig.SCALE_FIT_CENTER) {
        builder = builder.fitCenter();
    }
    return builder;
}
项目:RetrofitSample    文件:DataBindingAdapter.java   
@BindingAdapter(value = {"imageUrl", "defaultImg", "radius"}, requireAll = false)
public static void setImage(ImageView imageView, String imageUrl, Drawable defaultImg, int radius) {
    DrawableRequestBuilder drawableTypeRequest = Glide.with(imageView.getContext()).load(imageUrl).crossFade();
    if (defaultImg != null) {
        drawableTypeRequest.placeholder(defaultImg).error(defaultImg);
    } else {
        drawableTypeRequest.placeholder(R.drawable.bg_defautl_imageview).error(R.drawable.bg_defautl_imageview);
    }
    if (radius > 0) {
        drawableTypeRequest.bitmapTransform(new CenterCrop(imageView.getContext()),
                new RoundedCornersTransformation(imageView.getContext(), PixelUtil.dp2px(radius), 0));
    } else {
        drawableTypeRequest.bitmapTransform(new CenterCrop(imageView.getContext()));
    }
    drawableTypeRequest.into(imageView);
}
项目:filepicker    文件:ImageBrowserActivity.java   
@Override
public Object instantiateItem(final ViewGroup container, int position) {
    final PhotoView view = new PhotoView(ImageBrowserActivity.this);
    view.setScaleType(ImageView.ScaleType.FIT_CENTER);
    ImageFile file = mList.get(position);
    RequestManager requestManager = Glide.with(ImageBrowserActivity.this);
    DrawableRequestBuilder requestBuilder;
    if (file.getEditCount() > 0) {
        requestBuilder = requestManager.load(file.getEditedPath())
                .signature(new StringSignature(file.getEditCount() + ""));
    } else {
        requestBuilder = requestManager.load(file.getPath());
    }
    requestBuilder
            .crossFade()
            .placeholder(R.mipmap.ic_place_holder).into(view);
    container.addView(view);
    return view;
}
项目:bikedeboa-android    文件:BindingAdapters.java   
@BindingAdapter({"imageAddress"})
public static void loadImage(final ImageView imageView, final String imageAddress) {

    if (imageAddress != null && imageAddress.startsWith("https://s3.amazonaws.com/bikedeboa/")) {

        Context context = imageView.getContext();
        // Hopefully the thumbnail is already disk cached and no requests are made
        DrawableRequestBuilder<String> thumbnailRequest = Glide
                .with(context)
                .load(imageAddress.replace("images/", "images/thumbs/"))
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
                .transform(new BlurTransformation(context));

        Glide.with(context)
                .load(imageAddress)
                .thumbnail(thumbnailRequest)
                .crossFade()
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .priority(Priority.HIGH)
                .into(imageView);
    }
}
项目:Rubit    文件:ImageUtils.java   
/**
 * Using Glide to load image with round transform
 *
 * @param context          {@link Context}
 * @param imageView        {@link ImageView}
 * @param imagePath        {@link String}
 * @param isRoundTransform {@link Boolean}
 */
public static void loadingImageWithRoundTransform(final Context context,
                                                  final ImageView imageView,
                                                  final String imagePath,
                                                  final boolean isRoundTransform) {

    DrawableRequestBuilder<String> request = Glide.with(context)
            .load(imagePath)
            .placeholder(R.drawable.image_placeholder);

    if (isRoundTransform) {
        RoundedCornersTransformation transformation = new RoundedCornersTransformation(context,
                50, 0, RoundedCornersTransformation.CornerType.ALL);

        request.bitmapTransform(transformation);
    }

    request.into(imageView);
}
项目:GankGirl    文件:GankAdapter.java   
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    GankBean gankBean = mData.get(position);
    holder.tvHomeGankTitle.setText(gankBean.desc);
    holder.tvHomeGankAuthor.setText(gankBean.who);
    holder.tvHomeGankDate.setText(DateUtils.formatDateDetailDay(DateUtils.parseStringToDate(gankBean.publishedAt)));

    if (gankBean.images != null && !gankBean.images.isEmpty()) {
        holder.ivHomeGankImg.setVisibility(View.VISIBLE);
        DrawableRequestBuilder<String> requestBuilder = Glide.with(mContext)
                .load(gankBean.images.get(0)+"?imageView2/0/w/400")
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .error(R.color.accent)
                .crossFade();
        requestBuilder.into(holder.ivHomeGankImg);
    }else {
        holder.ivHomeGankImg.setVisibility(View.GONE);
    }
}
项目:Mysplash    文件:ImageHelper.java   
public static void loadAvatar(Context context, ImageView view,
                              @Nullable User user, @NotNull String url, int index,
                              @Nullable OnLoadImageListener<User> l) {
    DrawableRequestBuilder<Integer> thumbnailRequest = Glide.with(context)
            .load(R.drawable.default_avatar)
            .override(128, 128)
            .transform(new CircleTransformation(context))
            .diskCacheStrategy(DiskCacheStrategy.SOURCE);
    DrawableRequestBuilder<String> request = Glide.with(context)
            .load(url)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .override(128, 128)
            .transform(new CircleTransformation(context))
            .thumbnail(thumbnailRequest);
    if (l != null) {
        request.listener(new UserSaturationListener(context, view, user, index, l));
    }
    request.into(view);
}
项目:Pasta-for-Spotify    文件:CustomImageView.java   
public void load(final DrawableRequestBuilder request) {
    if (getWidth() > 0 && getHeight() > 0) {
        request.dontAnimate().into(new SimpleTarget<GlideDrawable>(getWidth(), getHeight()) {
            @Override
            public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                transition(resource);
            }
        });
    } else {
        getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                load(request);
                getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        });
    }
}
项目:PeSanKita-android    文件:GiphyAdapter.java   
@Override
public void onBindViewHolder(GiphyViewHolder holder, int position) {
  GiphyImage image = images.get(position);

  holder.modelReady = false;
  holder.image      = image;
  holder.thumbnail.setAspectRatio(image.getGifAspectRatio());
  holder.gifProgress.setVisibility(View.GONE);

  DrawableRequestBuilder<String> thumbnailRequest = Glide.with(context)
                                                         .load(image.getStillUrl());

  if (Util.isLowMemory(context)) {
    Glide.with(context)
         .load(image.getStillUrl())
         .placeholder(new ColorDrawable(Util.getRandomElement(MaterialColor.values()).toConversationColor(context)))
         .diskCacheStrategy(DiskCacheStrategy.ALL)
         .into(holder.thumbnail);

    holder.setModelReady();
  } else {
    Glide.with(context)
         .load(image.getGifUrl())
         .thumbnail(thumbnailRequest)
         .placeholder(new ColorDrawable(Util.getRandomElement(MaterialColor.values()).toConversationColor(context)))
         .diskCacheStrategy(DiskCacheStrategy.ALL)
         .listener(holder)
         .into(holder.thumbnail);
  }
}
项目: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);
}
项目:Orin    文件:SongGlideRequest.java   
public DrawableRequestBuilder<GlideDrawable> build() {
    //noinspection unchecked
    return createBaseRequest(requestManager, song, ignoreMediaStore)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(song));
}
项目:filepicker    文件:ImageBrowserActivity.java   
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
    ImageThumbnailHolder viewHolder = (ImageThumbnailHolder) holder;

    ImageFile file = mSelectedThumbnailList.get(position);

    RequestManager requestManager = Glide.with(ImageBrowserActivity.this);
    DrawableRequestBuilder requestBuilder;
    if (file.getEditCount() > 0) {
        requestBuilder = requestManager.load(file.getEditedPath())
                .signature(new StringSignature(file.getEditCount() + ""));
    } else {
        requestBuilder = requestManager.load(file.getPath());
    }
    requestBuilder.centerCrop()
            .crossFade()
            .placeholder(R.mipmap.ic_place_holder).into(viewHolder.imageView);

    if (mList.get(mCurrentIndex).getId() == file.getId()) {
        viewHolder.ivBlock.setVisibility(View.VISIBLE);
    } else {
        viewHolder.ivBlock.setVisibility(View.GONE);
    }
    if (mIsPreview) {
        viewHolder.shadow.setVisibility(file.isSelected() ? View.GONE : View.VISIBLE);
    }
    viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mViewPager.setCurrentItem(Integer.valueOf(mSelectedPosition.get(position)), false);
            mRecyclerView.scrollToPosition(position);
        }
    });
}
项目:tenor-android-core    文件:ImageLoader.java   
/**
 * Uses Glide to load image into an ImageView
 *
 * @param weakRef the {@link WeakReference} of a given subclass of {@link Context}
 * @param params  the {@link GlideTaskParams}
 */
public static <CTX extends Context, T extends ImageView> void loadImage(@NonNull WeakReference<CTX> weakRef,
                                                                        @NonNull GlideTaskParams<T> params) {

    if (!AbstractWeakReferenceUtils.isAlive(weakRef)) {
        return;
    }

    DrawableRequestBuilder<String> requestBuilder = Glide.with(weakRef.get()).load(params.getPath())
            .diskCacheStrategy(DiskCacheStrategy.ALL);

    load(applyDimens(requestBuilder, params), params);
}
项目:Cable-Android    文件:GiphyAdapter.java   
@Override
public void onBindViewHolder(GiphyViewHolder holder, int position) {
  GiphyImage image = images.get(position);

  holder.modelReady = false;
  holder.image      = image;
  holder.thumbnail.setAspectRatio(image.getGifAspectRatio());
  holder.gifProgress.setVisibility(View.GONE);

  DrawableRequestBuilder<String> thumbnailRequest = Glide.with(context)
                                                         .load(image.getStillUrl());

  if (Util.isLowMemory(context)) {
    Glide.with(context)
         .load(image.getStillUrl())
         .placeholder(new ColorDrawable(Util.getRandomElement(MaterialColor.values()).toConversationColor(context)))
         .diskCacheStrategy(DiskCacheStrategy.ALL)
         .into(holder.thumbnail);

    holder.setModelReady();
  } else {
    Glide.with(context)
         .load(image.getGifUrl())
         .thumbnail(thumbnailRequest)
         .placeholder(new ColorDrawable(Util.getRandomElement(MaterialColor.values()).toConversationColor(context)))
         .diskCacheStrategy(DiskCacheStrategy.ALL)
         .listener(holder)
         .into(holder.thumbnail);
  }
}
项目: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);
}
项目:bikedeboa-android    文件:ExpandImageActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_expand_image);

    ActionBar actionBar = getSupportActionBar();
    actionBar.hide();

    Bundle extras = getIntent().getExtras();
    int rackId = 0;
    if (extras != null) {
        rackId = extras.getInt(RACK_ID);
    } else {
        // Something's not right, finish this activity
        this.finish();
    }

    DetailViewModel detailViewModel = new DetailViewModel(rackId, this);
    PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);

    // Request cached thumbnail
    DrawableRequestBuilder<String> thumbnailRequest = Glide
            .with(this)
            .load(detailViewModel.getImage().replace("images/", "images/thumbs/"))
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .transform(new BlurTransformation(this));

    Glide.with(this)
            .load(detailViewModel.getImage())
            .thumbnail(thumbnailRequest)
            .crossFade()
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .priority(Priority.HIGH)
            .into(photoView);

}
项目:RetroMusicPlayer    文件:SongGlideRequest.java   
public DrawableRequestBuilder<GlideDrawable> build() {
    //noinspection unchecked
    return createBaseRequest(requestManager, song, ignoreMediaStore)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(song));
}
项目:RetroMusicPlayer    文件:ArtistGlideRequest.java   
public DrawableRequestBuilder<GlideDrawable> build() {
    //noinspection unchecked
    return createBaseRequest(requestManager, artist, noCustomImage, forceDownload)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .priority(Priority.LOW)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .signature(createSignature(artist));
}
项目:GankGirl    文件:GlideImageLoader.java   
/**
 * 下载图片转换圆角
 * @param context
 * @param imageRes
 * @param view
 * @param radius 圆角度
 */
public static void loadAdapterRadius(Context context, String imageRes, ImageView view,int radius){
    DrawableRequestBuilder requestBuilder = Glide.with(context)
            .load(imageRes)
            .centerCrop()
            .crossFade()
            .transform(new GlideRoundTransform(context, radius))
            .diskCacheStrategy(DiskCacheStrategy.ALL);
    requestBuilder.into(view);
}
项目:GankGirl    文件:GlideImageLoader.java   
/**
 * 下载图片转换圆角
 * @param context
 * @param imageRes
 * @param view
 * @param radius
 */
public static void loadAdapterRadius(Context context, @DrawableRes int imageRes, ImageView view, int radius){
    DrawableRequestBuilder requestBuilder = Glide.with(context)
            .load(imageRes)
            .centerCrop()
            .crossFade()
            .transform(new GlideRoundTransform(context, radius))
            .diskCacheStrategy(DiskCacheStrategy.ALL);
    requestBuilder.into(view);
}
项目:Mysplash    文件:ImageHelper.java   
private static DrawableRequestBuilder<String> loadRegularPhoto(Context context, ImageView view,
                                                              Photo photo, int index,
                                                              boolean saturation, boolean execute,
                                                              @Nullable OnLoadImageListener<Photo> l) {
    if (photo != null && photo.urls != null
            && photo.width != 0 && photo.height != 0) {

        DrawableRequestBuilder<String> thumbnailRequest = Glide
                .with(context)
                .load(photo.urls.thumb)
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .listener(new SetEnableListener(view));

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
                && !photo.hasFadedIn && saturation) {
            AnimUtils.ObservableColorMatrix matrix = new AnimUtils.ObservableColorMatrix();
            matrix.setSaturation(0);
            view.setColorFilter(new ColorMatrixColorFilter(matrix));
        }
        view.setEnabled(false);

        DrawableRequestBuilder<String> regularRequest = Glide
                .with(context)
                .load(photo.getRegularSizeUrl(context))
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .override(photo.getRegularWidth(), photo.getRegularHeight())
                .thumbnail(thumbnailRequest)
                .animate(new FadeAnimator());
        if (l != null && saturation) {
            regularRequest.listener(new PhotoSaturationListener(context, view, photo, index, l));
        } else if (l != null) {
            regularRequest.listener(new BaseRequestListener<Photo, String, GlideDrawable>(photo, 0, l));
        }
        if (execute) {
            regularRequest.into(view);
        }
        return regularRequest;
    }
    return null;
}
项目:Mysplash    文件:ImageHelper.java   
public static void loadResourceImage(Context context, ImageView view, int resId,
                                     @Nullable BitmapTransformation transformation) {
    DrawableRequestBuilder<Integer> request = Glide
            .with(context)
            .load(resId)
            .dontAnimate()
            .diskCacheStrategy(DiskCacheStrategy.SOURCE);
    if (transformation != null) {
        request.transform(transformation);
    }
    request.into(view);
}
项目:Mysplash    文件:ImageHelper.java   
public static void loadImageFromUrl(Context context, ImageView view, String url, boolean lowPriority,
                                    @Nullable OnLoadImageListener<String> l) {
    DrawableRequestBuilder<String> request = Glide
            .with(context)
            .load(url)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE);
    if (lowPriority) {
        request.priority(Priority.LOW);
    }
    if (l != null) {
        request.listener(new BaseRequestListener<String, String, GlideDrawable>(url, 0, l));
    }
    request.into(view);
}
项目:android-proguards    文件:AboutActivity.java   
private void bindLibrary(final LibraryHolder holder, final Library lib) {
    holder.name.setText(lib.name);
    holder.description.setText(lib.description);
    DrawableRequestBuilder<String> request = Glide.with(holder.image.getContext())
            .load(lib.imageUrl)
            .placeholder(R.drawable.avatar_placeholder);
    if (lib.circleCrop) {
        request.transform(circleCrop);
    }
    request.into(holder.image);
}
项目:GalleryPicker    文件:GlideImageLoader.java   
@Override
public void display(Context context, String path, ImageView imageView, Drawable defaultDrawable,
                    Bitmap.Config config, boolean resize, int width, int height) {
    DrawableRequestBuilder builder = Glide.with(context)
            .load(new File(path))
            .placeholder(defaultDrawable);
    if (resize) {
        builder = builder.override(width, height);
    }
    builder.crossFade()
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .into(imageView);
}
项目:GalleryPicker    文件:GlideImageLoader.java   
@Override
public void displayCenterCrop(Context context, String path, ImageView imageView, Drawable defaultDrawable,
                              Bitmap.Config config, boolean resize, int width, int height) {
    DrawableRequestBuilder builder = Glide.with(context)
            .load(new File(path))
            .placeholder(defaultDrawable);
    if (resize) {
        builder = builder.override(width, height);
    }
    builder.crossFade()
            .centerCrop()
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .into(imageView);
}
项目:orz    文件:AppPicUtils.java   
public static DrawableRequestBuilder<String> urlNoPlaceHolder(Context context, String url) {
        return Glide.with(context)
                .fromString()
                .load(url)
//                .placeholder(R.drawable.placeholder);
//                .error(R.drawable.error)
//                .animate(R.anim.my_fancy_anim)
                ;
    }
项目:Zatuji    文件:ImageHelper.java   
/**
 * 普通图片显示
 */
private static DrawableRequestBuilder<String> baseGlide(ImageView iv, String key){
    return Glide.with(iv.getContext())
            .load(key)
            .crossFade(150)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .placeholder(getRandomColor());

}
项目:Phonograph    文件:SongGlideRequest.java   
public DrawableRequestBuilder<GlideDrawable> build() {
    //noinspection unchecked
    return createBaseRequest(requestManager, song, ignoreMediaStore)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(song));
}
项目:Phonograph    文件:ArtistGlideRequest.java   
public DrawableRequestBuilder<GlideDrawable> build() {
    //noinspection unchecked
    return createBaseRequest(requestManager, artist, noCustomImage, forceDownload)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .priority(Priority.LOW)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .signature(createSignature(artist));
}
项目: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);
}
项目:Hentoid    文件:QueueContentAdapter.java   
private void attachCover(ViewHolder holder, Content content) {
    DrawableRequestBuilder<String> thumb = Glide.with(cxt).load(content.getCoverImageUrl());

    String coverFile = FileHelper.getThumb(cxt, content);
    holder.ivCover.layout(0, 0, 0, 0);

    Glide.with(cxt)
            .load(coverFile)
            .fitCenter()
            .placeholder(R.drawable.ic_placeholder)
            .error(R.drawable.ic_placeholder)
            .thumbnail(thumb)
            .into(holder.ivCover);
}
项目:android-tutorials-glide    文件:UsageExampleThumbnails.java   
private void loadImageThumbnailRequest() {
    DrawableRequestBuilder<String> thumbnailRequest = Glide
            .with(context)
            .load(eatFoodyImages[2])
            .skipMemoryCache(true)
            .diskCacheStrategy(DiskCacheStrategy.NONE);

    Glide
            .with(context)
            .load(UsageExampleGifAndVideos.gifUrl)
            .skipMemoryCache(true)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .thumbnail(thumbnailRequest)
            .into(imageView3);
}
项目:devfestnorte-app    文件:ImageLoader.java   
/**
 * Load an image from a url into an ImageView using the default placeholder
 * drawable if available.
 * @param url The web URL of an image.
 * @param imageView The target ImageView to load the image into.
 * @param requestListener A listener to monitor the request result.
 * @param placeholderOverride A drawable to use as a placeholder for this specific image.
 *                            If this parameter is present, {@link #mPlaceHolderResId}
 *                            if ignored for this request.
 */
public void loadImage(String url, ImageView imageView, RequestListener<String> requestListener,
            Drawable placeholderOverride, boolean crop) {
    DrawableRequestBuilder<String> request = beginImageLoad(url, requestListener, crop)
            .animate(R.anim.image_fade_in);
    if (placeholderOverride != null) {
        request.placeholder(placeholderOverride);
    } else if (mPlaceHolderResId != -1) {
        request.placeholder(mPlaceHolderResId);
    }
    request.into(imageView);
}
项目:GitHub    文件:GlideImageLoaderStrategy.java   
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
    if (ctx == null) throw new IllegalStateException("Context is required");
    if (config == null) throw new IllegalStateException("GlideImageConfig is required");
    if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("url is required");
    if (config.getImageView() == null) throw new IllegalStateException("imageview is required");


    RequestManager manager;

    manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期

    DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
            .crossFade()
            .centerCrop();

    switch (config.getCacheStrategy()) {//缓存策略
        case 0:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case 1:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case 2:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
            break;
        case 3:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
            break;
    }

    if (config.getTransformation() != null) {//glide用它来改变图形的形状
        requestBuilder.transform(config.getTransformation());
    }


    if (config.getPlaceholder() != 0)//设置占位符
        requestBuilder.placeholder(config.getPlaceholder());

    if (config.getErrorPic() != 0)//设置错误的图片
        requestBuilder.error(config.getErrorPic());

    requestBuilder
            .into(config.getImageView());
}
项目:CustomListView    文件:GlideImageLoaderStrategy.java   
@Override
    public void loadImage(Context ctx, GlideImageConfig config) {
        if (ctx == null) throw new IllegalStateException("Context is required");
        if (config == null) throw new IllegalStateException("GlideImageConfig is required");
        //这里不抛异常空的就显示默认图片
//        if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("url is required");
        if (config.getImageView() == null) throw new IllegalStateException("imageview is required");


        RequestManager manager;

        manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期

        DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
                .centerCrop();

        if (config.fitCenter()) {
            requestBuilder.fitCenter();
        }

        if (config.dontAnimation()) {
            requestBuilder.dontAnimate();
        } else {
            requestBuilder.crossFade();
        }

        switch (config.getCacheStrategy()) {//缓存策略
            case 0:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
                break;
            case 1:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
                break;
            case 2:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
                break;
            case 3:
                requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
                break;
        }

        if (config.getTransformation() != null) {//glide用它来改变图形的形状
            requestBuilder.transform(config.getTransformation());
        }

        //设置占位符
        if (config.getPlaceholder() != null) {
            requestBuilder.placeholder(config.getPlaceholder());
        } else if (config.getPlaceholderResId() != 0) {
            requestBuilder.placeholder(config.getPlaceholderResId());
        }

        if (config.getErrorPic() != 0)//设置错误的图片
            requestBuilder.error(config.getErrorPic());

        requestBuilder.skipMemoryCache(config.skipMemoryCache());

        requestBuilder.into(config.getImageView());
    }
项目:MvpPlus    文件:GlideImageLoaderStrategy.java   
/**
 * load image with Glide
 */
private void loadNetCache(Context ctx, ImageLoader img) {
    DrawableTypeRequest<String> urlTypeRequest = getUrlTypeRequest(ctx, img);
    DrawableRequestBuilder<String> builder = getDrawableRequestBuilder(ctx, img, urlTypeRequest);
    builder.crossFade(LoaderConfig.DEFAULT_DURATION_MS).into(img.imgView);
}
项目:MvpPlus    文件:GlideImageLoaderStrategy.java   
/**
 * load resource image with Glide
 */
private void loadResource(Context ctx, ImageLoader img) {
    DrawableTypeRequest<Integer> resTypeRequest = getResTypeRequest(ctx, img);
    DrawableRequestBuilder<Integer> builder = getDrawableRequestBuilder(ctx, img, resTypeRequest);
    builder.crossFade(LoaderConfig.DEFAULT_DURATION_MS).into(img.imgView);
}
项目:yyox    文件:GlideImageLoaderStrategy.java   
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
    RequestManager manager;
    if (ctx instanceof Activity)//如果是activity则可以使用Activity的生命周期
        manager = Glide.with((Activity) ctx);
    else
        manager = Glide.with(ctx);

    DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
            .crossFade()
            .centerCrop();

    switch (config.getCacheStrategy()) {//缓存策略
        case 0:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case 1:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case 2:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
            break;
        case 3:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
            break;
    }

    if (config.getTransformation() != null) {//glide用它来改变图形的形状
        requestBuilder.transform(config.getTransformation());
    }


    if (config.getPlaceholder() != 0)//设置占位符
        requestBuilder.placeholder(config.getPlaceholder());

    if (config.getErrorPic() != 0)//设置错误的图片
        requestBuilder.error(config.getErrorPic());

    requestBuilder
            .into(config.getImageView());
}
项目:MVVMFrames    文件:GlideImageLoader.java   
@Override
public void load(Context context, GlideImageConfig config) {
    this.check(context, config);

    RequestManager manager = Glide.with(context);

    DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .crossFade()// 默认显示淡入淡出动画
            ;

    // 缓存策略
    switch (config.getCacheStrategy()) {
        case 0:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case 1:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case 2:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
            break;
        case 3:
            requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
            break;
    }

    // 改变图形的形状
    if (config.getTransformation() != null) {
        requestBuilder.transform(config.getTransformation());
    }

    // 设置占位符
    if (config.getPlaceholder() != 0) {
        requestBuilder.placeholder(config.getPlaceholder());
    }

    // 设置错误的图片
    if (config.getError() != 0) {
        requestBuilder.error(config.getError());
    }

    requestBuilder.into(config.getImageView());
}