Hey there I'm pretty new to Glance and been just p...
# glance
v
Hey there I'm pretty new to Glance and been just playing around with the docs but couldn't find much in terms of how to approach a particular problem I have. 1. How do I approach the problem of triggering a UI refresh based on a network call. What is the recommended approach for doing this? 2. If I have a continuously recomposing Glance widget (like progressbar), do I have to always send in updates? If so can this only be done via protoDataStore?
c
I guess you refer to this documentation https://developer.android.com/jetpack/compose/glance/glance-app-widget But that’s how you actually update the state of your widget. Glance is just a „wrapper“ over the android widget apis and hi elements. So you still in the end use remote views and are also limited to those remotes views that are now wrapped into composables. You can read more about widget in the „original“ documentation. https://developer.android.com/develop/ui/views/appwidgets/overview
🙌 1
v
Thanks for the explanation, will dive deep into docs 👍
Got my first widget working, used CoroutineWorker from Work manager along with Hilt. Inject my API interface to the CoroutineWorker. Within the CoroutineWorker I'm calling the API needed and storing the results in a custom protoDataStore which when updated also updates the UI of the widget. The widget also has a refresh button when when pressed triggers an ActionCallback to enque said CoroutineWorker with some Params. Only difficulty is in managing states as I do that with protoDataStore directly (Error, Success &Loading). Also I don't suppose we can have something animating to show the loading progress like a Circular progress indicator ?