From 5d5331e8b51e1b47708c28aafa87ea8ca915bab1 Mon Sep 17 00:00:00 2001 From: HuanChengFly <609486518@qq.com> Date: Mon, 5 Oct 2020 20:12:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E6=97=B6=E6=8F=90=E7=A4=BA=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../post/api/adapters/MessageListAdapter.kt | 18 +++++++++++++++ .../tieba/post/api/models/ForumPageBean.kt | 23 ++++++++++++++++++- .../tieba/post/api/models/MessageListBean.kt | 3 +++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/huanchengfly/tieba/post/api/adapters/MessageListAdapter.kt diff --git a/app/src/main/java/com/huanchengfly/tieba/post/api/adapters/MessageListAdapter.kt b/app/src/main/java/com/huanchengfly/tieba/post/api/adapters/MessageListAdapter.kt new file mode 100644 index 00000000..544616b4 --- /dev/null +++ b/app/src/main/java/com/huanchengfly/tieba/post/api/adapters/MessageListAdapter.kt @@ -0,0 +1,18 @@ +package com.huanchengfly.tieba.post.api.adapters + +import com.google.gson.JsonDeserializationContext +import com.google.gson.JsonDeserializer +import com.google.gson.JsonElement +import com.google.gson.JsonParseException +import com.huanchengfly.tieba.post.api.models.MessageListBean.MessageInfoBean +import java.lang.reflect.Type +import java.util.* + +class MessageListAdapter : JsonDeserializer> { + @Throws(JsonParseException::class) + override fun deserialize(json: JsonElement, typeOfT: Type, context: JsonDeserializationContext): List { + return if (json.isJsonPrimitive) { + ArrayList() + } else context.deserialize(json, typeOfT) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/huanchengfly/tieba/post/api/models/ForumPageBean.kt b/app/src/main/java/com/huanchengfly/tieba/post/api/models/ForumPageBean.kt index 4c7bfaec..7c4cdfda 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/api/models/ForumPageBean.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/api/models/ForumPageBean.kt @@ -34,13 +34,28 @@ class ForumPageBean : ErrorBean() { class ZyqDefineBean : BaseBean() { var name: String? = null var link: String? = null - } class ManagerBean : BaseBean() { val id: String? = null val name: String? = null + } + data class ThemeColors( + var day: ThemeColor, + var dark: ThemeColor, + var night: ThemeColor + ) { + data class ThemeColor( + @SerializedName("common_color") + var commonColor: String, + @SerializedName("dark_color") + var darkColor: String, + @SerializedName("font_color") + var fontColor: String, + @SerializedName("light_color") + var lightColor: String, + ) } class ForumBean : BaseBean() { @@ -71,6 +86,12 @@ class ForumPageBean : ErrorBean() { @SerializedName("member_num") var memberNum: String? = null + @SerializedName("thread_num") + var threadNum: String? = null + + @SerializedName("theme_color") + lateinit var themeColor: ThemeColors + @SerializedName("post_num") var postNum: String? = null var managers: List? = null diff --git a/app/src/main/java/com/huanchengfly/tieba/post/api/models/MessageListBean.kt b/app/src/main/java/com/huanchengfly/tieba/post/api/models/MessageListBean.kt index 462847bd..0173cf97 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/api/models/MessageListBean.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/api/models/MessageListBean.kt @@ -2,6 +2,7 @@ package com.huanchengfly.tieba.post.api.models import com.google.gson.annotations.JsonAdapter import com.google.gson.annotations.SerializedName +import com.huanchengfly.tieba.post.api.adapters.MessageListAdapter import com.huanchengfly.tieba.post.api.adapters.PortraitAdapter import com.huanchengfly.tieba.post.models.BaseBean @@ -10,9 +11,11 @@ class MessageListBean : BaseBean() { val errorCode: String? = null val time: Long = 0 + @JsonAdapter(MessageListAdapter::class) @SerializedName("reply_list") val replyList: List? = null + @JsonAdapter(MessageListAdapter::class) @SerializedName("at_list") val atList: List? = null val page: PageInfoBean? = null