Search in sources :

Example 1 with NestSupportServiceManager

use of com.zhuinden.simplestackdemonestedstack.util.NestSupportServiceManager in project simple-stack by Zhuinden.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    NonConfigurationInstance nonConfigurationInstance = (NonConfigurationInstance) getLastCustomNonConfigurationInstance();
    if (nonConfigurationInstance != null) {
        serviceManager = nonConfigurationInstance.serviceManager;
        serviceTree = serviceManager.getServiceTree();
    } else {
        serviceTree = new ServiceTree();
        serviceTree.createRootNode(TAG);
        serviceManager = new NestSupportServiceManager(serviceTree, TAG);
        serviceManager.setRestoredStates(savedInstanceState != null ? savedInstanceState.getParcelable("SERVICE_BUNDLE") : new StateBundle());
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    backstack = Navigator.configure().setStateChanger(DefaultStateChanger.configure().setExternalStateChanger(this).create(this, root)).setStateClearStrategy(new PreserveTreeScopesStrategy(serviceTree)).install(this, root, HistoryBuilder.single(MainKey.create()));
}
Also used : PreserveTreeScopesStrategy(com.zhuinden.simplestackdemonestedstack.util.PreserveTreeScopesStrategy) NestSupportServiceManager(com.zhuinden.simplestackdemonestedstack.util.NestSupportServiceManager) ServiceTree(com.zhuinden.servicetree.ServiceTree) StateBundle(com.zhuinden.statebundle.StateBundle)

Aggregations

ServiceTree (com.zhuinden.servicetree.ServiceTree)1 NestSupportServiceManager (com.zhuinden.simplestackdemonestedstack.util.NestSupportServiceManager)1 PreserveTreeScopesStrategy (com.zhuinden.simplestackdemonestedstack.util.PreserveTreeScopesStrategy)1 StateBundle (com.zhuinden.statebundle.StateBundle)1