Search in sources :

Example 1 with BinaryWidget

use of org.odk.collect.android.widgets.interfaces.BinaryWidget in project collect by opendatakit.

the class ODKView method setBinaryData.

/**
 * Called when another activity returns information to answer this question.
 */
public void setBinaryData(Object answer) {
    boolean set = false;
    for (QuestionWidget q : widgets) {
        if (q instanceof BinaryWidget) {
            BinaryWidget binaryWidget = (BinaryWidget) q;
            if (binaryWidget.isWaitingForData()) {
                try {
                    binaryWidget.setBinaryData(answer);
                    binaryWidget.cancelWaitingForData();
                } catch (Exception e) {
                    Timber.e(e);
                    ToastUtils.showLongToast(getContext().getString(R.string.error_attaching_binary_file, e.getMessage()));
                }
                set = true;
                break;
            }
        }
    }
    if (!set) {
        Timber.w("Attempting to return data to a widget or set of widgets not looking for data");
    }
}
Also used : QuestionWidget(org.odk.collect.android.widgets.QuestionWidget) ExternalParamsException(org.odk.collect.android.exception.ExternalParamsException) JavaRosaException(org.odk.collect.android.exception.JavaRosaException) ActivityNotFoundException(android.content.ActivityNotFoundException) BinaryWidget(org.odk.collect.android.widgets.interfaces.BinaryWidget)

Example 2 with BinaryWidget

use of org.odk.collect.android.widgets.interfaces.BinaryWidget 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)

Aggregations

QuestionWidget (org.odk.collect.android.widgets.QuestionWidget)2 BinaryWidget (org.odk.collect.android.widgets.interfaces.BinaryWidget)2 SuppressLint (android.annotation.SuppressLint)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 ExternalParamsException (org.odk.collect.android.exception.ExternalParamsException)1 JavaRosaException (org.odk.collect.android.exception.JavaRosaException)1