avoid to divide by zero

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-07-22 19:16:19 +02:00 committed by Andy Scherzinger (Rebase PR Action)
parent c97d02fdde
commit 34686dd581

View File

@ -63,7 +63,10 @@ class PollResultsViewModel @Inject constructor() : ViewModel() {
private fun initPollResults(poll: Poll) { private fun initPollResults(poll: Poll) {
_items.value = ArrayList() _items.value = ArrayList()
val oneVoteInPercent = HUNDRED / poll.numVoters var oneVoteInPercent = 0
if (poll.numVoters != 0) {
oneVoteInPercent = HUNDRED / poll.numVoters
}
poll.options?.forEachIndexed { index, option -> poll.options?.forEachIndexed { index, option ->
val votersAmountForThisOption = getVotersAmountForOption(poll, index) val votersAmountForThisOption = getVotersAmountForOption(poll, index)