Package 

Class CreatePollViewModel


  • 
    public final class CreatePollViewModel
    extends ViewModel
                        

    ViewModel class for creating a poll. It handles the creation of the poll and its configuration.

    • Constructor Detail

      • CreatePollViewModel

        CreatePollViewModel()
    • Method Detail

      • getMultipleAnswersError

         final SharedFlow<Integer> getMultipleAnswersError()

        A shared flow that emits an error when the range of multiple answers is invalid.

      • getCreatePollParams

         final StateFlow<CreatePollParams> getCreatePollParams()

        The poll configuration. If the poll is not ready to be created, it will be null.

      • onTitleChanged

         final Unit onTitleChanged(String title)

        Set the title of the poll.

        Parameters:
        title - The title of the poll.
      • createOption

         final Unit createOption()

        Create a new empty option for the poll.

      • onOptionTextChanged

         final Unit onOptionTextChanged(Integer id, String text)

        Update the text of the option. If the text already exists in another option, it will set the duplicate error to true.

        Parameters:
        id - The id of the option.
        text - The text of the option.
      • setAllowMultipleVotes

         final Unit setAllowMultipleVotes(Boolean allowMultipleVotes)

        Set if the poll allows multiple votes.

        Parameters:
        allowMultipleVotes - True if the poll allows multiple votes, false otherwise.
      • setMaxAnswer

         final Unit setMaxAnswer(Integer maxAnswer)

        Set the maximum number of answers allowed.

        Parameters:
        maxAnswer - The maximum number of answers allowed.
      • setSuggestAnOption

         final Unit setSuggestAnOption(Boolean suggestAnOption)

        Set if the poll allows users to suggest new options.

        Parameters:
        suggestAnOption - True if the poll allows users to suggest new options, false otherwise.
      • setAnnonymousPoll

         final Unit setAnnonymousPoll(Boolean annonymousPoll)

        Set if the poll is annonymous.

        Parameters:
        annonymousPoll - True if the poll is annonymous, false otherwise.
      • setAllowAnswers

         final Unit setAllowAnswers(Boolean allowAnswers)

        Set if the poll allows users to add answers/comments.

        Parameters:
        allowAnswers - True if the poll allows users to add answers/comments, false otherwise.