Skip to content

Commit

Permalink
[Fix]: 修复用户收藏显示错误
Browse files Browse the repository at this point in the history
  • Loading branch information
why committed Dec 12, 2023
1 parent a003847 commit a98e8e8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.xiaoyv.bangumi.ui.discover.group.detail

import androidx.core.view.isVisible
import com.xiaoyv.bangumi.databinding.ActivityGroupDetailItemBinding
import com.xiaoyv.common.config.bean.SampleAvatar
import com.xiaoyv.common.helper.callback.IdDiffItemCallback
Expand All @@ -16,6 +17,8 @@ class GroupDetailAdapter : BaseQuickDiffBindingAdapter<SampleAvatar,
override fun BaseQuickBindingHolder<ActivityGroupDetailItemBinding>.converted(item: SampleAvatar) {
binding.ivAvatar.loadImageAnimate(item.image)
binding.tvTip.text = item.title

binding.tvCount.isVisible = item.desc.isNotBlank()
binding.tvCount.text = buildString {
append("成员:")
append(item.desc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class ProfileAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) :
val type = profileTab.type
return when (type) {
ProfileType.TYPE_COLLECTION -> SaveListFragment.newInstance(
userId = UserHelper.currentUser.id.orEmpty()
userId = UserHelper.currentUser.id.orEmpty(),
isMine = true
)

ProfileType.TYPE_TIMELINE -> TimelinePageFragment.newInstance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class SaveListFragment : BaseViewModelFragment<FragmentSaveListBinding, SaveList

override fun initArgumentsData(arguments: Bundle) {
viewModel.userId = arguments.getString(NavKey.KEY_STRING).orEmpty()
viewModel.isMine = arguments.getBoolean(NavKey.KEY_BOOLEAN, false)
}

override fun initView() {
Expand Down Expand Up @@ -124,20 +125,25 @@ class SaveListFragment : BaseViewModelFragment<FragmentSaveListBinding, SaveList
}
}

UserHelper.observe(this) {
if (it.isEmpty) {
viewModel.clearList()
} else {
viewModel.userId = it.id.orEmpty()
viewModel.refresh()
if (viewModel.isMine) {
UserHelper.observe(this) {
if (it.isEmpty) {
viewModel.clearList()
} else {
viewModel.userId = it.id.orEmpty()
viewModel.refresh()
}
}
}
}

companion object {
fun newInstance(userId: String): SaveListFragment {
fun newInstance(userId: String, isMine: Boolean = false): SaveListFragment {
return SaveListFragment().apply {
arguments = bundleOf(NavKey.KEY_STRING to userId)
arguments = bundleOf(
NavKey.KEY_STRING to userId,
NavKey.KEY_BOOLEAN to isMine
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SaveListViewModel : BaseViewModel() {

internal var listType = InterestCollectType.TYPE_WISH
internal var userId = ""
internal var isMine = false

/**
* 搜索条件
Expand Down

0 comments on commit a98e8e8

Please sign in to comment.