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:
Konrad Pozniak 2019-06-22 21:55:03 +02:00 committed by GitHub
commit b95ff10a3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 325 additions and 689 deletions

View file

@ -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()
}
}
}
)