diff --git a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt index 0e37b68251..e3ccfba756 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt @@ -4,12 +4,14 @@ import android.content.Context import android.graphics.Color import android.view.View import android.view.ViewGroup +import android.widget.LinearLayout import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView import com.gh.base.BaseActivity import com.gh.common.constant.ItemViewType import com.gh.common.syncpage.ISyncAdapterHandler import com.gh.common.util.MtaHelper +import com.gh.common.util.dip2px import com.gh.common.util.goneIf import com.gh.gamecenter.R import com.gh.gamecenter.adapter.viewholder.FooterViewHolder @@ -18,6 +20,8 @@ import com.gh.gamecenter.databinding.CommunityAnswerItemBinding import com.gh.gamecenter.entity.CommunityEntity import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity import com.gh.gamecenter.qa.entity.ArticleEntity +import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity +import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity class ForumArticleListAdapter(context: Context, val mEntrance: String, val path: String) : ListAdapter(context), ISyncAdapterHandler { @@ -55,6 +59,11 @@ class ForumArticleListAdapter(context: Context, val mEntrance: String, val path: val viewHolder = holder as ForumArticleAskItemViewHolder val articleEntity = mEntityList[position] articleEntity.community = CommunityEntity(articleEntity.bbs.id, articleEntity.bbs.name) + + if (articleEntity.type == "bbs_article") articleEntity.type = "community_article" + if (articleEntity.type == "bbs_question") articleEntity.type = "question" + if (articleEntity.type == "bbs_video") articleEntity.type = "video" + viewHolder.binding.run { topLine.goneIf(position == 0) contentContainer.setBackgroundColor(Color.TRANSPARENT) @@ -63,9 +72,41 @@ class ForumArticleListAdapter(context: Context, val mEntrance: String, val path: includeVoteAndComment.voteCountContainer.setBackgroundColor(Color.TRANSPARENT) } viewHolder.bindForumArticleItem(articleEntity, mEntrance, path) + + if (articleEntity.type == "question") { + if (articleEntity.count.answer > 0) { + viewHolder.commentCount.text = articleEntity.count.answer.toString() + } else { + viewHolder.commentCount.text = "回答" + } + viewHolder.commentCount.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(mContext, R.drawable.community_comment_count), null, null, null) + viewHolder.voteCountContainer.visibility = View.GONE + val params = viewHolder.binding.includeVoteAndComment.root.layoutParams as LinearLayout.LayoutParams + params.width = 80f.dip2px() + viewHolder.binding.includeVoteAndComment.root.layoutParams = params + } else { + viewHolder.voteCountContainer.visibility = View.VISIBLE + val params = viewHolder.binding.includeVoteAndComment.root.layoutParams as LinearLayout.LayoutParams + params.width = 160f.dip2px() + viewHolder.binding.includeVoteAndComment.root.layoutParams = params + } + viewHolder.itemView.setOnClickListener { - MtaHelper.onEvent("论坛首页", viewHolder.getKey(BaseActivity.mergeEntranceAndPath(mEntrance, path)), "${articleEntity.title}(${articleEntity.id})") - mContext.startActivity(ArticleDetailActivity.getIntent(mContext, articleEntity.community, articleEntity.id, "", path)) + when (articleEntity.type) { + "community_article" -> { + MtaHelper.onEvent("论坛首页", viewHolder.getKey(BaseActivity.mergeEntranceAndPath(mEntrance, path)), "${articleEntity.title}(${articleEntity.id})") + mContext.startActivity(ArticleDetailActivity.getIntent(mContext, articleEntity.community, articleEntity.id, "", path)) + } + "video" -> { + MtaHelper.onEvent("论坛首页", viewHolder.getKey(BaseActivity.mergeEntranceAndPath(mEntrance, path)), "${articleEntity.title}(${articleEntity.id})") + mContext.startActivity(ForumVideoDetailActivity.getIntent(mContext, articleEntity.id ?:"")) + } + else -> { + MtaHelper.onEvent("论坛首页", viewHolder.getKey(BaseActivity.mergeEntranceAndPath(mEntrance, path)), "${articleEntity.title}(${articleEntity.id})") + mContext.startActivity(NewQuestionDetailActivity.getIntent(mContext, articleEntity.id + ?: "", mEntrance, path)) + } + } } } diff --git a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListFragment.kt b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListFragment.kt index 80a0e79fc0..5b8a736ac5 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListFragment.kt @@ -37,6 +37,7 @@ class ForumArticleListFragment : LazyListFragment() init { + setOverLimitSize(0) getRecordForums() } diff --git a/app/src/main/java/com/gh/gamecenter/forum/search/ForumContentSearchListAdapter.kt b/app/src/main/java/com/gh/gamecenter/forum/search/ForumContentSearchListAdapter.kt index 15eff5337c..db23647611 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/search/ForumContentSearchListAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/search/ForumContentSearchListAdapter.kt @@ -133,7 +133,6 @@ class ForumContentSearchListAdapter(context: Context, val mListViewModel: ForumC params.width = 160f.dip2px() answerViewHolder.binding.includeVoteAndComment.root.layoutParams = params } - } else { val forumSearchHolder = holder as ForumSearchContentListViewHolder if (answer.type == "video") {