fix:GHZSCY-6136 社区推荐信息流改版&新增图文内容类型—客户端

This commit is contained in:
张晨
2024-10-10 15:28:39 +08:00
parent b5bfce7a60
commit 9de1ef1f99
11 changed files with 149 additions and 27 deletions

View File

@ -43,6 +43,7 @@ data class FollowDynamicEntity(
const val FOLLOW_UPDATE_TYPE_LIBAO_EXCHANGE = "libao_exchange"
const val FOLLOW_UPDATE_TYPE_ARTICLE = "article"
const val FOLLOW_UPDATE_TYPE_USER_POST = "user_post"
const val FOLLOW_UPDATE_TYPE_IMAGE_ARTICLE = "image_article"
}
@Parcelize

View File

@ -387,6 +387,7 @@ class ForumArticleAskItemViewHolder(
voteCountContainer.visibility = View.GONE
}
forumNameContainer?.visibleIf(entity.community.id.isNotBlank())
if (entity.community.type == "official_bbs") {
forumIcon?.displayGameIcon(entity.community.icon, null)
} else {

View File

@ -240,6 +240,15 @@ class FollowActivityResultLauncher(
questionsDetailLauncher.launch(LauncherDestination(position, historyEntity = entity))
}
entity.type == ImageArticleEntity.IMAGE_ARTICLE_TYPE -> {
val imageArticleUri = Uri.Builder()
.path(RouteConsts.activity.imageArticleDetailActivity)
.appendQueryParameter(EntranceConsts.KEY_IMAGE_ARTICLE_ID, entity.id)
.appendQueryParameter(EntranceConsts.KEY_SOURCE_ENTRANCE, "关注-个人动态")
.build()
ARouter.getInstance().build(imageArticleUri).navigation()
}
else -> {
commentEntityLauncher.launch(LauncherDestination(position, historyEntity = entity))
}

View File

@ -28,8 +28,6 @@ import com.gh.gamecenter.forum.home.follow.FollowDynamicPersonalItem
import com.gh.gamecenter.forum.home.follow.viewholder.FollowFooterViewHolder
import com.gh.gamecenter.forum.home.follow.viewholder.FollowInvalidViewHolder
import com.gh.gamecenter.forum.home.follow.viewmodel.FollowDynamicListViewModel
import com.gh.gamecenter.forum.home.follow.viewmodel.FollowDynamicViewModel
import com.gh.gamecenter.forum.search.CommunitySearchEventListener
import com.gh.gamecenter.personalhome.PersonalItemViewHolder
class FollowDynamicAdapter(

View File

@ -35,6 +35,7 @@ import com.gh.gamecenter.core.provider.IVisitManagerProvider
import com.gh.gamecenter.core.utils.MD5Utils
import com.gh.gamecenter.databinding.FragmentFollowHomeBinding
import com.gh.gamecenter.entity.FollowUserEntity
import com.gh.gamecenter.eventbus.EBImageArticleChanged
import com.gh.gamecenter.eventbus.EBUserFollow
import com.gh.gamecenter.feature.provider.IMessageDetailProvider
import com.gh.gamecenter.forum.home.CommunityHomeFragment
@ -69,6 +70,7 @@ class FollowHomeFragment : LazyFragment(), IScrollable {
ownerProducer = { requireParentFragment() }
)
private lateinit var userViewModel: UserViewModel
private var userId: String? = null
@ -454,6 +456,30 @@ class FollowHomeFragment : LazyFragment(), IScrollable {
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(changed: EBImageArticleChanged) {
when (changed) {
is EBImageArticleChanged.VoteChanged -> {
viewModel.voteChanged(changed)
}
is EBImageArticleChanged.CommentChanged ->{
viewModel.commentChanged(changed)
}
is EBImageArticleChanged.DataChanged -> {
viewModel.itemChanged(changed)
}
is EBImageArticleChanged.DataDeleted -> {
viewModel.itemDeleted(changed)
}
else -> Unit
}
}
override fun onDestroy() {
super.onDestroy()
mScrollCalculatorHelper?.currentPlayer?.release()

View File

@ -7,6 +7,7 @@ import com.gh.gamecenter.core.utils.UrlFilterUtils
import com.gh.gamecenter.entity.FollowCommonContentCollection
import com.gh.gamecenter.entity.FollowDynamicEntity
import com.gh.gamecenter.entity.FollowDynamicEntity.Companion.FOLLOW_UPDATE_TYPE_ARTICLE
import com.gh.gamecenter.entity.FollowDynamicEntity.Companion.FOLLOW_UPDATE_TYPE_IMAGE_ARTICLE
import com.gh.gamecenter.entity.FollowDynamicEntity.Companion.FOLLOW_UPDATE_TYPE_LIBAO
import com.gh.gamecenter.entity.FollowDynamicEntity.Companion.FOLLOW_UPDATE_TYPE_LIBAO_EXCHANGE
import com.gh.gamecenter.entity.FollowDynamicEntity.Companion.FOLLOW_UPDATE_TYPE_USER_POST

View File

@ -2,12 +2,17 @@ package com.gh.gamecenter.forum.home.follow.viewholder
import android.content.Context
import android.graphics.Color
import android.net.Uri
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.gamecenter.R
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.databinding.CommunityAnswerItemBinding
import com.gh.gamecenter.entity.ImageArticleEntity
import com.gh.gamecenter.feature.entity.ArticleEntity
import com.gh.gamecenter.forum.home.ForumArticleAskItemViewHolder
import com.gh.gamecenter.forum.search.CommunitySearchEventListener
@ -29,13 +34,13 @@ class FollowPostCardViewHolder(
fun bind(data: ArticleEntity, position: Int) {
val articleEntity = data
viewHolder.binding.run {
root.layoutParams = (root.layoutParams as ViewGroup.MarginLayoutParams).apply {
topMargin = if (position == 0) 8F.dip2px() else 0
}
if (position == 0) {
root.background = com.gh.gamecenter.common.R.drawable.background_shape_white_radius_12_top_only.toDrawable(context)
root.background =
com.gh.gamecenter.common.R.drawable.background_shape_white_radius_12_top_only.toDrawable(context)
} else {
root.setBackgroundColor(com.gh.gamecenter.common.R.color.ui_surface.toColor(context))
}
@ -118,6 +123,15 @@ class FollowPostCardViewHolder(
)
)
}
ImageArticleEntity.IMAGE_ARTICLE_TYPE -> {
val imageArticleUri = Uri.Builder()
.path(RouteConsts.activity.imageArticleDetailActivity)
.appendQueryParameter(EntranceConsts.KEY_IMAGE_ARTICLE_ID, articleEntity.id)
.appendQueryParameter(EntranceConsts.KEY_SOURCE_ENTRANCE, "社区-关注")
.build()
ARouter.getInstance().build(imageArticleUri).navigation()
}
}
}
}

View File

@ -8,6 +8,7 @@ import androidx.lifecycle.MutableLiveData
import com.gh.common.util.CheckLoginUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.common.baselist.LoadStatus
import com.gh.gamecenter.common.entity.CommunityEntity
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.common.retrofit.JSONObjectResponse
@ -16,6 +17,8 @@ import com.gh.gamecenter.common.utils.SensorsBridge
import com.gh.gamecenter.common.utils.observableToMain
import com.gh.gamecenter.common.utils.singleToMain
import com.gh.gamecenter.entity.FollowUserEntity
import com.gh.gamecenter.entity.ImageArticleEntity
import com.gh.gamecenter.eventbus.EBImageArticleChanged
import com.gh.gamecenter.eventbus.EBUserFollow
import com.gh.gamecenter.feature.entity.*
import com.gh.gamecenter.feature.exposure.ExposureEvent
@ -312,5 +315,71 @@ class FollowHomeViewModel(application: Application) : AndroidViewModel(applicati
compositeDisposable.clear()
}
fun voteChanged(changed: EBImageArticleChanged.VoteChanged) {
notifyImageArticleItemChanged(changed.id) {
FollowPostCardItem(
data = it.copy(
_me = it.me.copy(isCommunityArticleVote = changed.isVoted),
_count = it.count.copy(vote = changed.count)
),
)
}
}
fun commentChanged(changed: EBImageArticleChanged.CommentChanged) {
notifyImageArticleItemChanged(changed.id) {
FollowPostCardItem(
data = it.copy(
_count = it.count.copy(comment = changed.count)
)
)
}
}
fun itemChanged(changed: EBImageArticleChanged.DataChanged) {
val imageArticle = changed.data
notifyImageArticleItemChanged(imageArticle.id) { _ ->
val newArticle = ArticleEntity(
_id = imageArticle.id,
_title = imageArticle.title,
content = imageArticle.content,
_count = imageArticle.count,
time = imageArticle.time,
_images = imageArticle.images,
imagesInfo = imageArticle.imagesInfos,
_user = imageArticle.user,
_community = imageArticle.community?.toCommunityEntity() ?: CommunityEntity()
)
FollowPostCardItem(newArticle)
}
}
private fun notifyImageArticleItemChanged(
imageArticleId: String,
block: (ArticleEntity) -> FollowPostCardItem
) {
val oldData = dataList.value ?: return
val newData = oldData.toMutableList()
val position = newData.indexOfFirst {
it is FollowPostCardItem && it.data.type == ImageArticleEntity.IMAGE_ARTICLE_TYPE && it.data.id == imageArticleId
}
if (position != -1) {
val oldImageArticle = (newData[position] as FollowPostCardItem).data
val newItem = block(oldImageArticle)
newData[position] = newItem
_dataList.value = newData
}
}
fun itemDeleted(changed: EBImageArticleChanged.DataDeleted) {
val oldData = dataList.value ?: return
val newData = oldData.toMutableList()
val position = newData.indexOfFirst {
it is FollowPostCardItem && it.data.type == ImageArticleEntity.IMAGE_ARTICLE_TYPE && it.data.id == changed.imageArticleId
}
if (position != -1) {
newData.removeAt(position)
_dataList.value = newData
}
}
}

View File

@ -789,12 +789,12 @@ class ImageArticleDetailFragment : BaseFragment<Unit>() {
val imageArticle = viewModel.imageArticleDetailEntity.value ?: return
var highlightDialogHintContent = ""
val permissions = imageArticle.me.moderatorPermissions
if ((isHighlight && permissions.highlightCommunityArticle > Permissions.GUEST) ||
(!isHighlight && permissions.cancelHighlightCommunityArticle > Permissions.GUEST)
if ((isHighlight && permissions.choicenessImageArticle > Permissions.GUEST) ||
(!isHighlight && permissions.cancelChoicenessImageArticle > Permissions.GUEST)
) {
highlightDialogHintContent =
if ((isHighlight && permissions.highlightCommunityArticle == Permissions.REPORTER) ||
(!isHighlight && permissions.cancelHighlightCommunityArticle == Permissions.REPORTER)
if ((isHighlight && permissions.choicenessImageArticle == Permissions.REPORTER) ||
(!isHighlight && permissions.cancelChoicenessImageArticle == Permissions.REPORTER)
) {
"你的操作将提交给小编审核,确定提交吗?"
} else {

View File

@ -42,7 +42,7 @@ class PersonalItemViewHolder(
position: Int,
payloads: List<Any?>? = null
) {
if(!payloads.isNullOrEmpty()){
if (!payloads.isNullOrEmpty()) {
// 局部更新
commentCount.isClickable = true
bindCommendAndVote(historyEntity, entrance)
@ -51,25 +51,27 @@ class PersonalItemViewHolder(
commentCount.isClickable = true
bindCommendAndVote(historyEntity, entrance)
if (historyEntity.community.type == "official_bbs") {
forumIcon?.displayGameIcon(historyEntity.community.icon, null)
} else {
forumIcon?.displayGameIcon(
historyEntity.community.game?.getIcon(),
historyEntity.community.game?.iconSubscript,
historyEntity.community.game?.iconFloat
)
}
forumNameContainer?.setOnClickListener {
MtaHelper.onEvent(getEventId(entrance), getKey(entrance), historyEntity.community.name)
itemView.context.startActivity(
ForumDetailActivity.getIntent(
itemView.context,
historyEntity.community.id,
entrance
forumNameContainer?.visibleIf(historyEntity.community.id.isNotBlank()) {
if (historyEntity.community.type == "official_bbs") {
forumIcon?.displayGameIcon(historyEntity.community.icon, null)
} else {
forumIcon?.displayGameIcon(
historyEntity.community.game?.getIcon(),
historyEntity.community.game?.iconSubscript,
historyEntity.community.game?.iconFloat
)
)
}
forumNameContainer?.setOnClickListener {
MtaHelper.onEvent(getEventId(entrance), getKey(entrance), historyEntity.community.name)
itemView.context.startActivity(
ForumDetailActivity.getIntent(
itemView.context,
historyEntity.community.id,
entrance
)
)
}
}
val answer = AnswerEntity()

View File

@ -156,6 +156,7 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH
open fun bindCommendAndVote(entity: CommunityItemData, entrance: String, position: Int? = null) {
binNormalView(entity)
forumNameContainer?.visibleIf(entity.community.id.isNotBlank())
if (entity.community.type == "official_bbs") {
forumIcon?.displayGameIcon(entity.community.icon, null)
} else {