Search in sources :

Example 1 with ListWidget

use of org.odk.collect.android.widgets.items.ListWidget in project collect by opendatakit.

the class WidgetFactory method getSelectOneWidget.

private QuestionWidget getSelectOneWidget(String appearance, QuestionDetails questionDetails) {
    final QuestionWidget questionWidget;
    boolean isQuick = appearance.contains(Appearances.QUICK);
    // considered in each widget by calls to ExternalDataUtil.getSearchXPathExpression.
    if (appearance.contains(Appearances.MINIMAL)) {
        questionWidget = new SelectOneMinimalWidget(activity, questionDetails, isQuick, waitingForDataRegistry);
    } else if (appearance.contains(Appearances.LIKERT)) {
        questionWidget = new LikertWidget(activity, questionDetails);
    } else if (appearance.contains(Appearances.LIST_NO_LABEL)) {
        questionWidget = new ListWidget(activity, questionDetails, false, isQuick);
    } else if (appearance.contains(Appearances.LIST)) {
        questionWidget = new ListWidget(activity, questionDetails, true, isQuick);
    } else if (appearance.contains(Appearances.LABEL)) {
        questionWidget = new LabelWidget(activity, questionDetails);
    } else if (appearance.contains(Appearances.IMAGE_MAP)) {
        questionWidget = new SelectOneImageMapWidget(activity, questionDetails, isQuick);
    } else {
        questionWidget = new SelectOneWidget(activity, questionDetails, isQuick);
    }
    return questionWidget;
}
Also used : SelectOneWidget(org.odk.collect.android.widgets.items.SelectOneWidget) SelectOneMinimalWidget(org.odk.collect.android.widgets.items.SelectOneMinimalWidget) ListWidget(org.odk.collect.android.widgets.items.ListWidget) LabelWidget(org.odk.collect.android.widgets.items.LabelWidget) LikertWidget(org.odk.collect.android.widgets.items.LikertWidget) SelectOneImageMapWidget(org.odk.collect.android.widgets.items.SelectOneImageMapWidget)

Example 2 with ListWidget

use of org.odk.collect.android.widgets.items.ListWidget in project collect by opendatakit.

the class WidgetFactoryTest method testCreatingSelectOneListWidget.

@Test
public void testCreatingSelectOneListWidget() {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance("something LisT something").build();
    QuestionWidget widget = widgetFactory.createWidgetFromPrompt(prompt, null);
    assertThat(widget, instanceOf(ListWidget.class));
    assertThat(((ListWidget) widget).shouldDisplayLabel(), is(true));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) ListWidget(org.odk.collect.android.widgets.items.ListWidget) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Example 3 with ListWidget

use of org.odk.collect.android.widgets.items.ListWidget in project collect by opendatakit.

the class WidgetFactoryTest method testCreatingSelectOneListNoLabelWidget.

@Test
public void testCreatingSelectOneListNoLabelWidget() {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance("something LisT-nOLabeL something").build();
    QuestionWidget widget = widgetFactory.createWidgetFromPrompt(prompt, null);
    assertThat(widget, instanceOf(ListWidget.class));
    assertThat(((ListWidget) widget).shouldDisplayLabel(), is(false));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) ListWidget(org.odk.collect.android.widgets.items.ListWidget) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Aggregations

ListWidget (org.odk.collect.android.widgets.items.ListWidget)3 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)2 Test (org.junit.Test)2 MockFormEntryPromptBuilder (org.odk.collect.android.support.MockFormEntryPromptBuilder)2 LabelWidget (org.odk.collect.android.widgets.items.LabelWidget)1 LikertWidget (org.odk.collect.android.widgets.items.LikertWidget)1 SelectOneImageMapWidget (org.odk.collect.android.widgets.items.SelectOneImageMapWidget)1 SelectOneMinimalWidget (org.odk.collect.android.widgets.items.SelectOneMinimalWidget)1 SelectOneWidget (org.odk.collect.android.widgets.items.SelectOneWidget)1