use of org.eyeseetea.malariacare.presentation.factory.SingleQuestionViewFactory 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) || mDynamicTabAdapterStrategy.isMultiQuestionByVariant(tabType)) ? new MultiQuestionViewFactory() : new SingleQuestionViewFactory();
// Se get the value from Session
int visibility = View.GONE;
Survey survey = new SurveyFragmentStrategy().getRenderSurvey(screenQuestion);
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());
}
mDynamicTabAdapterStrategy.renderParticularSurvey(screenQuestion, survey, questionView);
if (questionView instanceof AOptionQuestionView) {
((AOptionQuestionView) questionView).setQuestion(screenQuestion);
List<Option> options = screenQuestion.getAnswer().getOptions();
((AOptionQuestionView) questionView).setOptions(options);
}
mDynamicTabAdapterStrategy.instanceOfSingleQuestion(questionView, screenQuestion);
if (!readOnly) {
configureAnswerChangedListener(questionView);
mDynamicTabAdapterStrategy.configureAnswerChangedListener(this, questionView);
}
if (reloadingQuestionFromInvalidOption) {
reloadingQuestionFromInvalidOption = false;
} else {
questionView.setValue(value);
}
setupNavigationByQuestionView(rowView.getRootView(), questionView);
tableRow.addView((View) questionView);
swipeTouchListener.addTouchableView(rowView);
swipeTouchListener.addTouchableView(tableRow);
swipeTouchListener.addTouchableView((View) questionView);
swipeTouchListener.addClickableView((View) questionView);
setVisibilityAndAddRow(tableRow, screenQuestion, visibility);
}
}
Aggregations