use of org.hwyl.sexytopo.control.io.translation.Exporter in project sexytopo by richsmith.
the class SexyTopoActivity method exportSurvey.
public void exportSurvey() {
// public due to stupid Reflection requirements
final Survey survey = getSurvey();
AlertDialog.Builder builderSingle = new AlertDialog.Builder(this);
builderSingle.setTitle(getString(R.string.select_export_type));
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.select_dialog_item);
final Map<String, Exporter> nameToExporter = new HashMap<>();
for (Exporter exporter : SelectableExporters.EXPORTERS) {
String name = exporter.getExportTypeName(this);
arrayAdapter.add(name);
nameToExporter.put(name, exporter);
}
builderSingle.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String name = arrayAdapter.getItem(which);
Exporter selectedExporter = nameToExporter.get(name);
try {
selectedExporter.export(SexyTopoActivity.this, survey);
showSimpleToast(survey.getName() + " " + getString(R.string.export_successful));
} catch (Exception exception) {
showException(exception);
}
}
});
builderSingle.show();
}
Aggregations