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'
...
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
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With