인기 크리에이터 팔로우 해제 시 확인 다이얼로그 추가

This commit is contained in:
2026-01-22 19:04:36 +09:00
parent f269044c69
commit 11c5d57c4e
5 changed files with 30 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ import kr.co.vividnext.sodalive.explorer.GetExplorerSectionCreatorResponse
class CreatorRankingAdapter(
private val onClickItem: (Long) -> Unit,
private val onClickFollow: (Long, Boolean) -> Unit
private val onClickFollow: (Int, Long, String, Boolean) -> Unit
) : RecyclerView.Adapter<CreatorRankingAdapter.ViewHolder>() {
private val items = mutableListOf<GetExplorerSectionCreatorResponse>()
@@ -78,7 +78,7 @@ class CreatorRankingAdapter(
item.follow = !item.follow
notifyItemChanged(index)
}
onClickFollow(item.id, item.follow)
onClickFollow(index, item.id, item.nickname, item.follow)
}
} else {
binding.tvFollow.visibility = View.GONE
@@ -103,6 +103,13 @@ class CreatorRankingAdapter(
override fun getItemCount() = items.size
fun revertFollowState(position: Int) {
if (position in items.indices) {
items[position].follow = !items[position].follow
notifyItemChanged(position)
}
}
@SuppressLint("NotifyDataSetChanged")
fun addItems(items: List<GetExplorerSectionCreatorResponse>) {
this.items.addAll(items)

View File

@@ -284,12 +284,25 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::infl
(requireActivity() as MainActivity).showLoginActivity()
}
},
onClickFollow = { creatorId, follow ->
onClickFollow = { position, creatorId, nickname, follow ->
if (SharedPreferenceManager.token.isNotBlank()) {
if (follow) {
viewModel.follow(creatorId, follow = true, notify = true)
} else {
viewModel.follow(creatorId, follow = false, notify = false)
SodaDialog(
activity = requireActivity(),
layoutInflater = layoutInflater,
title = getString(R.string.dialog_unfollow_title),
desc = getString(R.string.dialog_unfollow_message, nickname),
confirmButtonTitle = getString(R.string.confirm),
confirmButtonClick = {
viewModel.follow(creatorId, follow = false, notify = false)
},
cancelButtonTitle = getString(R.string.cancel),
cancelButtonClick = {
creatorRankingAdapter.revertFollowState(position)
}
).show(binding.root.width)
}
} else {
(requireActivity() as MainActivity).showLoginActivity()