Search in sources :

Example 1 with CustomEditText

use of org.eyeseetea.sdk.presentation.views.CustomEditText in project pictureapp by EyeSeeTea.

the class AQuestionAnswerChangedListener method showDefaultValue.

/**
     * when a question is shown this method set the correct value.
     *
     * @param rowQuestion is the question in the view
     */
private void showDefaultValue(TableRow tableRow, Question rowQuestion) {
    if (rowQuestion.getValueBySession() != null) {
        return;
    }
    switch(rowQuestion.getOutput()) {
        case Constants.PHONE:
        case Constants.POSITIVE_INT:
        case Constants.INT:
        case Constants.LONG_TEXT:
        case Constants.SHORT_TEXT:
            final CustomEditText editCard = (CustomEditText) tableRow.findViewById(R.id.answer);
            editCard.setText("");
            break;
        case Constants.DROPDOWN_LIST:
        case Constants.DROPDOWN_OU_LIST:
            Spinner dropdown = (Spinner) tableRow.findViewById(R.id.answer);
            dropdown.setSelection(0);
            break;
        case Constants.SWITCH_BUTTON:
            Switch switchView = (Switch) tableRow.findViewById(R.id.answer);
            Option selectedOption = rowQuestion.getOptionBySession();
            if (selectedOption == null) {
                //the 0 option is the left option and is false in the switch, the 1 option is
                // the right option and is true
                boolean isChecked = false;
                if (rowQuestion.getAnswer().getOptions().get(1).getOptionAttribute().getDefaultOption() == 1) {
                    isChecked = true;
                }
                saveSwitchOption(rowQuestion, isChecked);
                switchView.setChecked(isChecked);
                break;
            }
            switchView.setChecked(findSwitchBoolean(rowQuestion));
            break;
    }
}
Also used : Switch(android.widget.Switch) CustomEditText(org.eyeseetea.sdk.presentation.views.CustomEditText) Spinner(android.widget.Spinner) Option(org.eyeseetea.malariacare.data.database.model.Option)

Example 2 with CustomEditText

use of org.eyeseetea.sdk.presentation.views.CustomEditText in project pictureapp by EyeSeeTea.

the class DynamicTabAdapter method showDefaultValue.

private void showDefaultValue(TableRow tableRow, Question rowQuestion) {
    if (rowQuestion.getValueBySession() != null) {
        return;
    }
    switch(rowQuestion.getOutput()) {
        case Constants.PHONE:
        case Constants.POSITIVE_INT:
        case Constants.POSITIVE_OR_ZERO_INT:
        case Constants.INT:
        case Constants.LONG_TEXT:
        case Constants.SHORT_TEXT:
            final CustomEditText editCard = (CustomEditText) tableRow.findViewById(R.id.answer);
            editCard.setText("");
            break;
        case Constants.DROPDOWN_LIST:
        case Constants.DROPDOWN_OU_LIST:
            Spinner dropdown = (Spinner) tableRow.findViewById(R.id.answer);
            dropdown.setSelection(0);
            break;
        case Constants.SWITCH_BUTTON:
            Switch switchView = (Switch) tableRow.findViewById(R.id.answer);
            Option selectedOption = rowQuestion.getOptionBySession();
            if (selectedOption == null) {
                //the 0 option is the left option and is false in the switch, the 1 option is
                // the right option and is true
                boolean isChecked = false;
                if (rowQuestion.getAnswer().getOptions().get(1).getOptionAttribute().getDefaultOption() == 1) {
                    isChecked = true;
                }
                saveSwitchOption(rowQuestion, isChecked);
                switchView.setChecked(isChecked);
                break;
            }
            switchView.setChecked(findSwitchBoolean(rowQuestion));
            break;
    }
}
Also used : Switch(android.widget.Switch) CustomEditText(org.eyeseetea.sdk.presentation.views.CustomEditText) Spinner(android.widget.Spinner) QuestionOption(org.eyeseetea.malariacare.data.database.model.QuestionOption) ImageRadioButtonOption(org.eyeseetea.malariacare.views.option.ImageRadioButtonOption) Option(org.eyeseetea.malariacare.data.database.model.Option)

Aggregations

Spinner (android.widget.Spinner)2 Switch (android.widget.Switch)2 Option (org.eyeseetea.malariacare.data.database.model.Option)2 CustomEditText (org.eyeseetea.sdk.presentation.views.CustomEditText)2 QuestionOption (org.eyeseetea.malariacare.data.database.model.QuestionOption)1 ImageRadioButtonOption (org.eyeseetea.malariacare.views.option.ImageRadioButtonOption)1