Search in sources :

Example 6 with ImageRadioButtonOption

use of org.eyeseetea.malariacare.views.option.ImageRadioButtonOption in project pictureapp by EyeSeeTea.

the class DynamicStockImageRadioButtonSingleQuestionView method onCheckedChanged.

@Override
public void onCheckedChanged(ImageRadioButtonOption imageRadioButton, boolean value) {
    if (value == false)
        return;
    for (int i = 0; i < answersContainer.getChildCount(); i++) {
        ImageRadioButtonOption optionView = (ImageRadioButtonOption) answersContainer.getChildAt(i);
        if (imageRadioButton != optionView && optionView.isChecked()) {
            optionView.setChecked(false);
            Question question = (Question) optionView.getTag();
            if (!question.isOutStockQuestion()) {
                notifyAnswerChanged(optionView, String.valueOf(-1));
            } else {
                List<Option> options = question.getAnswer().getOptions();
                for (Option option : options) {
                    if (option.getCode().equals(PreferencesState.getInstance().getContext().getString(R.string.false_option_id))) {
                        notifyAnsweOptionChange(optionView, option);
                    }
                }
            }
        }
    }
    Question question = (Question) imageRadioButton.getTag();
    if (!question.isOutStockQuestion()) {
        notifyAnswerChanged(imageRadioButton, String.valueOf(optionDose.get(imageRadioButton.getOption().getId_option())));
    } else {
        List<Option> options = question.getAnswer().getOptions();
        for (Option option : options) {
            if (option.getCode().equals(PreferencesState.getInstance().getContext().getString(R.string.true_option_id))) {
                notifyAnsweOptionChange(imageRadioButton, option);
            }
        }
    }
    //Setting a value for the stock question to get max total question correct
    View stockHideView = new View(context);
    stockHideView.setTag(Treatment.getDynamicStockQuestion());
    Question pqHideQuestion = Question.findByUID(context.getString(R.string.stockPqQuestionUID));
    Option falseOption = Option.findById(41l);
    Value valuePq = pqHideQuestion.getValueBySession();
    if (valuePq != null) {
        falseOption = valuePq.getOption();
    }
    notifyAnsweOptionChange(stockHideView, falseOption);
}
Also used : ImageRadioButtonOption(org.eyeseetea.malariacare.views.option.ImageRadioButtonOption) Value(org.eyeseetea.malariacare.data.database.model.Value) Question(org.eyeseetea.malariacare.data.database.model.Question) Option(org.eyeseetea.malariacare.data.database.model.Option) ImageRadioButtonOption(org.eyeseetea.malariacare.views.option.ImageRadioButtonOption) AKeyboardQuestionView(org.eyeseetea.malariacare.views.question.AKeyboardQuestionView) AOptionQuestionView(org.eyeseetea.malariacare.views.question.AOptionQuestionView) View(android.view.View) IQuestionView(org.eyeseetea.malariacare.views.question.IQuestionView)

Example 7 with ImageRadioButtonOption

use of org.eyeseetea.malariacare.views.option.ImageRadioButtonOption in project pictureapp by EyeSeeTea.

the class ImageRadioButtonSingleQuestionView method createOptionView.

@NonNull
private ImageRadioButtonOption createOptionView(Option option) {
    ImageRadioButtonOption imageRadioButtonOption = new ImageRadioButtonOption(getContext());
    imageRadioButtonOption.setText(option.getInternationalizedCode());
    putImageInImageRadioButton(option.getInternationalizedPath(), imageRadioButtonOption);
    imageRadioButtonOption.setOnCheckedChangeListener(this);
    imageRadioButtonOption.setOption(option, mQuestion);
    imageRadioButtonOption.setEnabled(super.isEnabled());
    return imageRadioButtonOption;
}
Also used : ImageRadioButtonOption(org.eyeseetea.malariacare.views.option.ImageRadioButtonOption) NonNull(android.support.annotation.NonNull)

Example 8 with ImageRadioButtonOption

use of org.eyeseetea.malariacare.views.option.ImageRadioButtonOption in project pictureapp by EyeSeeTea.

the class ImageRadioButtonSingleQuestionView method setValue.

@Override
public void setValue(Value value) {
    if (value == null || value.getValue() == null) {
        return;
    }
    for (int i = 0; i < answersContainer.getChildCount(); i++) {
        ImageRadioButtonOption imageRadioButtonOption = (ImageRadioButtonOption) answersContainer.getChildAt(i);
        if (imageRadioButtonOption.getOption().equals(value.getOption())) {
            optionSetBySavedValue = true;
            imageRadioButtonOption.setChecked(true);
        }
    }
}
Also used : ImageRadioButtonOption(org.eyeseetea.malariacare.views.option.ImageRadioButtonOption)

Aggregations

ImageRadioButtonOption (org.eyeseetea.malariacare.views.option.ImageRadioButtonOption)8 Option (org.eyeseetea.malariacare.data.database.model.Option)5 Question (org.eyeseetea.malariacare.data.database.model.Question)3 NonNull (android.support.annotation.NonNull)2 View (android.view.View)2 AKeyboardQuestionView (org.eyeseetea.malariacare.views.question.AKeyboardQuestionView)2 AOptionQuestionView (org.eyeseetea.malariacare.views.question.AOptionQuestionView)2 IQuestionView (org.eyeseetea.malariacare.views.question.IQuestionView)2 ImageButton (android.widget.ImageButton)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 ListView (android.widget.ListView)1 ScrollView (android.widget.ScrollView)1 TableRow (android.widget.TableRow)1 List (java.util.List)1 QuestionOption (org.eyeseetea.malariacare.data.database.model.QuestionOption)1 Value (org.eyeseetea.malariacare.data.database.model.Value)1 IImageQuestionView (org.eyeseetea.malariacare.views.question.IImageQuestionView)1 IMultiQuestionView (org.eyeseetea.malariacare.views.question.IMultiQuestionView)1 INavigationQuestionView (org.eyeseetea.malariacare.views.question.INavigationQuestionView)1