Wednesday, January 4, 2012

Re: Basic question on activity and places

A quick followup question.
You have mentioned Display Area. From the response, I take it a Place
is bigger than a display area and multiple Display Areas make up a
place.right?

Yes, you could say it that way. 

A place is just an abstract tool that allows you to navigate through your app and storing state information. It has no real relation to display areas. A place does not know anything about display areas. You could have one, five or ten display areas. 

Imagine you are in a plane flying around the world. If the plane has three windows (front, left, right) you would see something different through each window (= display area). What you see depends on where you are (= place). But the place doesn't care about if you are in a plane looking through the left window ;-)
 

So if there is one ActivityMapper per Display Area, which would
indicate multiple ActivityMappers per Place, which component is
responsible for deciding which ActivityMapper be used when you are in
a Place?


When you change a place a PlaceChangeRequestEvent is fired on the EventBus and if the place change is allowed a PlaceChangeEvent is fired after it. For each display area you have to set up an ActivityManager (manages activity life cycle and clears the display area if the activity is stopped) which needs an ActivityMapper and an EventBus. So the ActivityManager listens for PlaceChange(Request)Events on the EventBus and ask the ActivityMapper for the activity it should use for a given place.

So in your app's init method you would have some code like:

EventBus eventbus = ....;
ActivityManager masterActivityManager = new ActivityManager(new MasterActivityMapper(), eventbus);
masterActivityManager.setDisplay(appShell.getMasterDisplayArea());

ActivityManager detailsActivityManager = new ActivityManager(new DetailsActivityMapper(), eventbus);
detailsActivityManager.setDisplay(appShell.getDetailsDisplayArea());

Now on a place change the ActivityManagers act totally independent from each other. But as you are responsible for implementing the ActivityMappers you can decide what each display area should show for a given place by returning the activity you want. So the component that decides which ActivityMapper is used is the developer that writes the app's init method ;-) 

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/0Q0e3ernr-AJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment