use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class FormEntryActivity method saveAnswersForCurrentScreen.
// The method saves questions one by one in order to support calculations in field-list groups
private void saveAnswersForCurrentScreen(FormEntryPrompt[] mutableQuestionsBeforeSave, List<ImmutableDisplayableQuestion> immutableQuestionsBeforeSave) {
FormController formController = getFormController();
ODKView currentView = getCurrentViewIfODKView();
if (formController == null || currentView == null) {
return;
}
int index = 0;
for (Map.Entry<FormIndex, IAnswerData> answer : currentView.getAnswers().entrySet()) {
// Questions with calculates will have their answers updated as the questions they depend on are saved
if (!isQuestionRecalculated(mutableQuestionsBeforeSave[index], immutableQuestionsBeforeSave.get(index))) {
try {
formController.saveOneScreenAnswer(answer.getKey(), answer.getValue(), false);
} catch (JavaRosaException e) {
Timber.e(e);
}
}
index++;
}
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class RankingListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position) {
FormController formController = Collect.getInstance().getFormController();
String itemName = String.valueOf(HtmlUtils.textToHtml(formController.getQuestionPrompt(formIndex).getSelectChoiceText(items.get(position))));
holder.textView.setText(itemName);
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class IdentityPromptViewModelTest method done_setsUserOnAuditEventLogger.
@Test
public void done_setsUserOnAuditEventLogger() {
FormController formController = mock(FormController.class);
AuditEventLogger auditEventLogger = mock(AuditEventLogger.class);
when(formController.getAuditEventLogger()).thenReturn(auditEventLogger);
IdentityPromptViewModel viewModel = new IdentityPromptViewModel();
viewModel.formLoaded(formController);
viewModel.setIdentity("Picard");
viewModel.done();
verify(auditEventLogger).setUser("Picard");
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class BackgroundAudioViewModelTest method setBackgroundRecordingEnabled_whenFalse_logsEventToAuditLog.
@Test
public void setBackgroundRecordingEnabled_whenFalse_logsEventToAuditLog() {
FormController formController = mock(FormController.class);
AuditEventLogger auditEventLogger = mock(AuditEventLogger.class);
when(formController.getAuditEventLogger()).thenReturn(auditEventLogger);
viewModel.formLoaded(formController);
when(clock.get()).thenReturn(1234L);
viewModel.setBackgroundRecordingEnabled(false);
verify(auditEventLogger).logEvent(AuditEvent.AuditEventType.BACKGROUND_AUDIO_DISABLED, true, 1234L);
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class QuestionWidget method getInstanceFolder.
// region Accessors
/**
* @deprecated widgets shouldn't need to know about the instance folder. They can use
* {@link org.odk.collect.android.utilities.QuestionMediaManager} to access media attached
* to the instance.
*/
@Nullable
@Deprecated
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();
}
Aggregations