fix: 修复首页发现页Item提交不喜欢错位问题

This commit is contained in:
liuyirong
2023-01-13 16:42:30 +08:00
parent 4dfed562d4
commit cec418d484
2 changed files with 7 additions and 4 deletions

View File

@ -155,6 +155,7 @@ class HomeFragment : LazyFragment() {
MtaHelper.onEvent("首页_新", "刷新")
mViewModel.loadStatus.postValue(LoadStatus.LIST_LOADING)
mHomeSearchViewModel.getHomeContentUnion(true)
mViewModel.refreshDiscoverCardData()
}
mBinding.reuseNoConnection.root.setOnClickListener {

View File

@ -77,7 +77,7 @@ class DiscoverCardGameAdapter(
)
}
holder.itemView.setOnLongClickListener {
showDislikeWindow(holder.itemView, position, gameEntity)
showDislikeWindow(holder.itemView, gameEntity)
true
}
DownloadItemUtils.setOnClickListener(
@ -93,7 +93,7 @@ class DiscoverCardGameAdapter(
}
@SuppressLint("CheckResult")
private fun showDislikeWindow(view: View, position: Int, gameEntity: GameEntity) {
private fun showDislikeWindow(view: View, gameEntity: GameEntity) {
val decorView = (mContext as Activity).window.decorView as? FrameLayout
val binding = LayoutPopupDiscoveryDislikeBinding.inflate(LayoutInflater.from(mContext), decorView, true)
binding.reasonFlex.removeAllViews()
@ -103,10 +103,12 @@ class DiscoverCardGameAdapter(
FlexboxLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
binding.reasonFlex.addView(popupItem, params)
popupItem.setOnClickListener {
val index = mList.indexOf(gameEntity)
if (index < 0) return@setOnClickListener
discoveryFeedback(gameEntity.id, popupItem.text.toString(), gameEntity.type ?: "") {
SPUtils.setBoolean(Constants.SP_DISCOVER_FORCE_REFRESH, true)
mList.removeAt(position)
notifyItemRemoved(position)
mList.removeAt(index)
notifyItemRemoved(index)
decorView?.removeView(binding.root)
ToastUtils.showToast("已根据你的偏好优化推荐机制~", Gravity.CENTER)
}