use of org.eyeseetea.malariacare.views.question.multiquestion.NumberRadioButtonMultiquestionView in project pictureapp by EyeSeeTea.
the class DynamicTabAdapter method configureAnswerChangedListener.
private void configureAnswerChangedListener(IQuestionView questionView) {
if (questionView instanceof AKeyboardQuestionView) {
((AKeyboardQuestionView) questionView).setOnAnswerChangedListener(new QuestionAnswerChangedListener(tableLayout, this, !GradleVariantConfig.isButtonNavigationActive()));
} else if (questionView instanceof AOptionQuestionView) {
((AOptionQuestionView) questionView).setOnAnswerChangedListener(new QuestionAnswerChangedListener(tableLayout, this, !GradleVariantConfig.isButtonNavigationActive()));
} else if (questionView instanceof NumberRadioButtonMultiquestionView) {
((NumberRadioButtonMultiquestionView) questionView).setOnAnswerChangedListener(new QuestionAnswerChangedListener(tableLayout, this, !GradleVariantConfig.isButtonNavigationActive()));
((NumberRadioButtonMultiquestionView) questionView).setOnAnswerOptionChangedListener(new QuestionAnswerChangedListener(tableLayout, this, !GradleVariantConfig.isButtonNavigationActive()));
} else if (questionView instanceof DynamicStockImageRadioButtonSingleQuestionView) {
((DynamicStockImageRadioButtonSingleQuestionView) questionView).setOnAnswerChangedListener(new QuestionAnswerChangedListener(tableLayout, this, !GradleVariantConfig.isButtonNavigationActive()));
((DynamicStockImageRadioButtonSingleQuestionView) questionView).setOnAnswerOptionChangedListener(new QuestionAnswerChangedListener(tableLayout, this, !GradleVariantConfig.isButtonNavigationActive()));
}
}
use of org.eyeseetea.malariacare.views.question.multiquestion.NumberRadioButtonMultiquestionView in project pictureapp by EyeSeeTea.
the class DynamicTabAdapter method renderQuestion.
public void renderQuestion(View rowView, int tabType, Question screenQuestion) {
TableRow tableRow;
IQuestionViewFactory questionViewFactory;
questionViewFactory = (Tab.isMultiQuestionTab(tabType) || Tab.isDynamicTreatmentTab(tabType)) ? new MultiQuestionViewFactory() : new SingleQuestionViewFactory();
// Se get the value from Session
int visibility = View.GONE;
Survey survey = (screenQuestion.isStockQuestion() || screenQuestion.isDynamicStockQuestion()) ? Session.getStockSurvey() : getMalariaSurvey();
if (!screenQuestion.isHiddenBySurveyAndHeader(survey) || !Tab.isMultiQuestionTab(tabType)) {
visibility = View.VISIBLE;
}
Value value = screenQuestion.getValueBySession();
tableRow = new TableRow(context);
IQuestionView questionView = questionViewFactory.getView(context, screenQuestion.getOutput());
if (questionView != null) {
if (questionView instanceof IMultiQuestionView) {
mMultiQuestionViews.add((IMultiQuestionView) questionView);
((IMultiQuestionView) questionView).setHeader(Utils.getInternationalizedString(screenQuestion.getForm_name()));
}
addTagQuestion(screenQuestion, (View) questionView);
configureLayoutParams(tabType, tableRow, (LinearLayout) questionView);
questionView.setHelpText(Utils.getInternationalizedString(screenQuestion.getHelp_text()));
questionView.setEnabled(!readOnly);
if (questionView instanceof IImageQuestionView) {
((IImageQuestionView) questionView).setImage(screenQuestion.getInternationalizedPath());
}
if (screenQuestion.isDynamicStockQuestion()) {
Treatment treatment = new Treatment(getMalariaSurvey(), Session.getStockSurvey());
if (treatment.hasTreatment()) {
org.eyeseetea.malariacare.data.database.model.Treatment dbTreatment = treatment.getTreatment();
Question actAnsweredNo = treatment.getACTQuestionAnsweredNo();
screenQuestion.setAnswer(treatment.getACTOptions(dbTreatment));
((DynamicStockImageRadioButtonSingleQuestionView) questionView).setOptionDose(treatment.getOptionDose(dbTreatment));
}
((DynamicStockImageRadioButtonSingleQuestionView) questionView).setQuestion(screenQuestion);
((DynamicStockImageRadioButtonSingleQuestionView) questionView).setOptions(screenQuestion.getAnswer().getOptions());
//Getting the question to put the correct values on it
ArrayList<Question> questions = new ArrayList<>();
for (Option option : screenQuestion.getAnswer().getOptions()) {
Question question = Question.findByID(option.getId_option());
if (question != null) {
questions.add(question);
}
}
survey.getValuesFromDB();
for (Question question : questions) {
Value valueStock = question.getValueBySession();
questionView.setValue(valueStock);
}
}
if (questionView instanceof AOptionQuestionView) {
((AOptionQuestionView) questionView).setQuestion(screenQuestion);
List<Option> options = screenQuestion.getAnswer().getOptions();
((AOptionQuestionView) questionView).setOptions(options);
}
if (questionView instanceof NumberRadioButtonMultiquestionView) {
if (doseByQuestion != null) {
((NumberRadioButtonMultiquestionView) questionView).setDose(doseByQuestion.get(screenQuestion.getId_question()));
}
((NumberRadioButtonMultiquestionView) questionView).setQuestion(screenQuestion);
((NumberRadioButtonMultiquestionView) questionView).setOptions(screenQuestion.getAnswer().getOptions());
}
if (!readOnly) {
configureAnswerChangedListener(questionView);
}
if (reloadingQuestionFromInvalidOption) {
reloadingQuestionFromInvalidOption = false;
} else {
questionView.setValue(value);
}
setupNavigationByQuestionView(rowView.getRootView(), questionView);
tableRow.addView((View) questionView);
swipeTouchListener.addClickableView(tableRow);
setVisibilityAndAddRow(tableRow, screenQuestion, visibility);
}
}
use of org.eyeseetea.malariacare.views.question.multiquestion.NumberRadioButtonMultiquestionView in project pictureapp by EyeSeeTea.
the class MultiQuestionViewFactory method getView.
public IQuestionView getView(Context context, int typeQuestion) {
switch(typeQuestion) {
case Constants.SHORT_TEXT:
TextMultiQuestionView shortTextMultiQuestionView = new TextMultiQuestionView(context);
shortTextMultiQuestionView.setInputType(InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
return shortTextMultiQuestionView;
case Constants.LONG_TEXT:
TextMultiQuestionView longTextMultiQuestionView = new TextMultiQuestionView(context);
longTextMultiQuestionView.setInputType(InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE);
return longTextMultiQuestionView;
case Constants.PHONE:
return new PhoneMultiQuestionView(context);
case Constants.INT:
return new NumberMultiQuestionView(context);
case Constants.POSITIVE_INT:
return new PositiveNumberMultiQuestionView(context);
case Constants.POSITIVE_OR_ZERO_INT:
return new PositiveOrZeroNumberMultiQuestionView(context);
case Constants.RADIO_GROUP_HORIZONTAL:
return new RadioButtonMultiQuestionView(context);
case Constants.QUESTION_LABEL:
return new LabelMultiQuestionView(context);
case Constants.DROPDOWN_LIST:
case Constants.DROPDOWN_OU_LIST:
return new DropdownMultiQuestionView(context);
case Constants.SWITCH_BUTTON:
return new SwitchMultiQuestionView(context);
case Constants.DYNAMIC_TREATMENT_SWITCH_NUMBER:
return new NumberRadioButtonMultiquestionView(context);
}
return null;
}
Aggregations