use of org.odk.collect.android.widgets.QuestionWidget in project collect by opendatakit.
the class ODKView method cancelWaitingForBinaryData.
public void cancelWaitingForBinaryData() {
int count = 0;
for (QuestionWidget q : widgets) {
if (q instanceof BinaryWidget) {
if (q.isWaitingForData()) {
q.cancelWaitingForData();
++count;
}
}
}
if (count != 1) {
Timber.w("Attempting to cancel waiting for binary data to a widget or set of widgets " + "not looking for data");
}
}
use of org.odk.collect.android.widgets.QuestionWidget in project collect by opendatakit.
the class ODKView method setOnFocusChangeListener.
@Override
public void setOnFocusChangeListener(OnFocusChangeListener l) {
for (int i = 0; i < widgets.size(); i++) {
QuestionWidget qw = widgets.get(i);
qw.setOnFocusChangeListener(l);
}
}
use of org.odk.collect.android.widgets.QuestionWidget in project collect by opendatakit.
the class ODKView method setDataForFields.
public void setDataForFields(Bundle bundle) throws JavaRosaException {
if (bundle == null) {
return;
}
FormController formController = Collect.getInstance().getFormController();
Set<String> keys = bundle.keySet();
for (String key : keys) {
for (QuestionWidget questionWidget : widgets) {
FormEntryPrompt prompt = questionWidget.getFormEntryPrompt();
TreeReference treeReference = (TreeReference) prompt.getFormElement().getBind().getReference();
if (treeReference.getNameLast().equals(key)) {
switch(prompt.getDataType()) {
case Constants.DATATYPE_TEXT:
formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asStringData(bundle.get(key)));
break;
case Constants.DATATYPE_INTEGER:
formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asIntegerData(bundle.get(key)));
break;
case Constants.DATATYPE_DECIMAL:
formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asDecimalData(bundle.get(key)));
break;
default:
throw new RuntimeException(getContext().getString(R.string.ext_assign_value_error, treeReference.toString(false)));
}
break;
}
}
}
}
Aggregations