Thursday, March 26, 2015

Re: How to filter some places in onPlaceChangeRequest in ActivityManager?



On Thursday, March 26, 2015 at 10:37:33 PM UTC+3, Jens wrote:


Am Donnerstag, 26. März 2015 18:57:40 UTC+1 schrieb Anton Mityagin:



If, so, why ActivityManager ask current MailListActivity mayStop, 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. 

But in PlaceChangeRequestEvent handled before PlaceChangeEvent and there is no nextActivity in handler PlaceChangeRequestEvent.

I think that problem in ActivityMapper. It has a logic to get next activity, but it is used only on handler of PlaceChangeEvent.

It needs to resuse it some way in handler of PlaceChangeRequestEvent to prevent unnecessary call of mayStop and duplicate logic of ActivityMapper in some workaround


Feel free to open a bug for it.

Do you mean open bug over there https://code.google.com/p/google-web-toolkit/issues/list?cursor=google-web-toolkit%3A6794 ?
 

 
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.


Your idea is perfect and it's works!!!

My first post was for this good idea! Thank you
 
-- 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