use of com.zhuinden.statebundle.StateBundle in project simple-stack by Zhuinden.
the class AddOrEditTaskPresenter method toBundle.
@Override
public StateBundle toBundle() {
StateBundle bundle = new StateBundle();
bundle.putString("title", title);
bundle.putString("description", description);
return bundle;
}
use of com.zhuinden.statebundle.StateBundle in project simple-stack by Zhuinden.
the class FirstView method toBundle.
@Override
public StateBundle toBundle() {
StateBundle bundle = new StateBundle();
bundle.putString("HELLO", "WORLD");
return bundle;
}
use of com.zhuinden.statebundle.StateBundle in project simple-stack by Zhuinden.
the class MortarDemoApplication method getSystemService.
@Override
public Object getSystemService(String name) {
if (serviceTree == null) {
serviceTree = new ServiceTree();
serviceTree.registerRootService(DaggerService.SERVICE_NAME, DaggerSingletonComponent.builder().rootModule(new RootModule(serviceTree)).build());
serviceTree.registerRootService(NodeStateManager.SERVICE_STATES, new StateBundle());
// MortarScope.buildRootScope()
//.withService(ObjectGraphService.SERVICE_NAME, ObjectGraph.create(new RootModule()))
//.build("Root");
}
if (serviceTree.hasRootService(name)) {
return serviceTree.getRootService(name);
}
if (TreeNodes.NODE_TAG.equals(name)) {
return serviceTree.getTreeRoot();
}
return super.getSystemService(name);
}
use of com.zhuinden.statebundle.StateBundle in project simple-stack by Zhuinden.
the class NodeStateManager method restoreStatesForNode.
public void restoreStatesForNode(ServiceTree.Node node) {
StateBundle rootBundle = serviceTree.getRootService(SERVICE_STATES);
StateBundle localBundle = rootBundle.getBundle(node.getKey().toString());
Log.i(TAG, "Restoring state for [" + node.getKey().toString() + "] with bundle [" + localBundle + "]");
for (ServiceTree.Node.Entry entry : node.getBoundServices()) {
Log.i(TAG, "Restoring state for service [" + entry.getName() + "]");
if (entry.getService() instanceof Bundleable) {
((Bundleable) entry.getService()).fromBundle(localBundle == null ? null : localBundle.getBundle(entry.getName()));
}
}
}
use of com.zhuinden.statebundle.StateBundle in project simple-stack by Zhuinden.
the class BackstackManager method persistViewToState.
// ----- viewstate persistence
/**
* Provides the means to save the provided view's hierarchy state
* and its optional StateBundle via {@link Bundleable} into a {@link SavedState}.
*
* @param view the view that belongs to a certain key
*/
public void persistViewToState(@Nullable View view) {
if (view != null) {
Object key = KeyContextWrapper.getKey(view.getContext());
if (key == null) {
throw new IllegalArgumentException("The view [" + view + "] contained no key!");
}
SparseArray<Parcelable> viewHierarchyState = new SparseArray<>();
view.saveHierarchyState(viewHierarchyState);
StateBundle bundle = null;
if (view instanceof Bundleable) {
bundle = ((Bundleable) view).toBundle();
}
SavedState previousSavedState = //
SavedState.builder().setKey(//
key).setViewHierarchyState(//
viewHierarchyState).setBundle(//
bundle).build();
keyStateMap.put(key, previousSavedState);
}
}
Aggregations