use of org.eyeseetea.malariacare.views.question.CommonQuestionView 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 (((CommonQuestionView) multiquestionView).isActive() && 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() || mDynamicTabAdapterStrategy.isMultiQuestionByVariant(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.question.CommonQuestionView in project pictureapp by EyeSeeTea.
the class DynamicTabAdapter method toggleChild.
/**
* find and toggle the child question
*
* @param row is the child question view
* @param rowQuestion is the question in the view
* @param childQuestion is the posible child
*/
private boolean toggleChild(TableRow row, Question rowQuestion, Question childQuestion) {
if (childQuestion.getId_question().equals(rowQuestion.getId_question())) {
Survey survey = SurveyFragmentStrategy.getSessionSurveyByQuestion(rowQuestion);
if (rowQuestion.isHiddenBySurveyAndHeader(survey)) {
row.clearFocus();
row.setVisibility(View.GONE);
((CommonQuestionView) row.getChildAt(0)).deactivateQuestion();
hideDefaultValue(rowQuestion);
} else {
row.setVisibility(View.VISIBLE);
((CommonQuestionView) row.getChildAt(0)).activateQuestion();
showDefaultValue(row, rowQuestion);
}
return true;
}
return false;
}
Aggregations