Any thoughts how to add google map to controller?
As MapView doc suggests, you have to add some lifecycle calls to corresponding Activity/Fragment parent methods:
onCreate, onResume, onLowMemory, onDestroy, onPause, onSaveInstanceState.
Where should I put these calls inside my controller?
You can use a MapView and forward on lifecycle events using ActivityLifecycleCallbacks, but it does take a bit of wiring up.
Thanks for the tip. I'll try to play with it.
if you know some resources with similar solution implemented, they are very welcome.
You'd handle a MapView in a Controller much the same way you'd handle it in a Fragment.
onCreateView -> create the mapview, then call onCreate on it
onAttach -> call onResume
onDetach -> call onPause
onDestroyView -> call onDestroy
onSaveViewState -> call onSaveInstanceState
For onLowMemory, see this issue: https://github.com/bluelinelabs/Conductor/issues/59
The one complication here is that the saved view state is not available in onCreateView like it is in Fragments, so restoring the state gets tricky. I'm interested to hear if anyone's found a good solution for this.
To close this out, 960b9317449f8b5507e05774d4ab7828b1bcee1c adds a view state getter so that you can now call onCreate on the map view with the saved state bundle.
Just a heads up that 39ab4723ffd261651e1aa8d78d8992743b54b8ea changes the way the onCreate call will be made to Google Maps. A simple Controller subclass, named RestoreViewOnCreateController has been added with a different onCreateView signature, which now includes a saved view state.
Most helpful comment
You'd handle a
MapViewin aControllermuch the same way you'd handle it in aFragment.onCreateView-> create the mapview, then callonCreateon itonAttach-> callonResumeonDetach-> callonPauseonDestroyView-> callonDestroyonSaveViewState-> callonSaveInstanceStateFor
onLowMemory, see this issue: https://github.com/bluelinelabs/Conductor/issues/59The one complication here is that the saved view state is not available in
onCreateViewlike it is inFragments, so restoring the state gets tricky. I'm interested to hear if anyone's found a good solution for this.