/** * DrawableRequestBuilder 的通行配置 * @param ctx 上下文 * @param img ImageLoader封装器 * @param typeRequest url or resource * @param <T> String or Integer * @return DrawableRequestBuilder<T> */ private <T> BitmapRequestBuilder<T, Bitmap> getBitmapRequestBuilder(Context ctx, ImageLoader img, BitmapTypeRequest<T> typeRequest) { BitmapRequestBuilder<T, Bitmap> builder = typeRequest.diskCacheStrategy(DiskCacheStrategy.ALL); // transform image type if (img.transType == LoaderConfig.TRANS_CIRCLE) { builder = builder.transform(new GlideCircleTransform(ctx)); } else if (img.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; }
@Override public void onBindViewHolder(ViewHolder holder, int position) { GankBean gankBean = mData.get(position); BitmapRequestBuilder<String, Bitmap> requestBuilder = Glide.with(mContext) .load(gankBean.url) .asBitmap() .diskCacheStrategy(DiskCacheStrategy.SOURCE) .transform(new GlideRoundTransform(mContext, 4)) .animate(R.anim.image_alpha_in) .error(R.color.accent); requestBuilder.into(new BitmapImageViewTarget(holder.ivGirlImg){ @Override protected void setResource(Bitmap resource) { holder.ivGirlImg.setOriginalSize(resource.getWidth(), resource.getHeight()); holder.ivGirlImg.setImageBitmap(resource); } }); }
public BitmapRequestBuilder<?, Bitmap> build() { //noinspection unchecked return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore) .asBitmap() .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .signature(createSignature(builder.song)); }
public BitmapRequestBuilder<?, BitmapPaletteWrapper> build() { //noinspection unchecked return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore) .asBitmap() .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .signature(createSignature(builder.song)); }
public BitmapRequestBuilder<?, Bitmap> build() { return createBaseRequest(builder.requestManager, builder.wallpaper) .asBitmap() .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION); }
public BitmapRequestBuilder<?, Bitmap> buildInt() { return createBaseRequest(builder.requestManager, builder.resId) .asBitmap() .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION); }
public BitmapRequestBuilder<?, BitmapPaletteWrapper> build() { return createBaseRequest(builder.requestManager, builder.wallpaper) .asBitmap() .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class) .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION); }
public BitmapRequestBuilder<?, BitmapPaletteWrapper> buildInt() { return createBaseRequest(builder.requestManager, builder.resId) .asBitmap() .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class) .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION); }
/** * 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, Bitmap> requestListener, Drawable placeholderOverride, boolean crop) { BitmapRequestBuilder 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); }
public BitmapRequestBuilder beginImageLoad(String url, RequestListener<String, Bitmap> requestListener, boolean crop) { if (crop){ return mGlideModelRequest.load(url) .listener(requestListener) .transform(mCenterCrop); } else { return mGlideModelRequest.load(url) .listener(requestListener); } }
public BitmapRequestBuilder<?, Bitmap> build() { //noinspection unchecked return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage, builder.forceDownload) .asBitmap() .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .priority(Priority.LOW) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .signature(createSignature(builder.artist)); }
public BitmapRequestBuilder<?, BitmapPaletteWrapper> build() { //noinspection unchecked return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage, builder.forceDownload) .asBitmap() .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .priority(Priority.LOW) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .signature(createSignature(builder.artist)); }
private void loadImage(Context context, ImageView imageView, int thumbWidth, int thumbHeight, int placeHolderResourceId, boolean full) { //TODO: Figure out why these can be <= 0. if (thumbWidth <= 0 || thumbHeight <=0) { return; } final int overrideWidth; final int overrideHeight; final BitmapRequestBuilder<Uri, Bitmap> thumbnailRequest; if (full) { // Load up to the maximum size Bitmap we can render. overrideWidth = Math.min(getWidth(), MAXIMUM_TEXTURE_SIZE); overrideHeight = Math.min(getHeight(), MAXIMUM_TEXTURE_SIZE); // Load two thumbnails, first the small low quality thumb from the media store, // then a medium quality thumbWidth/thumbHeight image. Using two thumbnails ensures // we don't flicker to grey while we load the maximum size image. thumbnailRequest = loadUri(context) .override(thumbWidth, thumbHeight) .fitCenter() .thumbnail(loadMediaStoreThumb(context)); } else { // Load a medium quality thumbWidth/thumbHeight image. overrideWidth = thumbWidth; overrideHeight = thumbHeight; // Load a single small low quality thumbnail from the media store. thumbnailRequest = loadMediaStoreThumb(context); } loadUri(context) .placeholder(placeHolderResourceId) .fitCenter() .override(overrideWidth, overrideHeight) .thumbnail(thumbnailRequest) .into(imageView); }
/** Loads an image using a MediaStore Uri with our default options. */ private BitmapRequestBuilder<Uri, Bitmap> loadUri(Context context) { return Glide.with(context) .loadFromMediaStore(getUri(), mMimeType, mDateModifiedInSeconds, mOrientation) .asBitmap() .encoder(JPEG_ENCODER); }
@Override public void loadImage( String url, ImageView imageView, Drawable placeholderOverride, boolean crop ) { BitmapRequestBuilder request = beginImageLoad(url, crop).animate(R.anim.fade_in_fast); if (placeholderOverride != null) { request.placeholder(placeholderOverride); } request.into(imageView); }
private BitmapRequestBuilder beginImageLoad( String url, boolean crop ) { if (crop) { return glideModelRequest.load(url).transform(centerCrop); } else { return glideModelRequest.load(url); } }
/** * 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) { BitmapRequestBuilder request = beginImageLoad(url, requestListener, crop) .animate(com.saarang.samples.apps.iosched.R.anim.image_fade_in); if (placeholderOverride != null) { request.placeholder(placeholderOverride); } else if (mPlaceHolderResId != -1) { request.placeholder(mPlaceHolderResId); } request.into(imageView); }
public BitmapRequestBuilder beginImageLoad(String url, RequestListener<String> requestListener, boolean crop) { return mGlideModelRequest.load(url) .asBitmap() // don't allow animated GIFs .listener(requestListener) .transform(crop ? mCenterCrop : mNone); }
/** * 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) { BitmapRequestBuilder 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); }