From 270fe32d946bdba0236b78e422823e079ea71385 Mon Sep 17 00:00:00 2001 From: klaus Date: Mon, 22 Jun 2026 17:45:20 +0900 Subject: [PATCH] =?UTF-8?q?feat(creator):=20FanTalk=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=20=EC=95=84=EC=9D=B4=ED=85=9C=EC=9D=84=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/CreatorChannelFanTalkAdapter.kt | 95 ++++++++++ .../bg_creator_channel_fantalk_reply.xml | 5 + .../layout/item_creator_channel_fantalk.xml | 175 ++++++++++++++++++ 3 files changed, 275 insertions(+) create mode 100644 app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/fantalk/ui/CreatorChannelFanTalkAdapter.kt create mode 100644 app/src/main/res/drawable/bg_creator_channel_fantalk_reply.xml create mode 100644 app/src/main/res/layout/item_creator_channel_fantalk.xml diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/fantalk/ui/CreatorChannelFanTalkAdapter.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/fantalk/ui/CreatorChannelFanTalkAdapter.kt new file mode 100644 index 00000000..4aa3fae4 --- /dev/null +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/fantalk/ui/CreatorChannelFanTalkAdapter.kt @@ -0,0 +1,95 @@ +package kr.co.vividnext.sodalive.v2.creator.channel.fantalk.ui + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.core.view.isVisible +import androidx.recyclerview.widget.RecyclerView +import coil.transform.CircleCropTransformation +import kr.co.vividnext.sodalive.R +import kr.co.vividnext.sodalive.databinding.ItemCreatorChannelFantalkBinding +import kr.co.vividnext.sodalive.extensions.loadUrl +import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkReplyUiModel +import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkRightAction +import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkUiModel + +class CreatorChannelFanTalkAdapter( + private val onOwnerMoreClick: (View, CreatorChannelFanTalkUiModel) -> Unit = { _, _ -> }, + private val onReportClick: (CreatorChannelFanTalkUiModel) -> Unit = { } +) : RecyclerView.Adapter() { + + private var items: List = emptyList() + + fun submitItems(items: List) { + this.items = items + notifyDataSetChanged() + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + return ViewHolder( + ItemCreatorChannelFantalkBinding.inflate(LayoutInflater.from(parent.context), parent, false), + onOwnerMoreClick, + onReportClick + ) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + holder.bind(items[position]) + } + + override fun getItemCount(): Int = items.size + + class ViewHolder( + private val binding: ItemCreatorChannelFantalkBinding, + private val onOwnerMoreClick: (View, CreatorChannelFanTalkUiModel) -> Unit, + private val onReportClick: (CreatorChannelFanTalkUiModel) -> Unit + ) : RecyclerView.ViewHolder(binding.root) { + + fun bind(item: CreatorChannelFanTalkUiModel) = with(binding) { + ivCreatorChannelFantalkProfile.loadProfile(item.writerProfileImageUrl) + tvCreatorChannelFantalkNickname.text = item.writerNickname + tvCreatorChannelFantalkTime.text = item.createdAtText + tvCreatorChannelFantalkContent.text = item.content + bindRightAction(item) + bindReply(item.reply) + } + + private fun ItemCreatorChannelFantalkBinding.bindRightAction(item: CreatorChannelFanTalkUiModel) { + when (item.rightAction) { + CreatorChannelFanTalkRightAction.Report -> { + tvCreatorChannelFantalkReport.isVisible = true + tvCreatorChannelFantalkReport.setOnClickListener { onReportClick(item) } + ivCreatorChannelFantalkMore.isVisible = false + ivCreatorChannelFantalkMore.setOnClickListener(null) + } + is CreatorChannelFanTalkRightAction.OwnerMore -> { + tvCreatorChannelFantalkReport.isVisible = false + tvCreatorChannelFantalkReport.setOnClickListener(null) + ivCreatorChannelFantalkMore.isVisible = true + ivCreatorChannelFantalkMore.setOnClickListener { onOwnerMoreClick(it, item) } + } + } + } + + private fun ItemCreatorChannelFantalkBinding.bindReply(reply: CreatorChannelFanTalkReplyUiModel?) { + val hasReply = reply != null + viewCreatorChannelFantalkReplyConnector.isVisible = hasReply + layoutCreatorChannelFantalkReply.isVisible = hasReply + if (reply == null) return + + ivCreatorChannelFantalkReplyProfile.loadProfile(reply.writerProfileImageUrl) + tvCreatorChannelFantalkReplyNickname.text = reply.writerNickname + tvCreatorChannelFantalkReplyTime.text = reply.createdAtText + tvCreatorChannelFantalkReplyContent.text = reply.content + } + + private fun android.widget.ImageView.loadProfile(url: String) { + loadUrl(url) { + crossfade(true) + placeholder(R.drawable.ic_placeholder_profile) + error(R.drawable.ic_placeholder_profile) + transformations(CircleCropTransformation()) + } + } + } +} diff --git a/app/src/main/res/drawable/bg_creator_channel_fantalk_reply.xml b/app/src/main/res/drawable/bg_creator_channel_fantalk_reply.xml new file mode 100644 index 00000000..c410cc4e --- /dev/null +++ b/app/src/main/res/drawable/bg_creator_channel_fantalk_reply.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/layout/item_creator_channel_fantalk.xml b/app/src/main/res/layout/item_creator_channel_fantalk.xml new file mode 100644 index 00000000..ddab3bb1 --- /dev/null +++ b/app/src/main/res/layout/item_creator_channel_fantalk.xml @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +