当前位置: 首页>>代码示例>>Java>>正文


Java Bundleable类代码示例

本文整理汇总了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;
}
 
开发者ID:Zhuinden,项目名称:scope-manager,代码行数:17,代码来源:ScopeManager.java

示例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;
}
 
开发者ID:Zhuinden,项目名称:navigator,代码行数:14,代码来源:NestSupportServiceManager.java

示例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()));
                }
            }
        }
    }
}
 
开发者ID:Zhuinden,项目名称:navigator,代码行数:14,代码来源:NestSupportServiceManager.java

示例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"));
        }
    }
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:10,代码来源:ViewModelHolder.java

示例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());
    }
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:8,代码来源:ViewModelHolder.java

示例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()));
        }
    }
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:12,代码来源:NodeStateManager.java

示例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()));
            }
        }
    }
}
 
开发者ID:Zhuinden,项目名称:scope-manager,代码行数:13,代码来源:ScopeManager.java


注:本文中的com.zhuinden.simplestack.Bundleable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。