Resolving state provided by place in a central class

23 views
Skip to first unread message

tanteanni

unread,
Mar 19, 2012, 8:44:27 AM3/19/12
to google-we...@googlegroups.com
in my application most activities rely on infos provided by current place. all infos of such place define the state of activity. the problem is that all infos are provided as strings and must be resolved to objects (i.e. userID=0815 must be resolved to a user object). In my case many activities share such a state (ShowUserActivity, SelectUserActivity both need "current(Selected)User"). At the moment the code to resolve a state is redundant across those activities -- very bad.

So i want to centralize each kind of state. In many cases async. services are needed to resolve the infos. So how is a good way to centralize this asynchronous process? One Idea i have in mind is to let this class hear PlaceChangeEvents to update itself. Because of the asynchronous nature of the update i probably need a UpdateStateEvent and each activity must register to it.

But is there a way to defer the loading of an activity 'til state is resolved (there is no need to start the activity). Or in general is there a way to make asynchronous calls synchronous by deferring until "onSuccess"/"onFailure"? 
Or this all is probably bullshit and you have a better idea to solve this kind of problem? 
Reply all
Reply to author
Forward
0 new messages