Refreshing only updated widgets, not all the fragments
See original GitHub issueI open this issue to discuss how we could improve the refresh of data in the app.
Currently when we receive a new information from the server, notifyDataSetChanged is called which leads to the refresh of all the fragments. The best would be to trigger the refresh of only updated widgets (like it is done in Basic UI for example). We are able to easily identify them when using SSE.
@9a4gl commented with a possible solution: https://github.com/openhab/openhab.android/issues/217#issuecomment-354495701
I link to my issue #555 but the new goal would be a more ambitious fix 😉
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (9 by maintainers)
Top Results From Across the Web
android - Refreshing data display on a fragment
I have two fragments on a view pager. I once had to move data from fragment B to A and refresh the data...
Read more >Home screen widgets not updating
Hello. After updating to iOS 16 all all widgets that should be updated every second stopped working. They are not updating.
Read more >appWidgetManager.updateAppWidget not updating widgets ...
When installing a widget onto a freshly wiped or newly created AVD, appWidgetManager.updateAppWidget calls are not updating the respective widgets.
Read more >Create an advanced widget
This page explains recommended practices for creating a more advanced widget that has a better user experience. Optimizations for updating widget content.
Read more >WooCommerce: Why & How to Disable Ajax Cart Fragments
wc-ajax=get_refreshed_fragments” active, or the widget won't refresh if you update the Cart. Conclusion: if your theme does NOT have a dynamic header Cart ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Just an update. Good news. Today I made a proof of concept. I replaced ListView with RecyclerView, then when I update the content I do call notifyUpdateChange only on items that are not Webview which result that Webview is not refreshed on every data change if it is visible. So, I can confirm RecyclerView is the way to go.
Unfortunately my current code breaks a lot of other features and is ugly, will try to make it better, hopefully it can become pull request one day, if not for merge, maybe as inspiration to continue on this topic.
Refreshing icons that has not changed is not so annoying… Real problems came when you start using Webview, refreshing Webview with grafana item each second make it flashing and you do not see graph at all. My plan is also to use webrtc video stream in Webview, that will not work at all, too.
While I was debugging I also noticed that parent page items are fetched and refreshed too, haven’t look into details if that cause refreshing. Anyway that sounds to me a separate issue and should be handled separately.
From one of my previous projects I remember and I can confirm notifyDataSetChanged cause refreshing ONLY visible items, but also those not changed. Thats why Google introduced RecyclerView where you can actually define which item has changed, and not only if changed but how, so it can perform fancy animation in case of adding or removing item. But, to implement that properly we need unique id for each item, we need to keep previous items, then perform add/remove/change item in adapter. But after quick look at json we fetch from server, I am not sure we can do that.
I hope I will have some spare time next days and will try proof of concept with RecyclerView. I will report if that make sense or not.