Poll notifications (#1229)
* show poll notifications in the app * show poll notifications in the app * allow filtering poll notifications in the poll fragment * show poll notifications in system notifications
This commit is contained in:
parent
647238052b
commit
e735e4843e
44 changed files with 1076 additions and 318 deletions
|
|
@ -2,6 +2,7 @@ package com.keylesspalace.tusky.entity
|
|||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import java.util.*
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
data class Poll(
|
||||
val id: String,
|
||||
|
|
@ -30,4 +31,12 @@ 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