Class MultiQuestionAdapter


  • public class MultiQuestionAdapter
    extends androidx.fragment.app.FragmentPagerAdapter
    Class that handles questions lists used in MultiQuestionFragment
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String MULTIPLE_CHOICE_QUESTION
      The Definition type for multiple choice question
      static java.lang.String RATING_QUESTION
      The Definition type for rating question
      static java.lang.String TEXT_QUESTION
      The Definition type for text question
      • Fields inherited from class androidx.fragment.app.FragmentPagerAdapter

        BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT, BEHAVIOR_SET_USER_VISIBLE_HINT
      • Fields inherited from class androidx.viewpager.widget.PagerAdapter

        POSITION_NONE, POSITION_UNCHANGED
    • Constructor Summary

      Constructors 
      Constructor Description
      MultiQuestionAdapter​(java.util.List<Definition> definitions, androidx.fragment.app.FragmentManager fm, boolean isSurveyQuiz)
      Default constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean completeAnswer()
      Check if all questions have answers
      java.util.List<Answer> getAnswers()
      Return answers to the questions
      int getCount()  
      androidx.fragment.app.Fragment getItem​(int position)
      Create an instance of QuestionFragment
      • Methods inherited from class androidx.fragment.app.FragmentPagerAdapter

        destroyItem, finishUpdate, getItemId, instantiateItem, isViewFromObject, restoreState, saveState, setPrimaryItem, startUpdate
      • Methods inherited from class androidx.viewpager.widget.PagerAdapter

        destroyItem, finishUpdate, getItemPosition, getPageTitle, getPageWidth, instantiateItem, notifyDataSetChanged, registerDataSetObserver, setPrimaryItem, startUpdate, unregisterDataSetObserver
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultiQuestionAdapter

        public MultiQuestionAdapter​(java.util.List<Definition> definitions,
                                    @NonNull
                                    androidx.fragment.app.FragmentManager fm,
                                    boolean isSurveyQuiz)
        Default constructor
        Parameters:
        definitions - list of question Definition
        fm - instance of FragmentManager
        isSurveyQuiz - true if the fragment was used as a survey quiz from view content challenges
    • Method Detail

      • getItem

        @NonNull
        public androidx.fragment.app.Fragment getItem​(int position)
        Create an instance of QuestionFragment
        Specified by:
        getItem in class androidx.fragment.app.FragmentPagerAdapter
        Parameters:
        position - item position
        Returns:
        instance of QuestionFragment
      • getCount

        public int getCount()
        Specified by:
        getCount in class androidx.viewpager.widget.PagerAdapter
      • getAnswers

        public java.util.List<Answer> getAnswers()
        Return answers to the questions
        Returns:
        list of Answer
      • completeAnswer

        public boolean completeAnswer()
        Check if all questions have answers
        Returns:
        true if all questions have answer, false otherwise