Search in sources :

Example 1 with Value

use of org.eyeseetea.malariacare.data.database.model.Value in project pictureapp by EyeSeeTea.

the class DynamicTabAdapter method goToLastQuestion.

private void goToLastQuestion() {
    navigationController.first();
    Value value = null;
    do {
        next();
        Question question = navigationController.getCurrentQuestion();
        value = question.getValueBySession();
        skipReminder();
    } while (value != null && !isDone(value));
    notifyDataSetChanged();
}
Also used : Value(org.eyeseetea.malariacare.data.database.model.Value) Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 2 with Value

use of org.eyeseetea.malariacare.data.database.model.Value in project pictureapp by EyeSeeTea.

the class DynamicTabAdapter method next.

/**
     * Changes the current question moving forward
     */
private void next() {
    Question question = navigationController.getCurrentQuestion();
    Value value = question.getValueBySession();
    if (isDone(value)) {
        navigationController.isMovingToForward = false;
        return;
    }
    navigationController.next(value != null ? value.getOption() : null);
    notifyDataSetChanged();
    hideKeyboard(PreferencesState.getInstance().getContext());
    question = navigationController.getCurrentQuestion();
    if (value != null && !readOnly && navigationController.getCurrentTotalPages() < question.getTotalQuestions()) {
        navigationController.setTotalPages(question.getTotalQuestions());
    }
    navigationController.isMovingToForward = false;
    isClicked = false;
}
Also used : Value(org.eyeseetea.malariacare.data.database.model.Value) Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 3 with Value

use of org.eyeseetea.malariacare.data.database.model.Value in project pictureapp by EyeSeeTea.

the class DynamicTabAdapter method finishOrNext.

/**
     * Advance to the next question with delay applied or finish survey according to question and
     * value.
     */
public void finishOrNext() {
    try {
        System.out.println(Session.getMalariaSurvey().getValuesFromDB().toString());
        System.out.println(Session.getStockSurvey().getValuesFromDB().toString());
    } catch (Exception e) {
    }
    if (Validation.hasErrors()) {
        Validation.showErrors();
        isClicked = false;
        return;
    }
    if (navigationController.getCurrentQuestion().hasCompulsoryNotAnswered()) {
        UIMessagesStrategy.getInstance().showCompulsoryUnansweredToast();
        isClicked = false;
        return;
    }
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
            Question question = navigationController.getCurrentQuestion();
            Value value = question.getValueBySession();
            if (isDone(value)) {
                navigationController.isMovingToForward = false;
                if (!wasPatientTested() || !BuildConfig.reviewScreen) {
                    surveyShowDone();
                } else {
                    DashboardActivity.dashboardActivity.showReviewFragment();
                    hideKeyboard(PreferencesState.getInstance().getContext());
                    isClicked = false;
                }
                return;
            }
            next();
        }
    }, 750);
}
Also used : Value(org.eyeseetea.malariacare.data.database.model.Value) Handler(android.os.Handler) Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 4 with Value

use of org.eyeseetea.malariacare.data.database.model.Value in project pictureapp by EyeSeeTea.

the class DynamicTabAdapter method saveOptionValue.

public void saveOptionValue(View view, Option selectedOption, Question question, boolean moveToNextQuestion) {
    Option answeredOption = (question != null) ? question.getAnsweredOption() : null;
    Value value = question.getValueBySession();
    if (goingBackwardAndModifiedValues(value, answeredOption, selectedOption)) {
        navigationController.setTotalPages(question.getTotalQuestions());
        isBackward = false;
    }
    question.saveValuesDDL(selectedOption, value);
    if (question.getOutput().equals(Constants.IMAGE_3_NO_DATAELEMENT) || question.getOutput().equals(Constants.IMAGE_RADIO_GROUP_NO_DATAELEMENT)) {
        switchHiddenMatches(question, selectedOption);
    }
    if (moveToNextQuestion) {
        navigationController.isMovingToForward = true;
        finishOrNext();
    } else {
        showOrHideChildren(question);
    }
}
Also used : Value(org.eyeseetea.malariacare.data.database.model.Value) QuestionOption(org.eyeseetea.malariacare.data.database.model.QuestionOption) ImageRadioButtonOption(org.eyeseetea.malariacare.views.option.ImageRadioButtonOption) Option(org.eyeseetea.malariacare.data.database.model.Option)

Example 5 with Value

use of org.eyeseetea.malariacare.data.database.model.Value in project pictureapp by EyeSeeTea.

the class ReviewScreenAdapter method getView.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    // Get the row layout
    Value value = (Value) getItem(position);
    TableRow rowView = (TableRow) this.lInflater.inflate(getRecordLayout(), parent, false);
    ReviewFragmentStrategy reviewFragmentStrategy = new ReviewFragmentStrategy();
    return reviewFragmentStrategy.createViewRow(rowView, value);
}
Also used : ReviewFragmentStrategy(org.eyeseetea.malariacare.strategies.ReviewFragmentStrategy) TableRow(android.widget.TableRow) Value(org.eyeseetea.malariacare.data.database.model.Value)

Aggregations

Value (org.eyeseetea.malariacare.data.database.model.Value)21 Question (org.eyeseetea.malariacare.data.database.model.Question)15 Survey (org.eyeseetea.malariacare.data.database.model.Survey)6 Option (org.eyeseetea.malariacare.data.database.model.Option)5 ArrayList (java.util.ArrayList)3 ImageRadioButtonOption (org.eyeseetea.malariacare.views.option.ImageRadioButtonOption)3 TableRow (android.widget.TableRow)2 QuestionOption (org.eyeseetea.malariacare.data.database.model.QuestionOption)2 ImportSummaryErrorException (org.eyeseetea.malariacare.domain.exception.ImportSummaryErrorException)2 AOptionQuestionView (org.eyeseetea.malariacare.views.question.AOptionQuestionView)2 IQuestionView (org.eyeseetea.malariacare.views.question.IQuestionView)2 Handler (android.os.Handler)1 View (android.view.View)1 Calendar (java.util.Calendar)1 CompositeScore (org.eyeseetea.malariacare.data.database.model.CompositeScore)1 Match (org.eyeseetea.malariacare.data.database.model.Match)1 QuestionRelation (org.eyeseetea.malariacare.data.database.model.QuestionRelation)1 Session.getMalariaSurvey (org.eyeseetea.malariacare.data.database.utils.Session.getMalariaSurvey)1 EventExtended (org.eyeseetea.malariacare.data.sync.importer.models.EventExtended)1 Treatment (org.eyeseetea.malariacare.domain.entity.Treatment)1