Search in sources :

Example 41 with FormController

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

the class ActivityLogger method logInstanceAction.

public void logInstanceAction(Object t, String context, String action, FormIndex index) {
    String instancePath = null;
    FormController formController = Collect.getInstance().getFormController();
    if (formController != null) {
        instancePath = getInstancePath(formController);
    }
    log(t.getClass().getName(), context, action, instancePath, index, null, null);
}
Also used : FormController(org.odk.collect.android.logic.FormController)

Example 42 with FormController

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

the class FormNavigationTestCase method testIndices.

private void testIndices(String formName, String[] expectedIndices) throws ExecutionException, InterruptedException {
    try {
        copyToSdCard(formName);
    } catch (IOException e) {
        Timber.i(e);
    }
    FormLoaderTask formLoaderTask = new FormLoaderTask(formPath(formName), null, null);
    formLoaderTask.setFormLoaderListener(new FormLoaderListener() {

        @Override
        public void loadingComplete(FormLoaderTask task, FormDef fd) {
            try {
                // form and then swiping back once. Verify the expected indices before and after each swipe.
                for (int i = 0; i < expectedIndices.length - 1; i++) {
                    FormController formController = task.getFormController();
                    // check the current index
                    assertEquals(expectedIndices[i], formController.getFormIndex().toString());
                    if (i < expectedIndices.length - 2) {
                        formController.stepToNextScreenEvent();
                    } else {
                        formController.stepToPreviousScreenEvent();
                    }
                    // check the index again after navigating
                    assertEquals(expectedIndices[i + 1], formController.getFormIndex().toString());
                }
            } catch (Exception e) {
                Timber.i(e);
            }
        }

        @Override
        public void loadingError(String errorMsg) {
        }

        @Override
        public void onProgressStep(String stepMessage) {
        }
    });
    formLoaderTask.execute(formPath(formName)).get();
}
Also used : FormController(org.odk.collect.android.logic.FormController) FormDef(org.javarosa.core.model.FormDef) FormLoaderListener(org.odk.collect.android.listeners.FormLoaderListener) IOException(java.io.IOException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) FormLoaderTask(org.odk.collect.android.tasks.FormLoaderTask)

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