Update model objects across different activities
Posted
by
Tom Esterez
on Stack Overflow
See other posts from Stack Overflow
or by Tom Esterez
Published on 2011-01-04T21:39:02Z
Indexed on
2011/01/04
21:54 UTC
Read the original article
Hit count: 193
android
|architecture
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 ?
© Stack Overflow or respective owner