feat(SearchThreadBean): 增加字段
This commit is contained in:
parent
e216a52fb0
commit
e897a03084
|
|
@ -23,31 +23,21 @@ class SearchThreadAdapter(
|
|||
) {
|
||||
viewHolder.setText(R.id.item_search_thread_title, item.title)
|
||||
viewHolder.setText(R.id.item_search_thread_content, item.content)
|
||||
viewHolder.setVisibility(R.id.item_search_thread_content, !item.content.isNullOrBlank())
|
||||
viewHolder.setText(R.id.user_name, item.user?.userName)
|
||||
viewHolder.setVisibility(R.id.item_search_thread_content, item.content.isNotBlank())
|
||||
viewHolder.setText(R.id.user_name, item.user.userName)
|
||||
ImageUtil.load(
|
||||
viewHolder.getView(R.id.user_avatar),
|
||||
ImageUtil.LOAD_TYPE_AVATAR,
|
||||
item.user?.portrait
|
||||
item.user.portrait
|
||||
)
|
||||
if (item.forumName == null) {
|
||||
viewHolder.setText(
|
||||
R.id.user_content,
|
||||
if (item.time != null) DateTimeUtils.getRelativeTimeString(
|
||||
context,
|
||||
item.time
|
||||
) else null
|
||||
viewHolder.setText(
|
||||
R.id.user_content,
|
||||
context.getString(
|
||||
R.string.template_two_string,
|
||||
DateTimeUtils.getRelativeTimeString(context, item.time),
|
||||
context.getString(R.string.title_forum_name, item.forumName)
|
||||
)
|
||||
} else {
|
||||
viewHolder.setText(
|
||||
R.id.user_content,
|
||||
if (item.time != null) context.getString(
|
||||
R.string.template_two_string,
|
||||
DateTimeUtils.getRelativeTimeString(context, item.time),
|
||||
context.getString(R.string.title_forum_name, item.forumName)
|
||||
) else context.getString(R.string.title_forum_name, item.forumName)
|
||||
)
|
||||
}
|
||||
)
|
||||
viewHolder.itemView.background = getItemBackgroundDrawable(
|
||||
context,
|
||||
position,
|
||||
|
|
|
|||
|
|
@ -7,38 +7,52 @@ data class SearchThreadBean(
|
|||
val errorCode: Int,
|
||||
@SerializedName("error")
|
||||
val errorMsg: String,
|
||||
val data: DataBean? = null
|
||||
val data: DataBean
|
||||
) {
|
||||
data class DataBean(
|
||||
@SerializedName("has_more")
|
||||
val hasMore: Int? = null,
|
||||
val hasMore: Int,
|
||||
@SerializedName("current_page")
|
||||
val currentPage: Int? = null,
|
||||
val currentPage: Int,
|
||||
@SerializedName("post_list")
|
||||
val postList: List<ThreadInfoBean>? = null
|
||||
val postList: List<ThreadInfoBean> = emptyList()
|
||||
)
|
||||
|
||||
data class ThreadInfoBean(
|
||||
val tid: String? = null,
|
||||
val pid: String? = null,
|
||||
val title: String? = null,
|
||||
val content: String? = null,
|
||||
val time: String? = null,
|
||||
|
||||
val tid: String,
|
||||
val pid: String,
|
||||
val title: String,
|
||||
val content: String,
|
||||
val time: String,
|
||||
@SerializedName("post_num")
|
||||
val postNum: String? = null,
|
||||
|
||||
val postNum: String,
|
||||
@SerializedName("like_num")
|
||||
val likeNum: String,
|
||||
@SerializedName("share_num")
|
||||
val shareNum: String,
|
||||
@SerializedName("forum_id")
|
||||
val forumId: String,
|
||||
@SerializedName("forum_name")
|
||||
val forumName: String? = null,
|
||||
val user: UserInfoBean? = null,
|
||||
val type: Int? = null
|
||||
val forumName: String,
|
||||
val user: UserInfoBean,
|
||||
val type: Int,
|
||||
@SerializedName("forum_info")
|
||||
val forumInfo: ForumInfo
|
||||
)
|
||||
|
||||
data class ForumInfo(
|
||||
@SerializedName("forum_name")
|
||||
val forumName: String,
|
||||
val avatar: String,
|
||||
)
|
||||
|
||||
data class UserInfoBean(
|
||||
@SerializedName("user_name")
|
||||
val userName: String? = null,
|
||||
val userName: String,
|
||||
@SerializedName("show_nickname")
|
||||
val showNickname: String,
|
||||
@SerializedName("user_id")
|
||||
val userId: String? = null,
|
||||
val portrait: String? = null
|
||||
val userId: String,
|
||||
val portrait: String,
|
||||
)
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ class SearchThreadFragment : BaseFragment(), ISearchFragment, NewSearchActivity.
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
searchThreadAdapter = SearchThreadAdapter(this).apply {
|
||||
setOnItemClickListener { _, item, _ ->
|
||||
ThreadActivity.launch(attachContext, item.tid!!, item.pid)
|
||||
ThreadActivity.launch(attachContext, item.tid, item.pid)
|
||||
}
|
||||
}
|
||||
recyclerView.apply {
|
||||
|
|
@ -191,7 +191,7 @@ class SearchThreadFragment : BaseFragment(), ISearchFragment, NewSearchActivity.
|
|||
return
|
||||
}
|
||||
mData = searchThreadBean.data
|
||||
mData!!.postList?.let {
|
||||
mData!!.postList.let {
|
||||
searchThreadAdapter!!.insert(it)
|
||||
}
|
||||
page += 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue