From 10b39ccd28dc7f4ba24f628e249ea5d78286c769 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 13 Dec 2021 21:08:52 +0100 Subject: [PATCH] Do some renaming --- .../timeline/factory/MessageItemFactory.kt | 8 +++--- .../room/detail/timeline/item/PollItem.kt | 2 +- .../detail/timeline/item/PollOptionItem.kt | 16 +++++------ .../timeline/item/PollOptionViewState.kt | 28 +++++++++---------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt index 1855acf981..9951558234 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -203,17 +203,17 @@ class MessageItemFactory @Inject constructor( optionViewStates.add( if (!isPollSent) { // Poll event is not send yet. Disable option. - PollOptionViewState.DisabledOptionWithInvisibleVotes(optionId, optionAnswer) + PollOptionViewState.PollSending(optionId, optionAnswer) } else if (isEnded) { // Poll is ended. Disable option, show votes and mark the winner. val isWinner = winnerVoteCount != 0 && voteCount == winnerVoteCount - PollOptionViewState.DisabledOptionWithVisibleVotes(optionId, optionAnswer, voteCount, votePercentage, isWinner) + PollOptionViewState.PollEnded(optionId, optionAnswer, voteCount, votePercentage, isWinner) } else if (didUserVoted) { // User voted to the poll, but poll is not ended. Enable option, show votes and mark the user's selection. - PollOptionViewState.EnabledOptionWithVisibleVotes(optionId, optionAnswer, voteCount, votePercentage, isMyVote) + PollOptionViewState.PollVoted(optionId, optionAnswer, voteCount, votePercentage, isMyVote) } else { // User didn't voted yet and poll is not ended yet. Enable options, hide votes. - PollOptionViewState.EnabledOptionWithInvisibleVotes(optionId, optionAnswer) + PollOptionViewState.PollReady(optionId, optionAnswer) } ) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollItem.kt index 6ec8427bf9..0db1585c45 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollItem.kt @@ -72,7 +72,7 @@ abstract class PollItem : AbsMessageItem() { .apply { setTag(STUB_ID, tag) render( - state = optionViewStates?.getOrNull(index) ?: PollOptionViewState.DisabledOptionWithInvisibleVotes(option.optionId, option.optionAnswer) + state = optionViewStates?.getOrNull(index) ?: PollOptionViewState.PollSending(option.optionId, option.optionAnswer) ) } pollOptionItem.setOnClickListener { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionItem.kt index a5525bf00a..39a647401b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionItem.kt @@ -47,35 +47,35 @@ class PollOptionItem @JvmOverloads constructor( views.optionNameTextView.text = state.optionAnswer when (state) { - is PollOptionViewState.DisabledOptionWithInvisibleVotes -> renderDisabledOptionWithInvisibleVotes() - is PollOptionViewState.DisabledOptionWithVisibleVotes -> renderDisabledOptionWithVisibleVotes(state) - is PollOptionViewState.EnabledOptionWithInvisibleVotes -> renderEnabledOptionWithInvisibleVotes() - is PollOptionViewState.EnabledOptionWithVisibleVotes -> renderEnabledOptionWithVisibleVotes(state) + is PollOptionViewState.PollSending -> renderPollSending() + is PollOptionViewState.PollEnded -> renderPollEnded(state) + is PollOptionViewState.PollReady -> renderPollReady() + is PollOptionViewState.PollVoted -> renderPollVoted(state) } } - private fun renderDisabledOptionWithInvisibleVotes() { + private fun renderPollSending() { views.optionCheckImageView.isVisible = false views.optionWinnerImageView.isVisible = false hideVotes() renderVoteSelection(false) } - private fun renderDisabledOptionWithVisibleVotes(state: PollOptionViewState.DisabledOptionWithVisibleVotes) { + private fun renderPollEnded(state: PollOptionViewState.PollEnded) { views.optionCheckImageView.isVisible = false views.optionWinnerImageView.isVisible = state.isWinner showVotes(state.voteCount, state.votePercentage) renderVoteSelection(state.isWinner) } - private fun renderEnabledOptionWithInvisibleVotes() { + private fun renderPollReady() { views.optionCheckImageView.isVisible = true views.optionWinnerImageView.isVisible = false hideVotes() renderVoteSelection(false) } - private fun renderEnabledOptionWithVisibleVotes(state: PollOptionViewState.EnabledOptionWithVisibleVotes) { + private fun renderPollVoted(state: PollOptionViewState.PollVoted) { views.optionCheckImageView.isVisible = true views.optionWinnerImageView.isVisible = false showVotes(state.voteCount, state.votePercentage) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionViewState.kt index 6542d4bc0a..5291e7f20a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionViewState.kt @@ -21,34 +21,34 @@ sealed class PollOptionViewState(open val optionId: String, /** * Represents a poll that is not sent to the server yet. */ - data class DisabledOptionWithInvisibleVotes(override val optionId: String, - override val optionAnswer: String + data class PollSending(override val optionId: String, + override val optionAnswer: String ) : PollOptionViewState(optionId, optionAnswer) /** * Represents a poll that is sent but not voted by the user */ - data class EnabledOptionWithInvisibleVotes(override val optionId: String, - override val optionAnswer: String + data class PollReady(override val optionId: String, + override val optionAnswer: String ) : PollOptionViewState(optionId, optionAnswer) /** * Represents a poll that user already voted. */ - data class EnabledOptionWithVisibleVotes(override val optionId: String, - override val optionAnswer: String, - val voteCount: Int, - val votePercentage: Double, - val isSelected: Boolean + data class PollVoted(override val optionId: String, + override val optionAnswer: String, + val voteCount: Int, + val votePercentage: Double, + val isSelected: Boolean ) : PollOptionViewState(optionId, optionAnswer) /** * Represents a poll that is ended. */ - data class DisabledOptionWithVisibleVotes(override val optionId: String, - override val optionAnswer: String, - val voteCount: Int, - val votePercentage: Double, - val isWinner: Boolean + data class PollEnded(override val optionId: String, + override val optionAnswer: String, + val voteCount: Int, + val votePercentage: Double, + val isWinner: Boolean ) : PollOptionViewState(optionId, optionAnswer) }