How to properly compress images for recycler view


I have a recycler view displaying multiple images\details from a SQL DB. I have tossed a few ideas back and forth about how to best display the images but I've run into a couple issues.

Initially I just took pictures via the phones camera, saved those to the filesdir and then reloaded those into the recycler view when a that page is accessed. However this made navigating the view horrendously slow with just a few images, so I tried to compress them to smaller bitmap formats which works but now I'm converting all images on loading that view meaning users wait ~4-5 seconds for it to convert them all, but at least the recycler view is fast.

What I think I'd like to actually do is convert the images just after taking them and save them in that compressed format so I get the best of both worlds. However I have not been able to figure out how to take the converted bitmap I make and overwrite the ImageURI I generated from taking the picture.

Any advice on how I could accomplish that or possibly better recommendations on how to approach?

0
Mar 24 at 11:18 PM
User AvatarAaron Lind
#android#kotlin#bitmap#uri

Accepted Answer

You don't mention if you are using an existing image caching library like glide and the size of the images you are displaying as the camera image can be larger than the display. Also clarify if the image is in the cloud (subject to network latency but preview images can be downsized to fit the device display) or completely local (camera app).

User AvatarMorrison Chang
Mar 25 at 5:17 AM
1