https://kotlinlang.org logo
#glance
Title
# glance
a

andrew

05/27/2022, 6:05 PM
Also, is there a recommended way to load a bunch of images remotely in a lazy column?
m

Marcel Pinto

06/09/2022, 12:25 PM
it’s a bit tricky. Ideally you would pre-load them, store in cache and get the URI. Now, you have to make sure the URI provides read access or that the files are accessible otherwise 3rd party launchers won’t be able to display them. https://developer.android.com/training/secure-file-sharing To load the images, better use a WorkManager and once loaded, just update the widget
a

andrew

06/09/2022, 1:55 PM
Are there any plans to make this simpler?
m

Marcel Pinto

06/09/2022, 1:56 PM
unfortunately that is a platform limitation, we are exploring ways to make the loading/async tasks simpler, but the way RemoteViews handle images cannot be changed.
a

andrew

06/09/2022, 1:57 PM
Gotcha, that makes sense, thank you!
m

Marcel Pinto

06/09/2022, 1:58 PM
You can either use resourceIds, bitmaps or URIs. The problem with bitmaps is that you might exceed the RemoteViews max size, so URIs is the better choice
a

andrew

06/09/2022, 1:59 PM
Gotcha, I'm currently rewriting our widget and weighing the options using this, other devs on our team decided to use bitmaps
m

Marcel Pinto

06/09/2022, 2:00 PM
if it’s small and not too many it might be okay, otherwise you might hit the size limit
a

andrew

06/09/2022, 2:01 PM
The images are full size, some quite large
There's no CDN backing either with support of scaling down
m

Marcel Pinto

06/09/2022, 2:04 PM
you could get the available size for the widget, reduce the images locally and store them
4 Views