use of org.eyeseetea.malariacare.views.option.ImageRadioButtonOption in project pictureapp by EyeSeeTea.
the class DynamicTabAdapter method initializeNavigationButtons.
private void initializeNavigationButtons(View navigationButtonsHolder) {
ImageButton button = (ImageButton) navigationButtonsHolder.findViewById(R.id.next_btn);
((LinearLayout) button.getParent()).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isClicked) {
Log.d(TAG, "onClick ignored to avoid double click");
return;
}
Log.d(TAG, "onClicked");
isClicked = true;
boolean questionsWithError = false;
for (IMultiQuestionView multiquestionView : mMultiQuestionViews) {
if (multiquestionView.hasError()) {
questionsWithError = true;
break;
}
}
Log.d(TAG, "Questions with failed validation " + failedValidations);
if (failedValidations == 0 && !questionsWithError) {
TableRow currentRow = (TableRow) tableLayout.getChildAt(0);
if (!readOnly && currentRow != null && currentRow.getChildAt(0) instanceof ImageRadioButtonSingleQuestionView) {
navigationController.isMovingToForward = true;
ImageRadioButtonSingleQuestionView imageRadioButtonSingleQuestionView = (ImageRadioButtonSingleQuestionView) currentRow.getChildAt(0);
ImageRadioButtonOption selectedOptionView = imageRadioButtonSingleQuestionView.getSelectedOptionView();
if (selectedOptionView != null) {
final Question question = navigationController.getCurrentQuestion();
Option selectedOption = selectedOptionView.getOption();
Question counterQuestion = question.findCounterByOption(selectedOption);
if ((mReviewMode && isCounterValueEqualToMax(question, selectedOption))) {
saveOptionValue(selectedOptionView, selectedOptionView.getOption(), question, true);
} else if (counterQuestion != null) {
showConfirmCounter(selectedOptionView, selectedOptionView.getOption(), question, counterQuestion);
} else {
finishOrNext();
}
} else {
isClicked = false;
}
} else {
finishOrNext();
}
} else if (navigationController.getCurrentQuestion().hasCompulsoryNotAnswered() || Tab.isDynamicTreatmentTab(navigationController.getCurrentTab().getType())) {
UIMessagesStrategy.getInstance().showCompulsoryUnansweredToast();
isClicked = false;
return;
} else {
isClicked = false;
}
}
});
button = (ImageButton) navigationButtonsHolder.findViewById(R.id.back_btn);
//Save the numberpicker value in the DB, and continue to the next screen.
((LinearLayout) button.getParent()).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
previous();
}
});
}
use of org.eyeseetea.malariacare.views.option.ImageRadioButtonOption in project pictureapp by EyeSeeTea.
the class ImageRadioButtonSingleQuestionView method setOptions.
@Override
public void setOptions(List<Option> options) {
for (Option option : options) {
ImageRadioButtonOption imageRadioButtonOption = createOptionView(option);
answersContainer.addView(imageRadioButtonOption);
}
}
use of org.eyeseetea.malariacare.views.option.ImageRadioButtonOption in project pictureapp by EyeSeeTea.
the class DynamicStockImageRadioButtonSingleQuestionView method setOptions.
public void setOptions(List<Option> options) {
for (Option option : options) {
ImageRadioButtonOption imageRadioButtonOption = createOptionView(option);
answersContainer.addView(imageRadioButtonOption);
}
}
use of org.eyeseetea.malariacare.views.option.ImageRadioButtonOption in project pictureapp by EyeSeeTea.
the class DynamicStockImageRadioButtonSingleQuestionView 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);
Question question = (Question) imageRadioButtonOption.getTag();
if (!question.isOutStockQuestion() && question.getId_question().equals(value.getQuestion().getId_question()) && Float.parseFloat(value.getValue()) > 0) {
imageRadioButtonOption.setChecked(true);
} else if (question.getId_question().equals(value.getQuestion().getId_question())) {
List<Option> options = question.getAnswer().getOptions();
for (Option option : options) {
if ((option.getCode().equals(PreferencesState.getInstance().getContext().getString(R.string.true_option_id))) && option.getId_option().equals(value.getId_option())) {
imageRadioButtonOption.setChecked(true);
}
}
}
}
}
use of org.eyeseetea.malariacare.views.option.ImageRadioButtonOption in project pictureapp by EyeSeeTea.
the class DynamicStockImageRadioButtonSingleQuestionView method createOptionView.
@NonNull
private ImageRadioButtonOption createOptionView(Option option) {
ImageRadioButtonOption imageRadioButtonOption = new ImageRadioButtonOption(getContext(), true);
imageRadioButtonOption.setText(option.getInternationalizedCode());
putImageInImageRadioButton(option.getInternationalizedPath(), imageRadioButtonOption);
imageRadioButtonOption.setOnCheckedChangeListener(this);
imageRadioButtonOption.setOption(option, mQuestion);
imageRadioButtonOption.setEnabled(super.isEnabled());
imageRadioButtonOption.setTag(Question.findByID(option.getId_option()));
return imageRadioButtonOption;
}
Aggregations