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