Wednesday, January 23, 2013

[android-developers] Re: Android MVC

1. Observer Pattern is the most obvious choice. I've used it plenty in my apps to achieve such behavior. (you can either implement your own or use existing android services like BroadcastRecievers)
2. Fragments do seem appropriate to what you're talking about. 

On Wednesday, January 23, 2013 12:53:49 AM UTC+2, dashman wrote:
I'm starting to write an app that'll have several separate screens - maybe displayed
on the page at the same time (using Fragments) - maybe not.

They all share a global app state. That is, if one screen modifies the state, I want it
notified autmatically to the other screens. In the olden days it used to be
called MVC design. i want my app logic to be centralized with all the views sharing
a single instance and be notified when someting changes.


To implement this, Application() sub-class seems to fit the bill.

1. If one screen changes a global variable - how to do notify the other pages of the
change.

2.In android my understanding is that there can be one 1 activity active on the screen.
There's just 1 FragmentActivity active - displaying multple Fragments right?

In my case I would all the Fragments to share the same getApplication() object - but
be able to notify all the fragments on state change.


Any suggestions how how to optimally design the app - appreciated.


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment