Mortar / Flow save view and presenter in backstack

497 Views Asked by At

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!

0

There are 0 best solutions below