com.bumptech.glide.GenericRequestBuilder Java Examples
The following examples show how to use
com.bumptech.glide.GenericRequestBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GifFrameLoader.java From giffun with Apache License 2.0 | 6 votes |
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); }
Example #2
Source File: GlideFilmstripManager.java From Camera2 with Apache License 2.0 | 5 votes |
/** * Create a small thumbnail sized image that has the same bounds as the * media store thumbnail images. * <p> * If the Uri points at an animated gif, the gif will not play. */ public GenericRequestBuilder<Uri, ?, ?, GlideDrawable> loadMediaStoreThumb(Uri uri, Key key) { Size size = clampSize(MEDIASTORE_THUMB_SIZE, MAXIMUM_SMOOTH_PIXELS, getMaxImageDisplaySize()); return mTinyImageBuilder .clone() .load(uri) .signature(key) // This attempts to ensure we load the cached media store version. .override(size.width(), size.height()); }
Example #3
Source File: GlideFilmstripManager.java From Camera2 with Apache License 2.0 | 5 votes |
/** * Create very tiny thumbnail request that should complete as fast * as possible. * <p> * If the Uri points at an animated gif, the gif will not play. */ public GenericRequestBuilder<Uri, ?, ?, GlideDrawable> loadTinyThumb(Uri uri, Key key) { Size size = clampSize(TINY_THUMB_SIZE, MAXIMUM_SMOOTH_PIXELS, getMaxImageDisplaySize()); return mTinyImageBuilder .clone() .load(uri) .signature(key) .override(size.width(), size.height()); }
Example #4
Source File: GlideLoader.java From tenor-android-core with Apache License 2.0 | 5 votes |
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; }
Example #5
Source File: GlideLoader.java From tenor-android-core with Apache License 2.0 | 5 votes |
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); } }); }
Example #6
Source File: DrawableGetter.java From mvvm-template with GNU General Public License v3.0 | 5 votes |
@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; }
Example #7
Source File: ArtistViewModel.java From Jockey with Apache License 2.0 | 5 votes |
@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; }
Example #8
Source File: ThumbnailView.java From Silence with GNU General Public License v3.0 | 5 votes |
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); }
Example #9
Source File: MainModule.java From MoeGallery with GNU General Public License v3.0 | 5 votes |
@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())); }
Example #10
Source File: LoadCycler.java From glide-support with The Unlicense | 4 votes |
private GenericRequestBuilder<M, ?, ?, T> copy(GenericRequestBuilder<M, ?, ?, T> request) { return request.clone().dontAnimate().thumbnail(null).listener(null).load(null); }
Example #11
Source File: GlideImageGetter.java From RichText with MIT License | 4 votes |
@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; }
Example #12
Source File: AlbumViewModel.java From Jockey with Apache License 2.0 | 4 votes |
@Bindable public GenericRequestBuilder getHeroImage() { return Glide.with(getContext()).load(mAlbum.getArtUri()).centerCrop(); }
Example #13
Source File: GlideBindingAdapters.java From Jockey with Apache License 2.0 | 4 votes |
@BindingAdapter("android:src") public static void bindImage(ImageView imageView, GenericRequestBuilder request) { if (request != null) { request.into(imageView); } }
Example #14
Source File: ThumbnailView.java From Silence with GNU General Public License v3.0 | 4 votes |
private GenericRequestBuilder buildPlaceholderGlideRequest(Slide slide) { return Glide.with(getContext()).load(slide.getPlaceholderRes(getContext().getTheme())) .asBitmap() .fitCenter(); }
Example #15
Source File: LoadCycler.java From glide-support with The Unlicense | 4 votes |
private void rotate() { GenericRequestBuilder<M, ?, ?, T> temp = prev; prev = curr; curr = next; next = temp; }
Example #16
Source File: LoadCycler.java From glide-support with The Unlicense | 4 votes |
public LoadCycler(GenericRequestBuilder<M, ?, ?, T> request, Target<? super T> target) { this.target = target; prev = copy(request); curr = copy(request); next = copy(request); }
Example #17
Source File: LoadCycler.java From glide-support with The Unlicense | 4 votes |
public LoadCycler(GenericRequestBuilder<M, ?, ?, T> request, ImageView imageView) { this(request, new DrawableImageViewTarget(imageView)); }
Example #18
Source File: PhotoItem.java From Camera2 with Apache License 2.0 | 4 votes |
private GenericRequestBuilder<Uri, ?, ?, GlideDrawable> renderTinySize(Uri uri) { return mGlideManager.loadTinyThumb(uri, generateSignature(mData)); }