use of com.example.mortar.nodes.NodeCreationManager in project simple-stack by Zhuinden.
the class MortarDemoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
// no need to restore if no process death could have occurred
DID_RESTORE_AFTER_PROCESS_DEATH = true;
}
if (savedInstanceState != null && !DID_RESTORE_AFTER_PROCESS_DEATH) {
DID_RESTORE_AFTER_PROCESS_DEATH = true;
StateBundle rootBundle = savedInstanceState.getParcelable(NodeStateManager.SERVICE_STATES);
if (rootBundle != null) {
// global service state is restored after process death
// not yet injected by field injection
SingletonComponent singletonComponent = DaggerService.get(this);
ServiceTree _serviceTree = singletonComponent.serviceTree();
NodeStateManager _nodeStateManager = singletonComponent.nodeStateManager();
_serviceTree.registerRootService(NodeStateManager.SERVICE_STATES, rootBundle);
// root services should be restored after process death
_nodeStateManager.restoreStatesForNode(_serviceTree.getTreeRoot());
}
}
ServiceTree.Node parentScope = TreeNodes.getNode(getApplication());
String scopeName = getLocalClassName() + "-task-" + getTaskId();
if (!parentScope.hasChild(scopeName)) {
parentScope.createChild(scopeName);
}
activityScope = parentScope.getChild(scopeName);
DaggerService.<SingletonComponent>get(this).inject(this);
actionBarOwner.takeView(this);
setContentView(R.layout.root_layout);
container = (FrameLayout) findViewById(R.id.container);
Navigator.configure().setKeyParceler(keyParceler).addStateChangeCompletionListener(new NodeClearManager(serviceTree, // to delete un-used mortar scopes
nodeStateManager)).setStateChanger(DefaultStateChanger.configure().setExternalStateChanger(this).setContextCreationStrategy(new NodeCreationManager(serviceTree, activityScope, nodeStateManager)).create(this, container)).install(this, container, HistoryBuilder.single(ChatListScreen.create()));
}
Aggregations