Search in sources :

Example 1 with DynamicTabAdapter

use of org.eyeseetea.malariacare.layout.adapters.survey.DynamicTabAdapter in project pictureapp by EyeSeeTea.

the class SurveyFragment method showSurvey.

private void showSurvey() {
    try {
        LayoutInflater inflater = LayoutInflater.from(getActivity().getApplicationContext());
        dynamicTabAdapter = new DynamicTabAdapter(getActivity(), mReviewMode);
        View viewContent = inflater.inflate(dynamicTabAdapter.getLayout(), content, false);
        content.removeAllViews();
        content.addView(viewContent);
        ListView listViewTab = (ListView) llLayout.findViewById(R.id.listView);
        dynamicTabAdapter.addOnSwipeListener(listViewTab);
        listViewTab.setAdapter(dynamicTabAdapter);
        hideProgress();
    } catch (NullPointerException e) {
        new LoadingSurveyException(e);
    }
}
Also used : DynamicTabAdapter(org.eyeseetea.malariacare.layout.adapters.survey.DynamicTabAdapter) LoadingSurveyException(org.eyeseetea.malariacare.domain.exception.LoadingSurveyException) ListView(android.widget.ListView) LayoutInflater(android.view.LayoutInflater) View(android.view.View) CustomTextView(org.eyeseetea.sdk.presentation.views.CustomTextView) ListView(android.widget.ListView)

Example 2 with DynamicTabAdapter

use of org.eyeseetea.malariacare.layout.adapters.survey.DynamicTabAdapter in project pictureapp by EyeSeeTea.

the class SurveyFragment method findOptionByText.

/**
     * Finds the option from the current answer associated with the given text.
     * Only for dynamicTabAdapter, required for automated testing.
     */
public Option findOptionByText(String text) {
    try {
        //Find adapter
        Tab tabZero = this.tabsList.get(0);
        DynamicTabAdapter tabAdapter = (DynamicTabAdapter) this.tabAdaptersCache.findAdapter(tabZero);
        //Get options from question
        List<Option> options = tabAdapter.navigationController.getCurrentQuestion().getAnswer().getOptions();
        //Return proper option if possible
        for (Option option : options) {
            if (option.getName().equals(text)) {
                return option;
            }
        }
    } catch (Exception ex) {
        return null;
    }
    return null;
}
Also used : DynamicTabAdapter(org.eyeseetea.malariacare.layout.adapters.survey.DynamicTabAdapter) Tab(org.eyeseetea.malariacare.data.database.model.Tab) Option(org.eyeseetea.malariacare.data.database.model.Option)

Aggregations

DynamicTabAdapter (org.eyeseetea.malariacare.layout.adapters.survey.DynamicTabAdapter)2 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ListView (android.widget.ListView)1 Option (org.eyeseetea.malariacare.data.database.model.Option)1 Tab (org.eyeseetea.malariacare.data.database.model.Tab)1 LoadingSurveyException (org.eyeseetea.malariacare.domain.exception.LoadingSurveyException)1 CustomTextView (org.eyeseetea.sdk.presentation.views.CustomTextView)1