//TODO This will need to change, for settings, etc.
@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    llView = (LinearLayout)inflater.inflate(R.layout.fragment_layers, container, false);
    llView.findViewById(R.id.btnAddStrokeLayer).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        Layer newLayer = new StrokePL();
        createLayer(((IDd<ID>)mTree).getId(), newLayer);
      }
    });
    llView.findViewById(R.id.btnAddGroupLayer).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        Layer newLayer = new GroupLayer();
        createLayer(((IDd<ID>)mTree).getId(), newLayer);
      }
    });
    llView.findViewById(R.id.btnAddOtherLayer).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        //TODO This will need to change, for settings, etc.
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        List<Class> classes = new ArrayList<Class>();
        try {
          classes = ClassScanner.getConcreteDescendants(getContext(), Layer.class, null);
        } catch (NoSuchMethodException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
        } catch (ClassNotFoundException e) {
          e.printStackTrace();
        }
        classes.remove(UACanvas.class);
        ArrayList<String> classNames = new ArrayList<String>();
        for (Class<?> clazz : classes) {
          classNames.add(clazz.getName());
        }
        String[] layerTypes = new String[]{};
        layerTypes = classNames.toArray(layerTypes);
        final List<Class> fClasses = classes;
        builder.setTitle("Pick a layer type")
                .setItems(layerTypes, new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    try {
                      Layer newLayer = (Layer)fClasses.get(which).newInstance();
                      createLayer(((IDd<ID>)mTree).getId(), newLayer);
                    } catch (java.lang.InstantiationException e) {
                      e.printStackTrace();
                      showToast("Error creating layer:\n" + e.getMessage());
                    } catch (IllegalAccessException e) {
                      e.printStackTrace();
                      showToast("Error creating layer:\n" + e.getMessage());
                    }
                  }
                });
        builder.show();
      }
    });
    updateView();
    return llView;
  }
@Override
public void onClick(View v) {
//TODO This will need to change, for settings, etc.
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
List<Class> classes = new ArrayList<Class>();
llView.findViewById(R.id.btnAddGroupLayer).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Layer newLayer = new GroupLayer();
createLayer(((IDd<ID>)mTree).getId(), newLayer);
}
});
llView.findViewById(R.id.btnAddOtherLayer).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//TODO This will need to change, for settings, etc.
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
List<Class> classes = new ArrayList<Class>();
try {
classes = ClassScanner.getConcreteDescendants(getContext(), Layer.class, null);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
llView = (LinearLayout)inflater.inflate(R.layout.fragment_layers, container, false);
llView.findViewById(R.id.btnAddStrokeLayer).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Layer newLayer = new StrokePL();
createLayer(((IDd<ID>)mTree).getId(), newLayer);
}
});
llView.findViewById(R.id.btnAddGroupLayer).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Layer newLayer = new GroupLayer();
createLayer(((IDd<ID>)mTree).getId(), newLayer);
}
});
llView.findViewById(R.id.btnAddOtherLayer).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//TODO This will need to change, for settings, etc.
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
List<Class> classes = new ArrayList<Class>();
try {
classes = ClassScanner.getConcreteDescendants(getContext(), Layer.class, null);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
classes.remove(UACanvas.class);
ArrayList<String> classNames = new ArrayList<String>();
for (Class<?> clazz : classes) {
classNames.add(clazz.getName());
}
String[] layerTypes = new String[]{};
layerTypes = classNames.toArray(layerTypes);
final List<Class> fClasses = classes;
builder.setTitle("Pick a layer type")