I have a simple page, with a small form and a table for results. When the user clicks the "Search" button, I'd like the form contents to saved in the URL, so that the search is "bookmarkable". So what I would really like to do is to update the URL (place) without triggering the whole MVP machinery (my current activity can handle the new place without restarting).
How can I do that? I tried to mess with the History class directly, but then the back button behave s开发者_运维技巧trangely. Looking at SO I found out about the CachingActivityMapper, but I'm not sure whether that's the "right" approach.
CachingActivityMapper (or anything similar) is the right approach.
The thing is, if an ActivityMapper returns the same instance (really the same, not even an instance that compares equals()
) as the current activity, then the ActivityManager does nothing (particularly, doesn't restart the activity).
Note however that it really does nothing, so your activity will have to listen to PlaceChangeEvent
s ti be notified of the change (or your ActivityMapper could "notify" it before returning it to the ActivityManager; this is basically the approach taken by the Expenses sample, where activities are singletons, and the ActivityMappers calls setPlace
on them).
精彩评论