-
public final class CreatePollViewModel extends ViewModel
ViewModel class for creating a poll. It handles the creation of the poll and its configuration.
-
-
Field Summary
Fields Modifier and Type Field Description private final StateFlow<List<PollAnswer>>optionsprivate final SharedFlow<Integer>multipleAnswersErrorprivate final StateFlow<CreatePollParams>createPollParamsprivate final StateFlow<Boolean>pollIsReady
-
Constructor Summary
Constructors Constructor Description CreatePollViewModel()
-
Method Summary
Modifier and Type Method Description final StateFlow<List<PollAnswer>>getOptions()The options for the poll. final SharedFlow<Integer>getMultipleAnswersError()A shared flow that emits an error when the range of multiple answers is invalid. final StateFlow<CreatePollParams>getCreatePollParams()The poll configuration. final StateFlow<Boolean>getPollIsReady()Indicates if the poll is ready to be created. final UnitonTitleChanged(String title)Set the title of the poll. final UnitcreateOption()Create a new empty option for the poll. final UnitonOptionTextChanged(Integer id, String text)Update the text of the option. final UnitcreatePollConfig()Create a new poll config. final UnitsetAllowMultipleVotes(Boolean allowMultipleVotes)Set if the poll allows multiple votes. final UnitsetMaxAnswer(Integer maxAnswer)Set the maximum number of answers allowed. final UnitsetSuggestAnOption(Boolean suggestAnOption)Set if the poll allows users to suggest new options. final UnitsetAnnonymousPoll(Boolean annonymousPoll)Set if the poll is annonymous. final UnitsetAllowAnswers(Boolean allowAnswers)Set if the poll allows users to add answers/comments. -
Methods inherited from class io.getstream.chat.android.ui.feature.messages.composer.attachment.picker.poll.CreatePollViewModel
addCloseable, addCloseable, addCloseable, getCloseable -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getOptions
final StateFlow<List<PollAnswer>> getOptions()
The options for the poll.
-
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.
-
getPollIsReady
final StateFlow<Boolean> getPollIsReady()
Indicates if the poll is ready to be created.
-
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.
-
createPollConfig
final Unit createPollConfig()
Create a new poll config.
-
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.
-
-
-
-