mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
klint cleaning
This commit is contained in:
parent
0cea26ec77
commit
6001ac60ab
7 changed files with 11 additions and 18 deletions
|
@ -24,7 +24,7 @@ import com.squareup.moshi.JsonClass
|
|||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class PollSummaryContent(
|
||||
//Index of my vote
|
||||
// Index of my vote
|
||||
var myVote: Int? = null,
|
||||
// Array of VoteInfo, list is constructed so that there is only one vote by user
|
||||
// And that optionIndex is valid
|
||||
|
|
|
@ -16,16 +16,12 @@
|
|||
|
||||
package im.vector.matrix.android.internal.database.mapper
|
||||
|
||||
import im.vector.matrix.android.api.session.events.model.toContent
|
||||
import im.vector.matrix.android.api.session.events.model.toModel
|
||||
import im.vector.matrix.android.api.session.room.model.EditAggregatedSummary
|
||||
import im.vector.matrix.android.api.session.room.model.EventAnnotationsSummary
|
||||
import im.vector.matrix.android.api.session.room.model.PollResponseAggregatedSummary
|
||||
import im.vector.matrix.android.api.session.room.model.ReactionAggregatedSummary
|
||||
import im.vector.matrix.android.api.session.room.model.ReferencesAggregatedSummary
|
||||
import im.vector.matrix.android.internal.database.model.EditAggregatedSummaryEntity
|
||||
import im.vector.matrix.android.internal.database.model.EventAnnotationsSummaryEntity
|
||||
import im.vector.matrix.android.internal.database.model.PollResponseAggregatedSummaryEntity
|
||||
import im.vector.matrix.android.internal.database.model.ReactionAggregatedSummaryEntity
|
||||
import im.vector.matrix.android.internal.database.model.ReferencesAggregatedSummaryEntity
|
||||
import io.realm.RealmList
|
||||
|
|
|
@ -33,7 +33,6 @@ internal object PollResponseAggregatedSummaryEntityMapper {
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
fun map(model: PollResponseAggregatedSummary): PollResponseAggregatedSummaryEntity {
|
||||
return PollResponseAggregatedSummaryEntity(
|
||||
aggregatedContent = ContentMapper.map(model.aggregatedContent.toContent()),
|
||||
|
|
|
@ -130,7 +130,7 @@ internal class DefaultEventRelationsAggregationTask @Inject constructor(
|
|||
handleReplace(realm, event, content, roomId, isLocalEcho)
|
||||
} else if (content?.relatesTo?.type == RelationType.RESPONSE) {
|
||||
Timber.v("###RESPONSE in room $roomId for event ${event.eventId}")
|
||||
handleResponse(realm,userId,event, content, roomId, isLocalEcho)
|
||||
handleResponse(realm, userId, event, content, roomId, isLocalEcho)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,11 +344,11 @@ internal class DefaultEventRelationsAggregationTask @Inject constructor(
|
|||
val votes = sumModel.votes?.toMutableList() ?: ArrayList()
|
||||
val existingVoteIndex = votes.indexOfFirst { it.userId == senderId }
|
||||
if (existingVoteIndex != -1) {
|
||||
//Is the vote newer?
|
||||
// Is the vote newer?
|
||||
val existingVote = votes[existingVoteIndex]
|
||||
if (existingVote.voteTimestamp < eventTimestamp) {
|
||||
//Take the new one
|
||||
votes[existingVoteIndex] = VoteInfo(senderId,optionIndex, eventTimestamp)
|
||||
// Take the new one
|
||||
votes[existingVoteIndex] = VoteInfo(senderId, optionIndex, eventTimestamp)
|
||||
if (userId == senderId) {
|
||||
sumModel.myVote = optionIndex
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ internal class DefaultEventRelationsAggregationTask @Inject constructor(
|
|||
Timber.v("## POLL Ignoring vote (older than known one) eventId:$eventId ")
|
||||
}
|
||||
} else {
|
||||
votes.add(VoteInfo(senderId,optionIndex, eventTimestamp))
|
||||
votes.add(VoteInfo(senderId, optionIndex, eventTimestamp))
|
||||
if (userId == senderId) {
|
||||
sumModel.myVote = optionIndex
|
||||
}
|
||||
|
@ -373,8 +373,6 @@ internal class DefaultEventRelationsAggregationTask @Inject constructor(
|
|||
existingPollSummary.aggregatedContent = ContentMapper.map(sumModel.toContent())
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun handleInitialAggregatedRelations(event: Event, roomId: String, aggregation: AggregatedAnnotation, realm: Realm) {
|
||||
if (SHOULD_HANDLE_SERVER_AGREGGATION) {
|
||||
aggregation.chunk?.forEach {
|
||||
|
|
|
@ -88,7 +88,7 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses
|
|||
myVote = it.aggregatedContent?.myVote,
|
||||
isClosed = it.closedTime ?: Long.MAX_VALUE > System.currentTimeMillis(),
|
||||
votes = it.aggregatedContent?.votes
|
||||
?.groupBy ({ it.optionIndex }, { it.userId })
|
||||
?.groupBy({ it.optionIndex }, { it.userId })
|
||||
?.mapValues { it.value.size }
|
||||
)
|
||||
},
|
||||
|
|
|
@ -87,9 +87,11 @@ abstract class MessagePollItem : AbsMessageItem<MessagePollItem.Holder>() {
|
|||
if (index < resultLines.size) {
|
||||
val optionCount = votes?.get(index) ?: 0
|
||||
val count = if (percentMode) {
|
||||
if (totalVotes > 0)
|
||||
if (totalVotes > 0) {
|
||||
(optionCount / totalVotes.toFloat() * 100).roundToInt().let { "$it%" }
|
||||
else ""
|
||||
} else {
|
||||
""
|
||||
}
|
||||
} else {
|
||||
optionCount.toString()
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import butterknife.BindView
|
|||
import butterknife.ButterKnife
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.extensions.setTextOrHide
|
||||
import im.vector.riotx.features.themes.ThemeUtils
|
||||
|
||||
class PollResultLineView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
@ -69,7 +68,6 @@ class PollResultLineView @JvmOverloads constructor(
|
|||
percentTextView.setTypeface(percentTextView.getTypeface(), if (value) Typeface.BOLD else Typeface.NORMAL)
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
inflate(context, R.layout.item_timeline_event_poll_result_item, this)
|
||||
orientation = HORIZONTAL
|
||||
|
|
Loading…
Reference in a new issue