Unlimited number of poll options (#1340)
* implement unlimited number of poll options * fixes * extract percent calculation into function so it can be used anywhere * add license header
This commit is contained in:
parent
d827bd120f
commit
b95ff10a3c
13 changed files with 325 additions and 689 deletions
|
@ -2,7 +2,6 @@ package com.keylesspalace.tusky.entity
|
|||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import java.util.*
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
data class Poll(
|
||||
val id: String,
|
||||
|
@ -31,12 +30,4 @@ data class Poll(
|
|||
data class PollOption(
|
||||
val title: String,
|
||||
@SerializedName("votes_count") val votesCount: Int
|
||||
) {
|
||||
fun getPercent(totalVotes: Int): Int {
|
||||
return if (votesCount == 0) {
|
||||
0
|
||||
} else {
|
||||
(votesCount / totalVotes.toDouble() * 100).roundToInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue