use of com.bumptech.glide.request.RequestOptions in project anitrend-app by AniTrend.
the class GlideAppModule method applyOptions.
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
boolean isLowRamDevice = CompatUtil.isLowRamDevice(context);
MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).setMemoryCacheScreens(isLowRamDevice ? 2 : 3).build();
// Increasing cache & pool by 25% - default is 250MB
int memoryCacheSize = (int) (1.25 * calculator.getMemoryCacheSize());
int bitmapPoolSize = (int) (1.25 * calculator.getBitmapPoolSize());
int storageCacheSize = 1024 * 1024 * 350;
if (context.getExternalCacheDir() != null) {
long total = context.getExternalCacheDir().getTotalSpace();
storageCacheSize = (int) (total * 0.2);
}
builder.setMemoryCache(new LruResourceCache(memoryCacheSize));
builder.setBitmapPool(new LruBitmapPool(bitmapPoolSize));
builder.setDiskCache(new ExternalPreferredCacheDiskCacheFactory(context, storageCacheSize));
// Setting default params for glide
RequestOptions options = new RequestOptions().format(isLowRamDevice ? DecodeFormat.PREFER_RGB_565 : DecodeFormat.PREFER_ARGB_8888).timeout(KeyUtil.GLIDE_REQUEST_TIMEOUT).diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).error(CompatUtil.getDrawable(context, R.drawable.ic_broken_image_white_48dp, R.color.colorStateOrange));
builder.setDefaultRequestOptions(options);
}
use of com.bumptech.glide.request.RequestOptions in project scissors by lyft.
the class GlideBitmapLoader method load.
@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);
}
use of com.bumptech.glide.request.RequestOptions in project AntennaPod by AntennaPod.
the class CoverFragment method displayCoverImage.
private void displayCoverImage() {
RequestOptions options = new RequestOptions().diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).dontAnimate().transforms(new FitCenter(), new RoundedCorners((int) (16 * getResources().getDisplayMetrics().density)));
RequestBuilder<Drawable> cover = Glide.with(this).load(media.getImageLocation()).error(Glide.with(this).load(ImageResourceUtils.getFallbackImageLocation(media)).apply(options)).apply(options);
if (displayedChapterIndex == -1 || media == null || media.getChapters() == null || TextUtils.isEmpty(media.getChapters().get(displayedChapterIndex).getImageUrl())) {
cover.into(imgvCover);
} else {
Glide.with(this).load(EmbeddedChapterImage.getModelFor(media, displayedChapterIndex)).apply(options).thumbnail(cover).error(cover).into(imgvCover);
}
}
use of com.bumptech.glide.request.RequestOptions in project AntennaPod by AntennaPod.
the class ExternalPlayerFragment method updateUi.
private void updateUi(Playable media) {
if (media == null) {
return;
}
((MainActivity) getActivity()).setPlayerVisible(true);
txtvTitle.setText(media.getEpisodeTitle());
feedName.setText(media.getFeedTitle());
onPositionObserverUpdate(new PlaybackPositionEvent(media.getPosition(), media.getDuration()));
RequestOptions options = new RequestOptions().placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate();
Glide.with(getActivity()).load(ImageResourceUtils.getEpisodeListImageLocation(media)).error(Glide.with(getActivity()).load(ImageResourceUtils.getFallbackImageLocation(media)).apply(options)).apply(options).into(imgvCover);
if (controller != null && controller.isPlayingVideoLocally()) {
((MainActivity) getActivity()).getBottomSheet().setLocked(true);
((MainActivity) getActivity()).getBottomSheet().setState(BottomSheetBehavior.STATE_COLLAPSED);
} else {
butPlay.setVisibility(View.VISIBLE);
((MainActivity) getActivity()).getBottomSheet().setLocked(false);
}
}
use of com.bumptech.glide.request.RequestOptions in project AntennaPod by AntennaPod.
the class ItemFragment method updateAppearance.
private void updateAppearance() {
if (item == null) {
Log.d(TAG, "updateAppearance item is null");
return;
}
txtvPodcast.setText(item.getFeed().getTitle());
txtvTitle.setText(item.getTitle());
if (item.getPubDate() != null) {
String pubDateStr = DateFormatter.formatAbbrev(getActivity(), item.getPubDate());
txtvPublished.setText(pubDateStr);
txtvPublished.setContentDescription(DateFormatter.formatForAccessibility(getContext(), item.getPubDate()));
}
RequestOptions options = new RequestOptions().error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).transforms(new FitCenter(), new RoundedCorners((int) (4 * getResources().getDisplayMetrics().density))).dontAnimate();
Glide.with(getActivity()).load(item.getImageLocation()).error(Glide.with(getActivity()).load(ImageResourceUtils.getFallbackImageLocation(item)).apply(options)).apply(options).into(imgvCover);
updateButtons();
}
Aggregations