use of org.javarosa.core.model.FormIndex in project collect by opendatakit.
the class FormEntryActivity method onSaveInstanceState.
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(KEY_FORMPATH, formPath);
FormController formController = getFormController();
if (formController != null) {
if (formController.getInstanceFile() != null) {
outState.putString(KEY_INSTANCEPATH, getAbsoluteInstancePath());
}
outState.putString(KEY_XPATH, formController.getXPath(formController.getFormIndex()));
FormIndex waiting = formController.getIndexWaitingForData();
if (waiting != null) {
outState.putString(KEY_XPATH_WAITING_FOR_DATA, formController.getXPath(waiting));
}
// save the instance to a temp path...
nonblockingCreateSavePointData();
}
outState.putBoolean(NEWFORM, false);
outState.putString(KEY_ERROR, errorMessage);
outState.putString(KEY_SAVE_NAME, saveName);
outState.putBoolean(KEY_AUTO_SAVED, autoSaved);
outState.putBoolean(KEY_READ_PHONE_STATE_PERMISSION_REQUEST_NEEDED, readPhoneStatePermissionRequestNeeded);
outState.putBoolean(KEY_LOCATION_PERMISSIONS_GRANTED, locationPermissionsPreviouslyGranted);
}
use of org.javarosa.core.model.FormIndex in project collect by opendatakit.
the class FormHierarchyActivity method jumpToHierarchyStartIndex.
/**
* Goes to the start of the hierarchy view based on where the user came from.
* Backs out until the index is at the beginning of a repeat group or the beginning of the form.
*/
private void jumpToHierarchyStartIndex() {
FormController formController = Collect.getInstance().getFormController();
FormIndex startIndex = formController.getFormIndex();
// If we're not at the first level, we're inside a repeated group so we want to only
// display everything enclosed within that group.
contextGroupRef = null;
// Save the index to the screen itself, before potentially moving into it.
screenIndex = startIndex;
// node to display.
if (formController.isDisplayableGroup(startIndex)) {
contextGroupRef = formController.getFormIndex().getReference();
formController.stepToNextEvent(FormController.STEP_INTO_GROUP);
} else {
FormIndex potentialStartIndex = getPreviousLevel(startIndex);
// Step back until we hit a displayable group or the beginning.
while (!isScreenEvent(formController, potentialStartIndex)) {
potentialStartIndex = getPreviousLevel(potentialStartIndex);
}
screenIndex = potentialStartIndex;
// Otherwise we're at a displayable group.
if (screenIndex == null) {
screenIndex = FormIndex.createBeginningOfFormIndex();
}
formController.jumpToIndex(screenIndex);
// Now test again. This should be true at this point or we're at the beginning.
if (formController.isDisplayableGroup(formController.getFormIndex())) {
contextGroupRef = formController.getFormIndex().getReference();
formController.stepToNextEvent(FormController.STEP_INTO_GROUP);
} else {
// Let contextGroupRef be null.
}
}
}
use of org.javarosa.core.model.FormIndex in project collect by opendatakit.
the class FormHierarchyActivity method onElementClick.
/**
* Handles clicks on a specific row in the hierarchy view.
*/
public void onElementClick(HierarchyElement element) {
FormIndex index = element.getFormIndex();
switch(element.getType()) {
case QUESTION:
onQuestionClicked(index);
break;
case REPEATABLE_GROUP:
// Show the picker.
repeatGroupPickerIndex = index;
refreshView();
break;
case VISIBLE_GROUP:
case REPEAT_INSTANCE:
// Hide the picker.
repeatGroupPickerIndex = null;
Collect.getInstance().getFormController().jumpToIndex(index);
setResult(RESULT_OK);
refreshView();
break;
}
}
use of org.javarosa.core.model.FormIndex in project collect by opendatakit.
the class FormController method deleteRepeat.
/**
* If the current FormIndex is within a repeated group, will find the innermost repeat, delete
* it, and jump the FormEntryController to the previous valid index. That is, if you have
* group1
* (2) > group2 (3) and you call deleteRepeat, it will delete the 3rd instance of group2.
*/
public void deleteRepeat() {
FormIndex fi = formEntryController.deleteRepeat();
formEntryController.jumpToIndex(fi);
}
use of org.javarosa.core.model.FormIndex in project collect by opendatakit.
the class FormController method stepToOuterScreenEvent.
/**
* Move the current form index to the index of the first displayable group
* (that is, a repeatable group or a visible group),
* or to the start of the form.
*/
public int stepToOuterScreenEvent() {
FormIndex index = getFormIndex();
// Step out once to begin with if we're coming from a question.
if (getEvent() == FormEntryController.EVENT_QUESTION) {
index = getPreviousLevel(index);
}
// Save where we started from.
FormIndex startIndex = index;
// Step out once more no matter what.
index = getPreviousLevel(index);
// Step out of any group indexes that are present, unless they're visible.
while (index != null && getEvent(index) == FormEntryController.EVENT_GROUP && !isDisplayableGroup(index)) {
index = getPreviousLevel(index);
}
if (index == null) {
jumpToIndex(FormIndex.createBeginningOfFormIndex());
} else {
if (isDisplayableGroup(startIndex)) {
// We were at a displayable group, so stepping back brought us to the previous level
jumpToIndex(index);
} else {
// We were at a question, so stepping back brought us to either:
// The beginning, or the start of a displayable group. So we need to step
// out again to go past the group.
index = getPreviousLevel(index);
if (index == null) {
jumpToIndex(FormIndex.createBeginningOfFormIndex());
} else {
jumpToIndex(index);
}
}
}
return getEvent();
}
Aggregations