mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-12-18 14:42:16 +03:00
use EnumActorTypeConverter for poll models
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
4595820aa8
commit
8969f2d3cc
6 changed files with 16 additions and 10 deletions
|
@ -30,7 +30,6 @@ import com.nextcloud.talk.databinding.PollResultVoterItemBinding
|
||||||
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
|
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
|
||||||
import com.nextcloud.talk.extensions.loadGuestAvatar
|
import com.nextcloud.talk.extensions.loadGuestAvatar
|
||||||
import com.nextcloud.talk.extensions.loadUserAvatar
|
import com.nextcloud.talk.extensions.loadUserAvatar
|
||||||
import com.nextcloud.talk.models.json.converters.EnumActorTypeConverter
|
|
||||||
import com.nextcloud.talk.models.json.participants.Participant
|
import com.nextcloud.talk.models.json.participants.Participant
|
||||||
import com.nextcloud.talk.polls.model.PollDetails
|
import com.nextcloud.talk.polls.model.PollDetails
|
||||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||||
|
@ -55,7 +54,7 @@ class PollResultVoterViewHolder(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadAvatar(pollDetail: PollDetails, avatar: ImageView) {
|
private fun loadAvatar(pollDetail: PollDetails, avatar: ImageView) {
|
||||||
when (EnumActorTypeConverter().getFromString(pollDetail.actorType)) {
|
when (pollDetail.actorType) {
|
||||||
Participant.ActorType.GUESTS -> {
|
Participant.ActorType.GUESTS -> {
|
||||||
var displayName = NextcloudTalkApplication.sharedApplication?.resources?.getString(R.string.nc_guest)
|
var displayName = NextcloudTalkApplication.sharedApplication?.resources?.getString(R.string.nc_guest)
|
||||||
if (!TextUtils.isEmpty(pollDetail.actorDisplayName)) {
|
if (!TextUtils.isEmpty(pollDetail.actorDisplayName)) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ import com.nextcloud.talk.databinding.PollResultVotersOverviewItemBinding
|
||||||
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
|
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
|
||||||
import com.nextcloud.talk.extensions.loadGuestAvatar
|
import com.nextcloud.talk.extensions.loadGuestAvatar
|
||||||
import com.nextcloud.talk.extensions.loadUserAvatar
|
import com.nextcloud.talk.extensions.loadUserAvatar
|
||||||
import com.nextcloud.talk.models.json.converters.EnumActorTypeConverter
|
|
||||||
import com.nextcloud.talk.models.json.participants.Participant
|
import com.nextcloud.talk.models.json.participants.Participant
|
||||||
import com.nextcloud.talk.polls.model.PollDetails
|
import com.nextcloud.talk.polls.model.PollDetails
|
||||||
import com.nextcloud.talk.utils.DisplayUtils
|
import com.nextcloud.talk.utils.DisplayUtils
|
||||||
|
@ -86,7 +85,7 @@ class PollResultVotersOverviewViewHolder(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadAvatar(pollDetail: PollDetails, avatar: ImageView) {
|
private fun loadAvatar(pollDetail: PollDetails, avatar: ImageView) {
|
||||||
when (EnumActorTypeConverter().getFromString(pollDetail.actorType)) {
|
when (pollDetail.actorType) {
|
||||||
Participant.ActorType.GUESTS -> {
|
Participant.ActorType.GUESTS -> {
|
||||||
var displayName = NextcloudTalkApplication.sharedApplication?.resources?.getString(R.string.nc_guest)
|
var displayName = NextcloudTalkApplication.sharedApplication?.resources?.getString(R.string.nc_guest)
|
||||||
if (!TextUtils.isEmpty(pollDetail.actorDisplayName)) {
|
if (!TextUtils.isEmpty(pollDetail.actorDisplayName)) {
|
||||||
|
|
|
@ -20,12 +20,14 @@
|
||||||
|
|
||||||
package com.nextcloud.talk.polls.model
|
package com.nextcloud.talk.polls.model
|
||||||
|
|
||||||
|
import com.nextcloud.talk.models.json.participants.Participant
|
||||||
|
|
||||||
data class Poll(
|
data class Poll(
|
||||||
val id: String,
|
val id: String,
|
||||||
val question: String?,
|
val question: String?,
|
||||||
val options: List<String>?,
|
val options: List<String>?,
|
||||||
val votes: Map<String, Int>?,
|
val votes: Map<String, Int>?,
|
||||||
val actorType: String?,
|
val actorType: Participant.ActorType?,
|
||||||
val actorId: String?,
|
val actorId: String?,
|
||||||
val actorDisplayName: String?,
|
val actorDisplayName: String?,
|
||||||
val status: Int,
|
val status: Int,
|
||||||
|
|
|
@ -20,8 +20,10 @@
|
||||||
|
|
||||||
package com.nextcloud.talk.polls.model
|
package com.nextcloud.talk.polls.model
|
||||||
|
|
||||||
|
import com.nextcloud.talk.models.json.participants.Participant
|
||||||
|
|
||||||
data class PollDetails(
|
data class PollDetails(
|
||||||
val actorType: String?,
|
val actorType: Participant.ActorType?,
|
||||||
val actorId: String?,
|
val actorId: String?,
|
||||||
val actorDisplayName: String?,
|
val actorDisplayName: String?,
|
||||||
val optionId: Int
|
val optionId: Int
|
||||||
|
|
|
@ -22,13 +22,15 @@ package com.nextcloud.talk.polls.repositories.model
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField
|
import com.bluelinelabs.logansquare.annotation.JsonField
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject
|
import com.bluelinelabs.logansquare.annotation.JsonObject
|
||||||
|
import com.nextcloud.talk.models.json.converters.EnumActorTypeConverter
|
||||||
|
import com.nextcloud.talk.models.json.participants.Participant
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
@JsonObject
|
@JsonObject
|
||||||
data class PollDetailsResponse(
|
data class PollDetailsResponse(
|
||||||
@JsonField(name = ["actorType"])
|
@JsonField(name = ["actorType"], typeConverter = EnumActorTypeConverter::class)
|
||||||
var actorType: String? = null,
|
var actorType: Participant.ActorType? = null,
|
||||||
|
|
||||||
@JsonField(name = ["actorId"])
|
@JsonField(name = ["actorId"])
|
||||||
var actorId: String,
|
var actorId: String,
|
||||||
|
|
|
@ -22,6 +22,8 @@ package com.nextcloud.talk.polls.repositories.model
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField
|
import com.bluelinelabs.logansquare.annotation.JsonField
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject
|
import com.bluelinelabs.logansquare.annotation.JsonObject
|
||||||
|
import com.nextcloud.talk.models.json.converters.EnumActorTypeConverter
|
||||||
|
import com.nextcloud.talk.models.json.participants.Participant
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
|
@ -39,8 +41,8 @@ data class PollResponse(
|
||||||
@JsonField(name = ["votes"])
|
@JsonField(name = ["votes"])
|
||||||
var votes: Map<String, Int>? = null,
|
var votes: Map<String, Int>? = null,
|
||||||
|
|
||||||
@JsonField(name = ["actorType"])
|
@JsonField(name = ["actorType"], typeConverter = EnumActorTypeConverter::class)
|
||||||
var actorType: String? = null,
|
var actorType: Participant.ActorType? = null,
|
||||||
|
|
||||||
@JsonField(name = ["actorId"])
|
@JsonField(name = ["actorId"])
|
||||||
var actorId: String? = null,
|
var actorId: String? = null,
|
||||||
|
|
Loading…
Reference in a new issue