Implement a Coordinator to manage lifecycle
masterA Coordinator provides a simple lifecycle for managing components (like 'MVWhatever' patterns) on Android. To use it, extend the Coordinator class and override the attach and detach methods:
attach(View view): Use this to attach listeners, load state, or perform initialization when the view becomes active.detach(View view): Use this to unbind listeners, save state, or perform cleanup when the view is removed.
class ExampleCoordinator extends Coordinator {
@Override public void attach(View view) {
// Attach listeners, load state, whatever.
}
@Override public void detach(View view) {
// Unbind listeners, save state, go nuts.
}
}