use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class LoaderTest method testReversedLegIsParsed.
@Test
public void testReversedLegIsParsed() throws Exception {
String text = "2\t1\t9.11\t121\t-23\n";
Survey survey = new Survey("TestSurvey");
Loader.parse(text, survey);
assert survey.getAllStations().size() == 2;
assert survey.getOrigin().getConnectedOnwardLegs().get(0).getDestination().getName().equals("2");
assert survey.getOrigin().getConnectedOnwardLegs().get(0).wasShotBackwards();
}
use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class LoaderTest method testSimpleSurveyIsParsed.
@Test
public void testSimpleSurveyIsParsed() throws Exception {
String text = "1\t2\t9.11\t121\t-23\n";
Survey survey = new Survey("TestSurvey");
Loader.parse(text, survey);
assert survey.getAllStations().size() == 2;
assert survey.getOrigin().getConnectedOnwardLegs().get(0).getDestination().getName().equals("2");
}
use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class LoaderTest method testEmptySurveyResultsIn1Station.
@Test
public void testEmptySurveyResultsIn1Station() throws Exception {
String text = "";
Survey survey = new Survey("TestSurvey");
Loader.parse(text, survey);
assert survey.getAllStations().size() == 1;
}
use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class SexyTopoActivity method saveSurveyAsName.
private void saveSurveyAsName() {
final EditText input = new EditText(this);
input.setText(getSurvey().getName());
input.setContentDescription("Enter new name");
new AlertDialog.Builder(this).setTitle(getString(R.string.dialog_save_as_title)).setView(input).setPositiveButton(getString(R.string.ok), (dialog, whichButton) -> {
Editable value = input.getText();
String newName = value.toString();
Survey survey = getSurvey();
String oldName = survey.getName();
if (oldName.equals(newName)) {
return;
}
try {
survey.setName(newName);
if (!Util.isSurveyNameUnique(SexyTopoActivity.this, survey.getName())) {
throw new Exception("Survey already exists");
}
Saver.save(SexyTopoActivity.this, survey);
updateRememberedSurvey();
} catch (Exception exception) {
survey.setName(oldName);
showSimpleToast(R.string.error_saving_survey);
showException(exception);
}
}).setNegativeButton(getString(R.string.cancel), (dialog, whichButton) -> {
/* Do nothing */
}).show();
}
use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.
the class SexyTopoActivity method startNewSurvey.
public void startNewSurvey() {
// public due to stupid Reflection requirements
Log.d("Starting new survey");
final EditText input = new EditText(this);
String defaultName = Util.getNextDefaultSurveyName(this);
input.setText(defaultName);
new AlertDialog.Builder(this).setTitle(getString(R.string.dialog_new_survey_title)).setView(input).setPositiveButton(getString(R.string.ok), (dialog, whichButton) -> {
Editable value = input.getText();
String name = value.toString();
Survey survey = new Survey(name);
if (Util.isSurveyNameUnique(SexyTopoActivity.this, name)) {
setSurvey(survey);
} else {
showSimpleToast(R.string.dialog_new_survey_name_must_be_unique);
}
}).setNegativeButton(getString(R.string.cancel), (dialog, whichButton) -> {
/* Do nothing. */
}).show();
}
Aggregations