use of com.zhuinden.simplestack.BackstackManager in project simple-stack by Zhuinden.
the class Key method bindServices.
public void bindServices(ServiceTree.Node node) {
if (hasNestedStack()) {
BackstackManager backstackManager = new BackstackManager();
backstackManager.setStateClearStrategy(new PreserveTreeScopesStrategy(node.getTree()));
backstackManager.setup(initialKeys());
node.bindService(NESTED_STACK, backstackManager);
}
}
use of com.zhuinden.simplestack.BackstackManager in project simple-stack by Zhuinden.
the class NestSupportServiceManager method handleBack.
public boolean handleBack(Context context) {
ServiceTree serviceTree = ServiceLocator.getService(context, ServiceLocator.SERVICE_TREE);
Object lastKey = activeKeys.get(activeKeys.size() - 1);
Backstack backstack = Navigator.getBackstack(context);
class Cancellation {
private boolean cancelled;
}
Cancellation cancellation = new Cancellation();
serviceTree.traverseChain(serviceTree.getNode(lastKey), (node, cancellationToken) -> {
Object _key = node.getKey();
if (_key instanceof Key) {
// ROOT is defined by Activity's TAG
Key key = (Key) _key;
if (key.hasNestedStack()) {
BackstackManager backstackManager = serviceTree.getNode(key).getService(Key.NESTED_STACK);
if (backstackManager.getBackstack().goBack()) {
cancellation.cancelled = true;
cancellationToken.cancel();
}
}
}
});
if (cancellation.cancelled) {
return true;
}
return backstack.goBack();
}
use of com.zhuinden.simplestack.BackstackManager in project simple-stack by Zhuinden.
the class BackstackHost method initialize.
Backstack initialize(boolean isInitializeDeferred) {
if (backstackManager == null) {
backstackManager = new BackstackManager();
backstackManager.setKeyFilter(keyFilter);
backstackManager.setKeyParceler(keyParceler);
backstackManager.setStateClearStrategy(stateClearStrategy);
for (BackstackManager.StateChangeCompletionListener completionListener : stateChangeCompletionListeners) {
backstackManager.addStateChangeCompletionListener(completionListener);
}
backstackManager.setup(initialKeys);
if (savedInstanceState != null) {
backstackManager.fromBundle(savedInstanceState.<StateBundle>getParcelable("NAVIGATOR_STATE_BUNDLE"));
}
}
if (!isInitializeDeferred) {
backstackManager.setStateChanger(stateChanger);
}
return backstackManager.getBackstack();
}
Aggregations