Mortar / Flow save view and presenter in backstack

纵饮孤独 提交于 2019-12-12 16:18:36

问题


I'm playing with Mortar / Flow / Dagger2.
My app has 2 screens :

  • Screen 1 shows a Google map. I'm using directly the MapView object rather than the MapFragment, and I hooked it properly to the root activity lifecycle events.

  • Screen 2 shows some info from a map marker. We go from screen 1 to screen 2 through Flow.get(context).goTo(new Screen2());

The problem is that when I come back from screen 2 to screen 1, using Flow.get(context).goBack();, the screen 1 and its MapView are recreated from scratch, loosing previous state and etc. Indeed, I can see that both the view of screen1 and its presenter are destroyed when I navigate to screen 2. Thus, going back to screen 1 recreates everything again.

I know there is a mechanism for saving and restoring the view state in the Flow samples (I'm using it), but it seems to not be enough.

Is there a way to save and restore the state of screen 1's view and presenter, in the backstack ? In order to have the correct navigation workflow, just like it would be naturally done with Activity1 and Activity2.

Thanks!

来源:https://stackoverflow.com/questions/29190673/mortar-flow-save-view-and-presenter-in-backstack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!