Update model objects across different activities
- by Tom Esterez
Lets say I have 2 activities:
A: A ListView displaying articles titles. Data is fetched from a web server and converted from XML to a list of ArticleSummary. Only user titles and id are returned by the server. Click on a title starts activity B.
B: A form to edit an article. Article is fetched from server. When the user hits OK, modifications are sent to the server and activity closed.
When the user go back to activity A, I would like to update the article title without any additional web request.
I was thinking about the following solution:
When article is modified, send a broadcast event with article id and new attributes values.
Listen for this event on activity A
Update the ArticleSummary object
notify data changed on ListView
Is there a better approach ?