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