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);
}
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;
}
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);
}
}
}
Aggregations