Conductor: [Question] Implement googleMaps API to controller

Created on 4 Sep 2016  路  5Comments  路  Source: bluelinelabs/Conductor

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?

Most helpful comment

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.

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MkhytarMkhoian picture MkhytarMkhoian  路  11Comments

EmkaMk picture EmkaMk  路  10Comments

adipascu picture adipascu  路  6Comments

ZakTaccardi picture ZakTaccardi  路  8Comments

PaulWoitaschek picture PaulWoitaschek  路  5Comments