当前位置:网站首页>Glide advanced level

Glide advanced level

2022-07-05 10:11:00 asahi_ xin

cache

  • skipMemoryCache(true/false) Whether to skip memory cache .

skipMemoryCache That means Glide Will not put pictures into memory cache . The default is false, So you don't need to call .

 Glide.with(this)
                .load(" Address ")
                .skipMemoryCache(true)
                .into(imageView);

When skipping memory cache ,Glide Disk cache will still be used to avoid repeated network requests .


Glide Not only the original image is cached , It also caches full resolution images and other small versions of images . such as , If an image you request is 1000x1000 Pixel , But yours. ImageView yes 500x500 Pixel ,Glide These two sizes will be cached .

If a picture has the same URL, But changes are fast , You may want to disable even disk caching .

  • diskCacheStrategy Skip disk cache , Take enumeration as a parameter , The parameters are as follows .
Parameters Meaning
DiskCacheStrategy.NONE Don't cache
DiskCacheStrategy.SOURCE Just cache the original full resolution image
DiskCacheStrategy.RESULT Only the final image is cached
DiskCacheStrategy.ALL Cache all versions of images ( Default )
  Glide.with(this)
                .load(" Address ")
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .skipMemoryCache(true)
                .into(imageView);

Request priority

We often have this need , A screen , To request multiple pictures at the same time , But pictures have priority .Glide There is a treatment in this regard .

  • priority Priority of image loading . Method parameters are also enumeration types .
  1. Priority.LOW
  2. Priority.NORMAL
  3. Priority.HIGH
  4. Priority.IMMEDIATE
  Glide.with(this)
                .load(" Address ")
                .priority(Priority.HIGH)
                .into(imageView);
原网站

版权声明
本文为[asahi_ xin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140534181900.html