Search in sources :

Example 1 with SelectChoice

use of org.javarosa.core.model.SelectChoice in project collect by opendatakit.

the class SpinnerWidget method getAnswer.

@Override
public IAnswerData getAnswer() {
    clearFocus();
    int i = spinner.getSelectedItemPosition();
    if (i == -1 || i == items.size()) {
        return null;
    } else {
        SelectChoice sc = items.get(i);
        return new SelectOneData(new Selection(sc));
    }
}
Also used : SelectOneData(org.javarosa.core.model.data.SelectOneData) SelectChoice(org.javarosa.core.model.SelectChoice) Selection(org.javarosa.core.model.data.helper.Selection) SuppressLint(android.annotation.SuppressLint)

Example 2 with SelectChoice

use of org.javarosa.core.model.SelectChoice in project collect by opendatakit.

the class SpinnerMultiWidgetTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    List<SelectChoice> selectChoices = getSelectChoices();
    for (SelectChoice selectChoice : selectChoices) {
        when(formEntryPrompt.getSelectChoiceText(selectChoice)).thenReturn(selectChoice.getValue());
    }
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice)

Example 3 with SelectChoice

use of org.javarosa.core.model.SelectChoice in project collect by opendatakit.

the class GeneralSelectMultiWidgetTest method getNextAnswer.

@NonNull
@Override
public SelectMultiData getNextAnswer() {
    List<SelectChoice> selectChoices = getSelectChoices();
    int selectedIndex = Math.abs(random.nextInt()) % selectChoices.size();
    SelectChoice selectChoice = selectChoices.get(selectedIndex);
    Selection selection = new Selection(selectChoice);
    return new SelectMultiData(ImmutableList.of(selection));
}
Also used : SelectMultiData(org.javarosa.core.model.data.SelectMultiData) SelectChoice(org.javarosa.core.model.SelectChoice) Selection(org.javarosa.core.model.data.helper.Selection) NonNull(android.support.annotation.NonNull)

Example 4 with SelectChoice

use of org.javarosa.core.model.SelectChoice in project collect by opendatakit.

the class SelectWidgetTest method createSelectChoices.

private List<SelectChoice> createSelectChoices() {
    int choiceCount = (Math.abs(random.nextInt()) % 3) + 2;
    List<SelectChoice> selectChoices = new ArrayList<>();
    for (int i = 0; i < choiceCount; i++) {
        SelectChoice selectChoice = new SelectChoice(Integer.toString(i), RandomString.make());
        selectChoice.setIndex(i);
        selectChoices.add(selectChoice);
    }
    return selectChoices;
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) ArrayList(java.util.ArrayList)

Example 5 with SelectChoice

use of org.javarosa.core.model.SelectChoice in project javarosa by opendatakit.

the class SelectOneDataTests method setUp.

/* (non-Javadoc)
     * @see j2meunit.framework.TestCase#setUp()
     */
public void setUp() throws Exception {
    super.setUp();
    question = new QuestionDef();
    question.setID(57);
    for (int i = 0; i < 3; i++) {
        question.addSelectChoice(new SelectChoice("", "Selection" + i, "Selection" + i, false));
    }
    one = new Selection("Selection1");
    one.attachChoice(question);
    two = new Selection("Selection2");
    two.attachChoice(question);
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) Selection(org.javarosa.core.model.data.helper.Selection) QuestionDef(org.javarosa.core.model.QuestionDef)

Aggregations

SelectChoice (org.javarosa.core.model.SelectChoice)24 ArrayList (java.util.ArrayList)12 Selection (org.javarosa.core.model.data.helper.Selection)12 QuestionDef (org.javarosa.core.model.QuestionDef)7 SelectMultiData (org.javarosa.core.model.data.SelectMultiData)7 SuppressLint (android.annotation.SuppressLint)5 SelectOneData (org.javarosa.core.model.data.SelectOneData)4 List (java.util.List)3 Test (org.junit.Test)3 NonNull (android.support.annotation.NonNull)2 EvaluationContext (org.javarosa.core.model.condition.EvaluationContext)2 IAnswerData (org.javarosa.core.model.data.IAnswerData)2 TreeElement (org.javarosa.core.model.instance.TreeElement)2 ExternalSelectChoice (org.odk.collect.android.external.ExternalSelectChoice)2 Cursor (android.database.Cursor)1 SQLiteException (android.database.sqlite.SQLiteException)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1