From ac5168a2eafd89dda2f1dcb0223528030e82e870 Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Thu, 13 Jul 2023 18:22:12 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E4=BB=A4=20POJO=20=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tieba/post/activities/ThreadActivity.kt | 19 +++----- .../api/interfaces/impls/MixedTiebaApiImpl.kt | 2 +- .../tieba/post/api/models/CollectDataBean.kt | 28 +++--------- .../tieba/post/api/models/CommonResponse.kt | 4 +- .../post/models/ThreadHistoryInfoBean.java | 44 ------------------- .../post/models/ThreadHistoryInfoBean.kt | 11 +++++ 6 files changed, 26 insertions(+), 82 deletions(-) delete mode 100644 app/src/main/java/com/huanchengfly/tieba/post/models/ThreadHistoryInfoBean.java create mode 100644 app/src/main/java/com/huanchengfly/tieba/post/models/ThreadHistoryInfoBean.kt diff --git a/app/src/main/java/com/huanchengfly/tieba/post/activities/ThreadActivity.kt b/app/src/main/java/com/huanchengfly/tieba/post/activities/ThreadActivity.kt index 26e2c9f6..84886a11 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/activities/ThreadActivity.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/activities/ThreadActivity.kt @@ -49,6 +49,7 @@ import com.huanchengfly.tieba.post.interfaces.CommonCallback import com.huanchengfly.tieba.post.models.ReplyInfoBean import com.huanchengfly.tieba.post.models.ThreadHistoryInfoBean import com.huanchengfly.tieba.post.models.database.History +import com.huanchengfly.tieba.post.toJson import com.huanchengfly.tieba.post.toastShort import com.huanchengfly.tieba.post.ui.common.theme.utils.ThemeUtils import com.huanchengfly.tieba.post.ui.widgets.VideoPlayerStandard @@ -488,15 +489,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment } } - fun getItemByPosition(itemPosition: Int): PostListItemBean? { - return if (itemPosition == 0) { - threadMainPostAdapter.threadPostBean - } else { - replyAdapter.getItem(itemPosition - 1) - } - } - - fun getItemPositionByPid(pid: String): Int { + private fun getItemPositionByPid(pid: String): Int { val threadPostId = threadMainPostAdapter.threadBean.postId return if (threadPostId == pid) { 0 @@ -659,10 +652,10 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment } var extras = "" if (postListItemBean != null) { - extras = ThreadHistoryInfoBean() - .setPid(postListItemBean.id) - .setSeeLz(seeLz) - .toString() + extras = ThreadHistoryInfoBean( + pid = postListItemBean.id, + isSeeLz = seeLz + ).toJson() } val history = History( title = dataBean!!.thread?.title ?: "", diff --git a/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/impls/MixedTiebaApiImpl.kt b/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/impls/MixedTiebaApiImpl.kt index b3c40f1a..7556ac4a 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/impls/MixedTiebaApiImpl.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/api/interfaces/impls/MixedTiebaApiImpl.kt @@ -400,8 +400,8 @@ object MixedTiebaApiImpl : ITiebaApi { RetrofitTiebaApi.NEW_TIEBA_API.addStore( listOf( CollectDataBean( - postId, threadId, + postId, "0", "0" ) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/api/models/CollectDataBean.kt b/app/src/main/java/com/huanchengfly/tieba/post/api/models/CollectDataBean.kt index 46fdf282..1120d6fd 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/api/models/CollectDataBean.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/api/models/CollectDataBean.kt @@ -2,29 +2,13 @@ package com.huanchengfly.tieba.post.api.models import com.huanchengfly.tieba.post.utils.GsonUtil -class CollectDataBean(var pid: String, var tid: String, var status: String, var type: String) { - fun setPid(pid: String): CollectDataBean { - this.pid = pid - return this - } - - fun setStatus(status: String): CollectDataBean { - this.status = status - return this - } - - fun setTid(tid: String): CollectDataBean { - this.tid = tid - return this - } - - fun setType(type: String): CollectDataBean { - this.type = type - return this - } - +data class CollectDataBean( + val pid: String, + val tid: String, + val status: String, + val type: String? = null +) { override fun toString(): String { return GsonUtil.getGson().toJson(this) } - } \ No newline at end of file diff --git a/app/src/main/java/com/huanchengfly/tieba/post/api/models/CommonResponse.kt b/app/src/main/java/com/huanchengfly/tieba/post/api/models/CommonResponse.kt index e3fd9e10..718485c1 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/api/models/CommonResponse.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/api/models/CommonResponse.kt @@ -7,8 +7,8 @@ import com.huanchengfly.tieba.post.models.BaseBean data class CommonResponse( @SerializedName("error_code", alternate = ["errno", "no"]) - var errorCode: Int?, + val errorCode: Int = 0, @JsonAdapter(ErrorMsgAdapter::class) @SerializedName("error_msg", alternate = ["errmsg", "error"]) - var errorMsg: String? + val errorMsg: String = "" ) : BaseBean() \ No newline at end of file diff --git a/app/src/main/java/com/huanchengfly/tieba/post/models/ThreadHistoryInfoBean.java b/app/src/main/java/com/huanchengfly/tieba/post/models/ThreadHistoryInfoBean.java deleted file mode 100644 index 8f2ce4c5..00000000 --- a/app/src/main/java/com/huanchengfly/tieba/post/models/ThreadHistoryInfoBean.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.huanchengfly.tieba.post.models; - -public class ThreadHistoryInfoBean extends BaseBean { - private boolean seeLz; - private String pid; - private String forumName; - private String floor; - - public String getForumName() { - return forumName; - } - - public ThreadHistoryInfoBean setForumName(String forumName) { - this.forumName = forumName; - return this; - } - - public String getFloor() { - return floor; - } - - public ThreadHistoryInfoBean setFloor(String floor) { - this.floor = floor; - return this; - } - - public boolean isSeeLz() { - return seeLz; - } - - public ThreadHistoryInfoBean setSeeLz(boolean seeLz) { - this.seeLz = seeLz; - return this; - } - - public String getPid() { - return pid; - } - - public ThreadHistoryInfoBean setPid(String pid) { - this.pid = pid; - return this; - } -} \ No newline at end of file diff --git a/app/src/main/java/com/huanchengfly/tieba/post/models/ThreadHistoryInfoBean.kt b/app/src/main/java/com/huanchengfly/tieba/post/models/ThreadHistoryInfoBean.kt new file mode 100644 index 00000000..49c37841 --- /dev/null +++ b/app/src/main/java/com/huanchengfly/tieba/post/models/ThreadHistoryInfoBean.kt @@ -0,0 +1,11 @@ +package com.huanchengfly.tieba.post.models + +import kotlinx.serialization.Serializable + +@Serializable +data class ThreadHistoryInfoBean( + val isSeeLz: Boolean = false, + val pid: String? = null, + val forumName: String? = null, + val floor: String? = null, +) : BaseBean() \ No newline at end of file