本文整理汇总了Java中com.zhuinden.simplestack.Bundleable类的典型用法代码示例。如果您正苦于以下问题:Java Bundleable类的具体用法?Java Bundleable怎么用?Java Bundleable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Bundleable类属于com.zhuinden.simplestack包,在下文中一共展示了Bundleable类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: persistStates
import com.zhuinden.simplestack.Bundleable; //导入依赖的package包/类
public StateBundle persistStates() {
final StateBundle serviceStates = new StateBundle();
serviceTree.traverseTree(ServiceTree.Walk.PRE_ORDER, new ServiceTree.Walk() {
@Override
public void execute(@NonNull ServiceTree.Node node, @NonNull CancellationToken cancellationToken) {
StateBundle keyBundle = new StateBundle();
for(ServiceTree.Node.Entry entry : node.getBoundServices()) {
if(entry.getService() instanceof Bundleable) {
keyBundle.putParcelable(entry.getName(), ((Bundleable) entry.getService()).toBundle());
}
}
serviceStates.putParcelable(node.getKey().toString(), keyBundle);
}
});
return serviceStates;
}
示例2: persistStates
import com.zhuinden.simplestack.Bundleable; //导入依赖的package包/类
public StateBundle persistStates() {
StateBundle serviceStates = new StateBundle();
serviceTree.traverseTree(ServiceTree.Walk.PRE_ORDER, (node, cancellationToken) -> {
StateBundle keyBundle = new StateBundle();
for(ServiceTree.Node.Entry entry : node.getBoundServices()) {
if(entry.getService() instanceof Bundleable) {
keyBundle.putParcelable(entry.getName(), ((Bundleable) entry.getService()).toBundle());
}
}
serviceStates.putParcelable(node.getKey().toString(), keyBundle);
});
return serviceStates;
}
示例3: restoreServiceStateForKey
import com.zhuinden.simplestack.Bundleable; //导入依赖的package包/类
private void restoreServiceStateForKey(StateBundle states, Key key, ServiceTree.Node node) {
if(states != null) {
StateBundle keyBundle = states.getParcelable(key.toString());
if(keyBundle != null) {
List<ServiceTree.Node.Entry> entries = node.getBoundServices();
for(ServiceTree.Node.Entry entry : entries) {
if(entry.getService() instanceof Bundleable) {
((Bundleable) entry.getService()).fromBundle(keyBundle.getParcelable(entry.getName()));
}
}
}
}
}
示例4: setViewModel
import com.zhuinden.simplestack.Bundleable; //导入依赖的package包/类
public <T> void setViewModel(@NonNull T viewModel) {
checkNotNull(viewModel);
this.viewModel = viewModel;
if(savedInstanceState != null) {
if(viewModel instanceof Bundleable) {
((Bundleable) viewModel).fromBundle(savedInstanceState.getParcelable("VIEWMODEL_STATE"));
}
}
}
示例5: onSaveInstanceState
import com.zhuinden.simplestack.Bundleable; //导入依赖的package包/类
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if(viewModel != null && viewModel instanceof Bundleable) {
outState.putParcelable("VIEWMODEL_STATE", ((Bundleable) viewModel).toBundle());
}
}
示例6: restoreStatesForNode
import com.zhuinden.simplestack.Bundleable; //导入依赖的package包/类
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()));
}
}
}
示例7: restoreServiceStateForKey
import com.zhuinden.simplestack.Bundleable; //导入依赖的package包/类
private void restoreServiceStateForKey(ServiceTree.Node node) {
StateBundle states = serviceTree.getRootService(SERVICE_STATES);
StateBundle keyBundle = states.getParcelable(node.getKey().toString());
if(keyBundle != null) {
List<ServiceTree.Node.Entry> entries = node.getBoundServices();
for(ServiceTree.Node.Entry entry : entries) {
if(entry.getService() instanceof Bundleable) {
((Bundleable) entry.getService()).fromBundle(keyBundle.<StateBundle>getParcelable(entry.getName()));
}
}
}
}