Exemplo n.º 1
0
  @Override
  protected void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context) {
    super.doGetRestorableState(rs, context);

    RestorableSupport.StateObject so = rs.addStateObject(context, "layers");
    for (Layer layer : this.layers) {
      RestorableSupport.StateObject lso = rs.addStateObject(so, "layer");
      layer.doGetRestorableState(rs, lso);
    }
  }
Exemplo n.º 2
0
  @Override
  protected void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context) {
    super.doRestoreState(rs, context);

    RestorableSupport.StateObject so = rs.getStateObject(context, "layers");
    if (so == null) return;

    RestorableSupport.StateObject[] lsos = rs.getAllStateObjects(so, "layer");
    if (lsos == null || lsos.length == 0) return;

    ArrayList<Layer> layerList = new ArrayList<Layer>(lsos.length);

    for (RestorableSupport.StateObject lso : lsos) {
      if (lso != null) {
        Layer layer = new Layer();
        layer.doRestoreState(rs, lso);
        layerList.add(layer);
      }
    }

    this.setLayers(layerList);
  }