游戏评论 页面数据同步 适配'我的评论'模块

This commit is contained in:
kehaoyuan
2019-06-20 10:04:55 +08:00
parent ce44d3b2a7
commit 5119bdf545

View File

@ -24,7 +24,9 @@ class RatingAdapter(context: Context,
var ratingData: Rating? = null
val path = "游戏详情:评分"
val headDataPosition = -1
val headServiceCommentPosition = -1
val headMyCommentPosition = -2
public override fun setListData(updateData: MutableList<RatingComment>) {
var oldSize = TOP_ITEM_COUNT
@ -104,14 +106,14 @@ class RatingAdapter(context: Context,
}
if (ratingData?.serviceComment != null) {
includeServiceComment.commentItem.visibility = View.VISIBLE
initRatingComment(RatingCommentItemViewHolder(includeServiceComment), ratingData?.serviceComment!!, headDataPosition)
initRatingComment(RatingCommentItemViewHolder(includeServiceComment), ratingData?.serviceComment!!, headServiceCommentPosition)
} else {
includeServiceComment.commentItem.visibility = View.GONE
}
if (ratingData?.myComment != null) {
includeMyComment.commentItem.visibility = View.VISIBLE
initRatingComment(RatingCommentItemViewHolder(includeMyComment), ratingData?.serviceComment!!, headDataPosition)
initRatingComment(RatingCommentItemViewHolder(includeMyComment), ratingData?.myComment!!, headMyCommentPosition)
} else {
includeMyComment.commentItem.visibility = View.GONE
}
@ -217,13 +219,15 @@ class RatingAdapter(context: Context,
fun handleSyncData(intent: Intent?) {
SyncDataBetweenPageHelper.resultHandle(intent, object : OnSyncCallBack<RatingComment> {
override fun onData(dataPosition: Int): RatingComment? {
if (dataPosition == headDataPosition) return ratingData?.serviceComment
if (dataPosition == headServiceCommentPosition) return ratingData?.serviceComment
if (dataPosition == headMyCommentPosition) return ratingData?.myComment
return mEntityList[dataPosition]
}
override fun onNotify(dataPosition: Int) {
if (dataPosition == headDataPosition) notifyItemChanged(0)
else notifyItemChanged(dataPosition + 1)
if (dataPosition == headServiceCommentPosition || dataPosition == headMyCommentPosition) {
notifyItemChanged(0)
} else notifyItemChanged(dataPosition + 1)
}
})
}