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

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

View File

@@ -284,12 +284,25 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::infl
(requireActivity() as MainActivity).showLoginActivity() (requireActivity() as MainActivity).showLoginActivity()
} }
}, },
onClickFollow = { creatorId, follow -> onClickFollow = { position, creatorId, nickname, follow ->
if (SharedPreferenceManager.token.isNotBlank()) { if (SharedPreferenceManager.token.isNotBlank()) {
if (follow) { if (follow) {
viewModel.follow(creatorId, follow = true, notify = true) viewModel.follow(creatorId, follow = true, notify = true)
} else { } else {
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) viewModel.follow(creatorId, follow = false, notify = false)
},
cancelButtonTitle = getString(R.string.cancel),
cancelButtonClick = {
creatorRankingAdapter.revertFollowState(position)
}
).show(binding.root.width)
} }
} else { } else {
(requireActivity() as MainActivity).showLoginActivity() (requireActivity() as MainActivity).showLoginActivity()

View File

@@ -168,6 +168,8 @@
<string name="day_random">Irregular</string> <string name="day_random">Irregular</string>
<string name="screen_home_follow">Follow</string> <string name="screen_home_follow">Follow</string>
<string name="screen_home_following">Following</string> <string name="screen_home_following">Following</string>
<string name="dialog_unfollow_title">Unfollow</string>
<string name="dialog_unfollow_message">Are you sure you want to unfollow %1$s?</string>
<string name="screen_home_theme_all">All</string> <string name="screen_home_theme_all">All</string>
<string name="screen_home_sort_revenue">Revenue</string> <string name="screen_home_sort_revenue">Revenue</string>
<string name="screen_home_sort_sales_count">Units</string> <string name="screen_home_sort_sales_count">Units</string>

View File

@@ -168,6 +168,8 @@
<string name="day_random">ランダム</string> <string name="day_random">ランダム</string>
<string name="screen_home_follow">フォロー</string> <string name="screen_home_follow">フォロー</string>
<string name="screen_home_following">フォロー中</string> <string name="screen_home_following">フォロー中</string>
<string name="dialog_unfollow_title">フォロー解除</string>
<string name="dialog_unfollow_message">%1$sさんのフォロー를解除しますか</string>
<string name="screen_home_theme_all"></string> <string name="screen_home_theme_all"></string>
<string name="screen_home_sort_revenue">売上</string> <string name="screen_home_sort_revenue">売上</string>
<string name="screen_home_sort_sales_count">販売数</string> <string name="screen_home_sort_sales_count">販売数</string>

View File

@@ -167,6 +167,8 @@
<string name="day_random">랜덤</string> <string name="day_random">랜덤</string>
<string name="screen_home_follow">팔로우</string> <string name="screen_home_follow">팔로우</string>
<string name="screen_home_following">팔로잉</string> <string name="screen_home_following">팔로잉</string>
<string name="dialog_unfollow_title">팔로우 해제</string>
<string name="dialog_unfollow_message">%1$s님을 팔로우 해제 하시겠습니까?</string>
<string name="screen_home_theme_all">전체</string> <string name="screen_home_theme_all">전체</string>
<string name="screen_home_sort_revenue">매출</string> <string name="screen_home_sort_revenue">매출</string>
<string name="screen_home_sort_sales_count">판매량</string> <string name="screen_home_sort_sales_count">판매량</string>