Am Donnerstag, 26. März 2015 18:57:40 UTC+1 schrieb Anton Mityagin:
Why it's look like a design problem?Can I create ActivityManager with CachingActivityMapper and FilteredActivityMapper?Somthing like this:public CachingHorizontalMasterActivityMapper( HorizontalMasterActivityMapper horizontalMasterActivityMapper ) { FilteredActivityMapper.Filter filter = new FilteredActivityMapper.Filter() { @Overridepublic Place filter(Place place) {return place instanceof MailDetailPlace ? new MailListPlace() : place;}};CachingActivityMapper cachingActivityMapper = new CachingActivityMapper(horizontalMasterActivityMapper ); filteredActivityMapper = new FilteredActivityMapper(filter, cachingActivityMapper);}@Overridepublic Activity getActivity(Place place) {return filteredActivityMapper.getActivity(place); }This ActivityManager does not stop currently started activity MailListActivity if new place is MailDetailPlace, right?If, so, why ActivityManager ask current MailListActivitymayStop, if it will not stop it?
Good question, probably a design decision or its simply a bug/oversight. I think it would be fine to add the "currentActivity.equals(nextActivity) return" check for PlaceChangeRequestEvents as well to avoid the mayStop() call.
However others might already depend on that behavior of calling mayStop() on cached activities so its generally a breaking change although I think it won't affect a lot of people, if any at all.
Feel free to open a bug for it.
Is there in my words any logic?
Yes of course once I figured out that your ListEditActivity should save a list of items with one server request.
As a workaround, if you don't want to implement your own ActivityManager, you could probably do the following in your ListEditActivity:
public String mayStop() {
return null; // always return null.
}
public void start(AcceptsOneWidget panel, EventBus eventBus) {
eventBus.addHandler(PlaceChangeRequestEvent.TYPE, this);
}
// implement PlaceChangeRequestEvent.Handler in your Activity
public void onPlaceChangeRequest(PlaceChangeRequestEvent e) {
Place newPlace = e.getNewPlace();
if (/* check that newPlace would really cause this Activity to be stopped and not reused from cache */) {
if (unsavedChanges) {
e.setWarning("your warning message");
}
}
}
I think that should work as the mayStop() method should be called before your onPlaceChangeRequest() method is called. That means mayStop() won't reset the message back to null.
But a patched ActivityManager would be a cleaner solution, especially if you have that case more than once.
-- J.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment