Search in sources :

Example 1 with ImageRadioButtonSingleQuestionView

use of org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView in project pictureapp by EyeSeeTea.

the class SingleQuestionViewFactory method getView.

public IQuestionView getView(Context context, int typeQuestion) {
    switch(typeQuestion) {
        case Constants.PHONE:
            return new PhoneSingleQuestionView(context);
        case Constants.POSITIVE_INT:
            return new PositiveNumberSingleQuestionView(context);
        case Constants.POSITIVE_OR_ZERO_INT:
            return new PositiveOrZeroNumberMultiQuestionView(context);
        case Constants.IMAGE_RADIO_GROUP_NO_DATAELEMENT:
            return new ImageRadioButtonSingleQuestionView(context);
        case Constants.IMAGE_RADIO_GROUP:
            return new ImageRadioButtonSingleQuestionView(context);
        case Constants.DYNAMIC_STOCK_IMAGE_RADIO_BUTTON:
            return new DynamicStockImageRadioButtonSingleQuestionView(context);
        case Constants.REMINDER:
        case Constants.WARNING:
            return new ReminderSingleQuestionView(context);
        case Constants.IMAGES_2:
        case Constants.IMAGES_4:
        case Constants.IMAGES_6:
        case Constants.IMAGES_5:
            ImageOptionSingleQuestionView twoColumnsImageOptionSingleQuestionView = new ImageOptionSingleQuestionView(context);
            twoColumnsImageOptionSingleQuestionView.setColumnsCount(2);
            return twoColumnsImageOptionSingleQuestionView;
        case Constants.IMAGES_3:
        case Constants.IMAGE_3_NO_DATAELEMENT:
            ImageOptionSingleQuestionView imageOptionSingleQuestionView = new ImageOptionSingleQuestionView(context);
            imageOptionSingleQuestionView.setColumnsCount(1);
            return imageOptionSingleQuestionView;
    }
    return null;
}
Also used : ReminderSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.ReminderSingleQuestionView) PhoneSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.PhoneSingleQuestionView) PositiveNumberSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.PositiveNumberSingleQuestionView) DynamicStockImageRadioButtonSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.DynamicStockImageRadioButtonSingleQuestionView) PositiveOrZeroNumberMultiQuestionView(org.eyeseetea.malariacare.views.question.multiquestion.PositiveOrZeroNumberMultiQuestionView) ImageOptionSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.ImageOptionSingleQuestionView) DynamicStockImageRadioButtonSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.DynamicStockImageRadioButtonSingleQuestionView) ImageRadioButtonSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView)

Example 2 with ImageRadioButtonSingleQuestionView

use of org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView 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();
        }
    });
}
Also used : ImageRadioButtonOption(org.eyeseetea.malariacare.views.option.ImageRadioButtonOption) ImageButton(android.widget.ImageButton) TableRow(android.widget.TableRow) IMultiQuestionView(org.eyeseetea.malariacare.views.question.IMultiQuestionView) Question(org.eyeseetea.malariacare.data.database.model.Question) QuestionOption(org.eyeseetea.malariacare.data.database.model.QuestionOption) ImageRadioButtonOption(org.eyeseetea.malariacare.views.option.ImageRadioButtonOption) Option(org.eyeseetea.malariacare.data.database.model.Option) AKeyboardQuestionView(org.eyeseetea.malariacare.views.question.AKeyboardQuestionView) ImageView(android.widget.ImageView) AOptionQuestionView(org.eyeseetea.malariacare.views.question.AOptionQuestionView) View(android.view.View) INavigationQuestionView(org.eyeseetea.malariacare.views.question.INavigationQuestionView) IQuestionView(org.eyeseetea.malariacare.views.question.IQuestionView) ImageRadioButtonSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView) CustomTextView(org.eyeseetea.sdk.presentation.views.CustomTextView) ListView(android.widget.ListView) IMultiQuestionView(org.eyeseetea.malariacare.views.question.IMultiQuestionView) DynamicStockImageRadioButtonSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.DynamicStockImageRadioButtonSingleQuestionView) IImageQuestionView(org.eyeseetea.malariacare.views.question.IImageQuestionView) NumberRadioButtonMultiquestionView(org.eyeseetea.malariacare.views.question.multiquestion.NumberRadioButtonMultiquestionView) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout) ImageRadioButtonSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView) DynamicStockImageRadioButtonSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.DynamicStockImageRadioButtonSingleQuestionView)

Example 3 with ImageRadioButtonSingleQuestionView

use of org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView in project pictureapp by EyeSeeTea.

the class DynamicTabAdapter method OnOptionAnswered.

public void OnOptionAnswered(View view, Option selectedOption, boolean moveToNextQuestion) {
    if (moveToNextQuestion) {
        navigationController.isMovingToForward = true;
    }
    Question question = (Question) view.getTag();
    if (!selectedOption.getName().isEmpty() && question.getOutput() == Constants.DROPDOWN_OU_LIST) {
        OrgUnit orgUnit = OrgUnit.findByUID(selectedOption.getName());
        assignOrgUnitToSurvey(Session.getMalariaSurvey(), orgUnit);
        assignOrgUnitToSurvey(Session.getStockSurvey(), orgUnit);
    }
    Question counterQuestion = question.findCounterByOption(selectedOption);
    if (counterQuestion == null) {
        saveOptionValue(view, selectedOption, question, moveToNextQuestion);
    } else if (!(view instanceof ImageRadioButtonSingleQuestionView)) {
        showConfirmCounter(view, selectedOption, question, counterQuestion);
    }
}
Also used : OrgUnit(org.eyeseetea.malariacare.data.database.model.OrgUnit) Question(org.eyeseetea.malariacare.data.database.model.Question) ImageRadioButtonSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView) DynamicStockImageRadioButtonSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.DynamicStockImageRadioButtonSingleQuestionView)

Aggregations

DynamicStockImageRadioButtonSingleQuestionView (org.eyeseetea.malariacare.views.question.singlequestion.DynamicStockImageRadioButtonSingleQuestionView)3 ImageRadioButtonSingleQuestionView (org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView)3 Question (org.eyeseetea.malariacare.data.database.model.Question)2 View (android.view.View)1 ImageButton (android.widget.ImageButton)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 ListView (android.widget.ListView)1 ScrollView (android.widget.ScrollView)1 TableRow (android.widget.TableRow)1 Option (org.eyeseetea.malariacare.data.database.model.Option)1 OrgUnit (org.eyeseetea.malariacare.data.database.model.OrgUnit)1 QuestionOption (org.eyeseetea.malariacare.data.database.model.QuestionOption)1 ImageRadioButtonOption (org.eyeseetea.malariacare.views.option.ImageRadioButtonOption)1 AKeyboardQuestionView (org.eyeseetea.malariacare.views.question.AKeyboardQuestionView)1 AOptionQuestionView (org.eyeseetea.malariacare.views.question.AOptionQuestionView)1 IImageQuestionView (org.eyeseetea.malariacare.views.question.IImageQuestionView)1 IMultiQuestionView (org.eyeseetea.malariacare.views.question.IMultiQuestionView)1 INavigationQuestionView (org.eyeseetea.malariacare.views.question.INavigationQuestionView)1 IQuestionView (org.eyeseetea.malariacare.views.question.IQuestionView)1