mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 12:39:58 +01:00
use EnumActorTypeConverter for poll models
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
091fddc2c0
commit
0bdbc8a538
@ -16,7 +16,6 @@ import com.nextcloud.talk.databinding.PollResultVoterItemBinding
|
||||
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
|
||||
import com.nextcloud.talk.extensions.loadGuestAvatar
|
||||
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.polls.model.PollDetails
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
@ -41,7 +40,7 @@ class PollResultVoterViewHolder(
|
||||
}
|
||||
|
||||
private fun loadAvatar(pollDetail: PollDetails, avatar: ImageView) {
|
||||
when (EnumActorTypeConverter().getFromString(pollDetail.actorType)) {
|
||||
when (pollDetail.actorType) {
|
||||
Participant.ActorType.GUESTS -> {
|
||||
var displayName = NextcloudTalkApplication.sharedApplication?.resources?.getString(R.string.nc_guest)
|
||||
if (!TextUtils.isEmpty(pollDetail.actorDisplayName)) {
|
||||
|
@ -19,7 +19,6 @@ import com.nextcloud.talk.databinding.PollResultVotersOverviewItemBinding
|
||||
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
|
||||
import com.nextcloud.talk.extensions.loadGuestAvatar
|
||||
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.polls.model.PollDetails
|
||||
import com.nextcloud.talk.utils.DisplayUtils
|
||||
@ -71,7 +70,7 @@ class PollResultVotersOverviewViewHolder(
|
||||
}
|
||||
|
||||
private fun loadAvatar(pollDetail: PollDetails, avatar: ImageView) {
|
||||
when (EnumActorTypeConverter().getFromString(pollDetail.actorType)) {
|
||||
when (pollDetail.actorType) {
|
||||
Participant.ActorType.GUESTS -> {
|
||||
var displayName = NextcloudTalkApplication.sharedApplication?.resources?.getString(R.string.nc_guest)
|
||||
if (!TextUtils.isEmpty(pollDetail.actorDisplayName)) {
|
||||
|
@ -6,12 +6,14 @@
|
||||
*/
|
||||
package com.nextcloud.talk.polls.model
|
||||
|
||||
import com.nextcloud.talk.models.json.participants.Participant
|
||||
|
||||
data class Poll(
|
||||
val id: String,
|
||||
val question: String?,
|
||||
val options: List<String>?,
|
||||
val votes: Map<String, Int>?,
|
||||
val actorType: String?,
|
||||
val actorType: Participant.ActorType?,
|
||||
val actorId: String?,
|
||||
val actorDisplayName: String?,
|
||||
val status: Int,
|
||||
|
@ -6,8 +6,10 @@
|
||||
*/
|
||||
package com.nextcloud.talk.polls.model
|
||||
|
||||
import com.nextcloud.talk.models.json.participants.Participant
|
||||
|
||||
data class PollDetails(
|
||||
val actorType: String?,
|
||||
val actorType: Participant.ActorType?,
|
||||
val actorId: String?,
|
||||
val actorDisplayName: String?,
|
||||
val optionId: Int
|
||||
|
@ -9,13 +9,15 @@ package com.nextcloud.talk.polls.repositories.model
|
||||
import android.os.Parcelable
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField
|
||||
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
|
||||
|
||||
@Parcelize
|
||||
@JsonObject
|
||||
data class PollDetailsResponse(
|
||||
@JsonField(name = ["actorType"])
|
||||
var actorType: String? = null,
|
||||
@JsonField(name = ["actorType"], typeConverter = EnumActorTypeConverter::class)
|
||||
var actorType: Participant.ActorType? = null,
|
||||
|
||||
@JsonField(name = ["actorId"])
|
||||
var actorId: String,
|
||||
|
@ -9,6 +9,8 @@ package com.nextcloud.talk.polls.repositories.model
|
||||
import android.os.Parcelable
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField
|
||||
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
|
||||
|
||||
@Parcelize
|
||||
@ -26,8 +28,8 @@ data class PollResponse(
|
||||
@JsonField(name = ["votes"])
|
||||
var votes: Map<String, Int>? = null,
|
||||
|
||||
@JsonField(name = ["actorType"])
|
||||
var actorType: String? = null,
|
||||
@JsonField(name = ["actorType"], typeConverter = EnumActorTypeConverter::class)
|
||||
var actorType: Participant.ActorType? = null,
|
||||
|
||||
@JsonField(name = ["actorId"])
|
||||
var actorId: String? = null,
|
||||
|
Loading…
Reference in New Issue
Block a user