Search in sources :

Example 81 with RequestOptions

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);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) MemorySizeCalculator(com.bumptech.glide.load.engine.cache.MemorySizeCalculator) GlideBuilder(com.bumptech.glide.GlideBuilder) LruBitmapPool(com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool) ExternalPreferredCacheDiskCacheFactory(com.bumptech.glide.load.engine.cache.ExternalPreferredCacheDiskCacheFactory) LruResourceCache(com.bumptech.glide.load.engine.cache.LruResourceCache)

Example 82 with RequestOptions

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);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 83 with 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);
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Drawable(android.graphics.drawable.Drawable) FitCenter(com.bumptech.glide.load.resource.bitmap.FitCenter) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners)

Example 84 with RequestOptions

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);
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) MainActivity(de.danoeh.antennapod.activity.MainActivity) PlaybackPositionEvent(de.danoeh.antennapod.event.playback.PlaybackPositionEvent)

Example 85 with RequestOptions

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();
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) FitCenter(com.bumptech.glide.load.resource.bitmap.FitCenter) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners)

Aggregations

RequestOptions (com.bumptech.glide.request.RequestOptions)96 ImageView (android.widget.ImageView)23 View (android.view.View)18 Drawable (android.graphics.drawable.Drawable)16 TextView (android.widget.TextView)13 Bitmap (android.graphics.Bitmap)9 BitmapDrawable (android.graphics.drawable.BitmapDrawable)8 File (java.io.File)8 Uri (android.net.Uri)7 ColorDrawable (android.graphics.drawable.ColorDrawable)6 Context (android.content.Context)5 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)5 DataSource (com.bumptech.glide.load.DataSource)5 GlideException (com.bumptech.glide.load.engine.GlideException)5 FitCenter (com.bumptech.glide.load.resource.bitmap.FitCenter)5 RoundedCorners (com.bumptech.glide.load.resource.bitmap.RoundedCorners)5 Test (org.junit.Test)5 Activity (android.app.Activity)3 LayoutInflater (android.view.LayoutInflater)3