Search in sources :

Example 41 with Selection

use of org.javarosa.core.model.data.helper.Selection in project collect by opendatakit.

the class SelectImageMapWidget method unselectArea.

private void unselectArea(String areaId) {
    Selection selectionToRemove = null;
    for (Selection selection : selections) {
        if (areaId.equalsIgnoreCase(selection.getValue())) {
            selectionToRemove = selection;
        }
    }
    selections.remove(selectionToRemove);
    widgetValueChanged();
}
Also used : Selection(org.javarosa.core.model.data.helper.Selection)

Example 42 with Selection

use of org.javarosa.core.model.data.helper.Selection in project collect by opendatakit.

the class SelectImageMapWidget method refreshSelectedItemsLabel.

protected void refreshSelectedItemsLabel() {
    StringBuilder stringBuilder = new StringBuilder();
    if (!selections.isEmpty()) {
        stringBuilder.append("<b>").append(getContext().getString(R.string.selected)).append("</b> ");
        for (Selection selection : selections) {
            String choiceName = getFormEntryPrompt().getSelectChoiceText(selection.choice);
            CharSequence choiceDisplayName = HtmlUtils.textToHtml(choiceName);
            stringBuilder.append(choiceDisplayName);
            if (selections.indexOf(selection) < selections.size() - 1) {
                stringBuilder.append(", ");
            }
        }
    }
    ((Activity) getContext()).runOnUiThread(() -> binding.selectedElements.setText(Html.fromHtml(stringBuilder.toString())));
}
Also used : Selection(org.javarosa.core.model.data.helper.Selection) Activity(android.app.Activity)

Example 43 with Selection

use of org.javarosa.core.model.data.helper.Selection in project collect by opendatakit.

the class SelectImageMapWidget method selectArea.

protected void selectArea(String areaId) {
    SelectChoice selectChoice = null;
    for (SelectChoice sc : items) {
        if (areaId.equalsIgnoreCase(sc.getValue())) {
            selectChoice = sc;
        }
    }
    if (selectChoice != null) {
        selections.add(new Selection(selectChoice));
    }
    widgetValueChanged();
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) Selection(org.javarosa.core.model.data.helper.Selection)

Example 44 with Selection

use of org.javarosa.core.model.data.helper.Selection in project collect by opendatakit.

the class LikertWidget method setSavedButton.

// Inserts the selected button from a saved state
public void setSavedButton() {
    if (getFormEntryPrompt().getAnswerValue() != null) {
        String name = ((Selection) getFormEntryPrompt().getAnswerValue().getValue()).getValue();
        for (RadioButton bu : buttonsToName.keySet()) {
            if (buttonsToName.get(bu).equals(name)) {
                checkedButton = bu;
                checkedButton.setChecked(true);
            }
        }
    }
}
Also used : Selection(org.javarosa.core.model.data.helper.Selection) RadioButton(android.widget.RadioButton) MaterialRadioButton(com.google.android.material.radiobutton.MaterialRadioButton)

Aggregations

Selection (org.javarosa.core.model.data.helper.Selection)44 SelectChoice (org.javarosa.core.model.SelectChoice)20 SelectMultiData (org.javarosa.core.model.data.SelectMultiData)19 ArrayList (java.util.ArrayList)17 SelectOneData (org.javarosa.core.model.data.SelectOneData)14 List (java.util.List)12 Test (org.junit.Test)10 NonNull (androidx.annotation.NonNull)5 QuestionDef (org.javarosa.core.model.QuestionDef)5 SuppressLint (android.annotation.SuppressLint)4 Constraint (org.javarosa.core.model.condition.Constraint)4 IAnswerData (org.javarosa.core.model.data.IAnswerData)4 GeneralSelectMultiWidgetTest (org.odk.collect.android.widgets.base.GeneralSelectMultiWidgetTest)4 Arrays.asList (java.util.Arrays.asList)3 GeneralSelectOneWidgetTest (org.odk.collect.android.widgets.base.GeneralSelectOneWidgetTest)3 EvaluationContext (org.javarosa.core.model.condition.EvaluationContext)2 ConstraintHint (org.javarosa.core.model.condition.pivot.ConstraintHint)2 DateData (org.javarosa.core.model.data.DateData)2 DateTimeData (org.javarosa.core.model.data.DateTimeData)2 TreeElement (org.javarosa.core.model.instance.TreeElement)2