Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image loading with Glide in GridView is too slow

I am showing about 50+ images with url from server in GridView which has image(120*120) when loading images taking too much time. Average original images size is around 50-200 KB

Glide Code:

In GridViewAdapter

RequestOptions reqOpt = RequestOptions.fitCenterTransform().transform(new RoundedCorners(5));
    ...
GlideApp
      .with(context)
      .load(item.getUrl())
      .apply(reqOpt)
      .placeholder(R.drawable.place_holder)
      .into(holder.ivThumb);

In Gradle

...
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
...
like image 913
ld-sr-dev Avatar asked Oct 19 '25 02:10

ld-sr-dev


2 Answers

Try this,

It'll optimize your memory for loading images.

RequestOptions reqOpt = RequestOptions
                            .fitCenterTransform()
                            .transform(new RoundedCorners(5))
                            .diskCacheStrategy(DiskCacheStrategy.ALL) // It will cache your image after loaded for first time
                            .override(holder.ivThumb.getWidth(),holder.ivThumb.getHeight()) // Overrides size of downloaded image and converts it's bitmaps to your desired image size;

Checkout more from here : Glide reference

like image 83
Jeel Vankhede Avatar answered Oct 21 '25 16:10

Jeel Vankhede


You can use in Thumbnail -

GlideApp.with(context)
 .load(item.getUrl())
 .thumbnail(/*sizeMultiplier=*/ 0.25f)
 .apply(reqOpt)
 .placeholder(R.drawable.place_holder)
 .into(holder.ivThumb);
like image 40
offset Avatar answered Oct 21 '25 15:10

offset



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!