Conductor: Using MapView inside a Controller

Created on 7 Feb 2017  路  1Comment  路  Source: bluelinelabs/Conductor

I'm trying to get a MapView to work inside a Controller but I'm having trouble setting it up. MapView has to be bound to Activity/Fragment lifecycle to work properly.

Since a Controller lifecycle is different than that of its host Activity I can't use onActivity* callbacks (not that I haven't tried).

Calling MapView.onStart() and MapView.onResume() inside onAttach() doesn't work either. I'm wondering what should I do?

Most helpful comment

I think this was explained pretty well in #109. For a quick summary, use a RestoreViewOnCreateController, which allows you to get the view state bundle in onCreateView. The methods map as such:

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: #59

>All comments

I think this was explained pretty well in #109. For a quick summary, use a RestoreViewOnCreateController, which allows you to get the view state bundle in onCreateView. The methods map as such:

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: #59

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomblenz picture tomblenz  路  4Comments

EricKuck picture EricKuck  路  5Comments

EricKuck picture EricKuck  路  5Comments

Lancelittle picture Lancelittle  路  10Comments

EmkaMk picture EmkaMk  路  10Comments