/** * Returns a {@link RequestOptions} object with {@link #skipMemoryCache(boolean)} set. */ @NonNull @CheckResult public static RequestOptions skipMemoryCacheOf(boolean skipMemoryCache) { if (skipMemoryCache) { if (skipMemoryCacheTrueOptions == null) { skipMemoryCacheTrueOptions = new RequestOptions().skipMemoryCache(true).autoClone(); } return skipMemoryCacheTrueOptions; } else { if (skipMemoryCacheFalseOptions == null) { skipMemoryCacheFalseOptions = new RequestOptions().skipMemoryCache(false).autoClone(); } return skipMemoryCacheFalseOptions; } }
private static RequestBuilder<Bitmap> getRequestBuilder( RequestManager requestManager, int width, int height) { return requestManager .asBitmap() .apply( diskCacheStrategyOf(DiskCacheStrategy.NONE) .useAnimationPool(true) .skipMemoryCache(true) .override(width, height)); }
@Override public void load(@Nullable Object model, @NonNull ImageView imageView) { RequestOptions requestOptions = new RequestOptions(); requestOptions.skipMemoryCache(true) .diskCacheStrategy(DiskCacheStrategy.DATA) .transform(transformation); requestManager.asBitmap() .load(model) .apply(requestOptions); }
@Test public void isSkipMemoryCacheSet_withSkipMemoryCacheTrue_isTrue() { assertThat(options.skipMemoryCache(true).isSkipMemoryCacheSet()).isTrue(); }
@Test public void isSkipMemoryCacheSet_withSkipMemoryCacheFalse_isTrue() { assertThat(options.skipMemoryCache(false).isSkipMemoryCacheSet()).isTrue(); }
.addEqualityGroup(new RequestOptions().fallback(second)) .addEqualityGroup( new RequestOptions().skipMemoryCache(true), new RequestOptions().skipMemoryCache(true)) .addEqualityGroup( new RequestOptions(), new RequestOptions().skipMemoryCache(false), new RequestOptions().theme(null), new RequestOptions().onlyRetrieveFromCache(false),
/** * Returns a request to load the given byte array. * * <p> Note - by default loads for bytes are not cached in either the memory or the disk cache. * </p> * * @param model the data to load. * @see #load(Object) */ public RequestBuilder<TranscodeType> load(@Nullable byte[] model) { return loadGeneric(model).apply(signatureOf(new ObjectKey(UUID.randomUUID().toString())) .diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true /*skipMemoryCache*/)); }
@Override public void loadImageCall(String url, ImageView imageView, int placeholder, RequestListener<Drawable> listener) { Glide.with(imageView.getContext()) .load(url) .apply(new RequestOptions() .skipMemoryCache(true) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) .error(R.drawable.ic_bottom_bar_more) .centerCrop() ) .listener(listener) .into(imageView); }
/** * Returns a {@link RequestOptions} object with {@link #skipMemoryCache(boolean)} set. */ @CheckResult public static RequestOptions skipMemoryCacheOf(boolean skipMemoryCache) { if (skipMemoryCache) { if (skipMemoryCacheTrueOptions == null) { skipMemoryCacheTrueOptions = new RequestOptions().skipMemoryCache(true).autoClone(); } return skipMemoryCacheTrueOptions; } else { if (skipMemoryCacheFalseOptions == null) { skipMemoryCacheFalseOptions = new RequestOptions().skipMemoryCache(false).autoClone(); } return skipMemoryCacheFalseOptions; } }
/** * Allows the loaded resource to skip the memory cache. * * <p> Note - this is not a guarantee. If a request is already pending for this resource and that * request is not also skipping the memory cache, the resource will be cached in memory.</p> * * @param skip True to allow the resource to skip the memory cache. * @return This request builder. */ @CheckResult public RequestOptions skipMemoryCache(boolean skip) { if (isAutoCloneEnabled) { return clone().skipMemoryCache(true); } this.isCacheable = !skip; fields |= IS_CACHEABLE; return selfOrThrowIfLocked(); }
private void retrieveColors(final Uri uri) { if (uri == null) { return; } int[] imageDimens = Util .getImageDimensions(itemView.getContext(), uri); RequestOptions options = new RequestOptions() .skipMemoryCache(true) .override((int) (imageDimens[0] * 0.1f), (int) (imageDimens[1] * 0.1f)) .diskCacheStrategy(DiskCacheStrategy.NONE); Glide.with(itemView.getContext()) .asBitmap() .load(uri) .apply(options) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(@NonNull final Bitmap bitmap, com.bumptech.glide.request .transition.Transition<? super Bitmap> transition) { // Do something with bitmap here. Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() { @Override public void onGenerated(@NonNull Palette palette) { p = palette; setColors(null); } }); } }); }
Glide.with(getContext()) .load(R.drawable.error_placeholder) .apply(new RequestOptions().skipMemoryCache(true)) .into(image); return;
.apply(new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.RESOURCE) .skipMemoryCache(true)
.apply(new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.RESOURCE) .skipMemoryCache(true)
options.skipMemoryCache(imageConfig.isSkipMemoryCache()); return options;