Search in sources :

Example 1 with FormController

use of org.odk.collect.android.logic.FormController in project collect by opendatakit.

the class QuestionWidget method isWaitingForData.

@Override
public final boolean isWaitingForData() {
    Collect collect = Collect.getInstance();
    if (collect == null) {
        throw new IllegalStateException("Collect application instance is null.");
    }
    FormController formController = collect.getFormController();
    if (formController == null) {
        return false;
    }
    FormIndex index = getFormEntryPrompt().getIndex();
    return index.equals(formController.getIndexWaitingForData());
}
Also used : FormController(org.odk.collect.android.logic.FormController) Collect(org.odk.collect.android.application.Collect) FormIndex(org.javarosa.core.model.FormIndex)

Example 2 with FormController

use of org.odk.collect.android.logic.FormController in project collect by opendatakit.

the class QuestionWidget method waitForData.

// region Data waiting
@Override
public final void waitForData() {
    Collect collect = Collect.getInstance();
    if (collect == null) {
        throw new IllegalStateException("Collect application instance is null.");
    }
    FormController formController = collect.getFormController();
    if (formController == null) {
        return;
    }
    formController.setIndexWaitingForData(getFormEntryPrompt().getIndex());
}
Also used : FormController(org.odk.collect.android.logic.FormController) Collect(org.odk.collect.android.application.Collect)

Example 3 with FormController

use of org.odk.collect.android.logic.FormController in project collect by opendatakit.

the class QuestionWidget method cancelWaitingForData.

@Override
public final void cancelWaitingForData() {
    Collect collect = Collect.getInstance();
    if (collect == null) {
        throw new IllegalStateException("Collect application instance is null.");
    }
    FormController formController = collect.getFormController();
    if (formController == null) {
        return;
    }
    formController.setIndexWaitingForData(null);
}
Also used : FormController(org.odk.collect.android.logic.FormController) Collect(org.odk.collect.android.application.Collect)

Example 4 with FormController

use of org.odk.collect.android.logic.FormController in project collect by opendatakit.

the class QuestionWidget method getInstanceFolder.

// region Accessors
@Nullable
public final String getInstanceFolder() {
    Collect collect = Collect.getInstance();
    if (collect == null) {
        throw new IllegalStateException("Collect application instance is null.");
    }
    FormController formController = collect.getFormController();
    if (formController == null) {
        return null;
    }
    return formController.getInstanceFile().getParent();
}
Also used : FormController(org.odk.collect.android.logic.FormController) Collect(org.odk.collect.android.application.Collect) Nullable(android.support.annotation.Nullable)

Example 5 with FormController

use of org.odk.collect.android.logic.FormController in project collect by opendatakit.

the class SaveFormIndexTask method doInBackground.

@Override
protected String doInBackground(Void... params) {
    long start = System.currentTimeMillis();
    FormController formController = Collect.getInstance().getFormController();
    try {
        File tempFormIndexFile = SaveToDiskTask.getFormIndexFile(formController.getInstanceFile().getName());
        exportFormIndexToFile(formIndex, tempFormIndexFile);
        long end = System.currentTimeMillis();
        Timber.i("SaveFormIndex ms: %s to %s", Long.toString(end - start), tempFormIndexFile.toString());
        return null;
    } catch (Exception e) {
        String msg = e.getMessage();
        Timber.e(e);
        return msg;
    }
}
Also used : FormController(org.odk.collect.android.logic.FormController) File(java.io.File)

Aggregations

FormController (org.odk.collect.android.logic.FormController)42 FailedConstraint (org.odk.collect.android.logic.FormController.FailedConstraint)10 FormIndex (org.javarosa.core.model.FormIndex)8 JavaRosaException (org.odk.collect.android.exception.JavaRosaException)8 File (java.io.File)7 OnClickListener (android.view.View.OnClickListener)6 ODKView (org.odk.collect.android.views.ODKView)6 DialogInterface (android.content.DialogInterface)5 View (android.view.View)5 AdapterView (android.widget.AdapterView)5 ListView (android.widget.ListView)5 TextView (android.widget.TextView)5 IOException (java.io.IOException)4 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)4 Collect (org.odk.collect.android.application.Collect)4 GDriveConnectionException (org.odk.collect.android.exception.GDriveConnectionException)4 ContentValues (android.content.ContentValues)3 Intent (android.content.Intent)3 Cursor (android.database.Cursor)3 FormEntryCaption (org.javarosa.form.api.FormEntryCaption)3