Search in sources :

Example 6 with QuestionWidget

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");
    }
}
Also used : QuestionWidget(org.odk.collect.android.widgets.QuestionWidget) SuppressLint(android.annotation.SuppressLint) BinaryWidget(org.odk.collect.android.widgets.interfaces.BinaryWidget)

Example 7 with QuestionWidget

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);
    }
}
Also used : QuestionWidget(org.odk.collect.android.widgets.QuestionWidget) SuppressLint(android.annotation.SuppressLint)

Example 8 with QuestionWidget

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;
            }
        }
    }
}
Also used : FormController(org.odk.collect.android.logic.FormController) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) TreeReference(org.javarosa.core.model.instance.TreeReference) QuestionWidget(org.odk.collect.android.widgets.QuestionWidget)

Aggregations

QuestionWidget (org.odk.collect.android.widgets.QuestionWidget)8 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)3 SuppressLint (android.annotation.SuppressLint)2 JavaRosaException (org.odk.collect.android.exception.JavaRosaException)2 FormController (org.odk.collect.android.logic.FormController)2 FailedConstraint (org.odk.collect.android.logic.FormController.FailedConstraint)2 StringWidget (org.odk.collect.android.widgets.StringWidget)2 BinaryWidget (org.odk.collect.android.widgets.interfaces.BinaryWidget)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 Editable (android.text.Editable)1 InputFilter (android.text.InputFilter)1 Spanned (android.text.Spanned)1 TextWatcher (android.text.TextWatcher)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 AdapterView (android.widget.AdapterView)1 CheckBox (android.widget.CheckBox)1 EditText (android.widget.EditText)1