From 3a421d2a600ad10af18c066889d0f496de10d830 Mon Sep 17 00:00:00 2001 From: klaus Date: Fri, 19 Jun 2026 21:03:47 +0900 Subject: [PATCH] =?UTF-8?q?refactor(creator):=20=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B8=8C=20replay=20adapter=EB=A5=BC=20=EA=B3=B5=ED=86=B5?= =?UTF-8?q?=ED=99=94=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../live/CreatorChannelLiveFragment.kt | 4 +-- .../live/model/CreatorChannelLiveMappers.kt | 16 +++++---- .../live/model/CreatorChannelLiveUiModels.kt | 21 ------------ .../CreatorChannelAudioContentAdapter.kt} | 34 +++++++++---------- .../CreatorChannelLiveFragmentLayoutTest.kt | 25 +++++++------- .../live/CreatorChannelLiveMapperTest.kt | 6 ++-- 6 files changed, 44 insertions(+), 62 deletions(-) delete mode 100644 app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/model/CreatorChannelLiveUiModels.kt rename app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/{live/ui/CreatorChannelLiveReplayAdapter.kt => ui/CreatorChannelAudioContentAdapter.kt} (75%) diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveFragment.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveFragment.kt index 51d00807..5dfe53d5 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveFragment.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveFragment.kt @@ -13,7 +13,7 @@ import kr.co.vividnext.sodalive.extensions.dpToPx import kr.co.vividnext.sodalive.extensions.moneyFormat import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelLiveResponse import kr.co.vividnext.sodalive.v2.creator.channel.live.model.toReplayUiModel -import kr.co.vividnext.sodalive.v2.creator.channel.live.ui.CreatorChannelLiveReplayAdapter +import kr.co.vividnext.sodalive.v2.creator.channel.ui.CreatorChannelAudioContentAdapter import kr.co.vividnext.sodalive.v2.creator.channel.model.toLabelResId import kr.co.vividnext.sodalive.v2.creator.channel.ui.formatCreatorChannelLiveDateTime import kr.co.vividnext.sodalive.v2.creator.channel.ui.CreatorChannelSortPopup @@ -24,7 +24,7 @@ class CreatorChannelLiveFragment : BaseFragment + private val replayAdapter = CreatorChannelAudioContentAdapter { item -> host.onCreatorChannelLiveReplayClicked(item.audioContentId) } private var lastContentLayoutKey: CreatorChannelLiveContentLayoutKey? = null diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/model/CreatorChannelLiveMappers.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/model/CreatorChannelLiveMappers.kt index a2e2ad46..5d96c28e 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/model/CreatorChannelLiveMappers.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/model/CreatorChannelLiveMappers.kt @@ -1,10 +1,12 @@ package kr.co.vividnext.sodalive.v2.creator.channel.live.model import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelAudioContentResponse +import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelAudioContentStatus +import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelAudioContentUiModel import kr.co.vividnext.sodalive.v2.widget.AudioContentTag -fun CreatorChannelAudioContentResponse.toReplayUiModel(): CreatorChannelLiveReplayUiModel = - CreatorChannelLiveReplayUiModel( +fun CreatorChannelAudioContentResponse.toReplayUiModel(): CreatorChannelAudioContentUiModel = + CreatorChannelAudioContentUiModel( audioContentId = audioContentId, title = title, secondaryText = duration, @@ -22,9 +24,9 @@ private fun CreatorChannelAudioContentResponse.toAudioContentTags(): Set CreatorChannelLiveReplayStatus.Owned - isRented -> CreatorChannelLiveReplayStatus.Rented - price == 0 -> CreatorChannelLiveReplayStatus.Play - else -> CreatorChannelLiveReplayStatus.Price(price) +private fun CreatorChannelAudioContentResponse.toReplayStatus(): CreatorChannelAudioContentStatus = when { + isOwned -> CreatorChannelAudioContentStatus.Owned + isRented -> CreatorChannelAudioContentStatus.Rented + price == 0 -> CreatorChannelAudioContentStatus.Play + else -> CreatorChannelAudioContentStatus.Price(price) } diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/model/CreatorChannelLiveUiModels.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/model/CreatorChannelLiveUiModels.kt deleted file mode 100644 index d61faf02..00000000 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/model/CreatorChannelLiveUiModels.kt +++ /dev/null @@ -1,21 +0,0 @@ -package kr.co.vividnext.sodalive.v2.creator.channel.live.model - -import kr.co.vividnext.sodalive.v2.widget.AudioContentTag - -data class CreatorChannelLiveReplayUiModel( - val audioContentId: Long, - val title: String, - val secondaryText: String?, - val imageUrl: String?, - val price: Int, - val showAdultBadge: Boolean, - val tags: Set, - val status: CreatorChannelLiveReplayStatus -) - -sealed interface CreatorChannelLiveReplayStatus { - data object Play : CreatorChannelLiveReplayStatus - data object Owned : CreatorChannelLiveReplayStatus - data object Rented : CreatorChannelLiveReplayStatus - data class Price(val price: Int) : CreatorChannelLiveReplayStatus -} diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/ui/CreatorChannelLiveReplayAdapter.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/ui/CreatorChannelAudioContentAdapter.kt similarity index 75% rename from app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/ui/CreatorChannelLiveReplayAdapter.kt rename to app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/ui/CreatorChannelAudioContentAdapter.kt index a4f2bf27..f4a7503e 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/ui/CreatorChannelLiveReplayAdapter.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/ui/CreatorChannelAudioContentAdapter.kt @@ -1,4 +1,4 @@ -package kr.co.vividnext.sodalive.v2.creator.channel.live.ui +package kr.co.vividnext.sodalive.v2.creator.channel.ui import android.graphics.Outline import android.view.LayoutInflater @@ -11,17 +11,17 @@ import kr.co.vividnext.sodalive.R import kr.co.vividnext.sodalive.databinding.ItemCreatorChannelAudioContentBinding import kr.co.vividnext.sodalive.extensions.loadUrl import kr.co.vividnext.sodalive.extensions.moneyFormat -import kr.co.vividnext.sodalive.v2.creator.channel.live.model.CreatorChannelLiveReplayStatus -import kr.co.vividnext.sodalive.v2.creator.channel.live.model.CreatorChannelLiveReplayUiModel +import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelAudioContentStatus +import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelAudioContentUiModel import kr.co.vividnext.sodalive.v2.widget.AudioContentTag -class CreatorChannelLiveReplayAdapter( - private val onReplayClick: (CreatorChannelLiveReplayUiModel) -> Unit = {} -) : RecyclerView.Adapter() { +class CreatorChannelAudioContentAdapter( + private val onAudioContentClick: (CreatorChannelAudioContentUiModel) -> Unit = {} +) : RecyclerView.Adapter() { - private var items: List = emptyList() + private var items: List = emptyList() - fun submitItems(items: List) { + fun submitItems(items: List) { this.items = items notifyDataSetChanged() } @@ -29,7 +29,7 @@ class CreatorChannelLiveReplayAdapter( override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { return ViewHolder( ItemCreatorChannelAudioContentBinding.inflate(LayoutInflater.from(parent.context), parent, false), - onReplayClick + onAudioContentClick ) } @@ -41,7 +41,7 @@ class CreatorChannelLiveReplayAdapter( class ViewHolder( private val binding: ItemCreatorChannelAudioContentBinding, - private val onReplayClick: (CreatorChannelLiveReplayUiModel) -> Unit + private val onAudioContentClick: (CreatorChannelAudioContentUiModel) -> Unit ) : RecyclerView.ViewHolder(binding.root) { init { @@ -59,7 +59,7 @@ class CreatorChannelLiveReplayAdapter( } } - fun bind(item: CreatorChannelLiveReplayUiModel) = with(binding) { + fun bind(item: CreatorChannelAudioContentUiModel) = with(binding) { ivCreatorChannelAudioContentThumbnail.loadUrl(item.imageUrl) tvCreatorChannelAudioContentTitle.text = item.title tvCreatorChannelAudioContentSecondaryText.text = item.secondaryText.orEmpty() @@ -71,24 +71,24 @@ class CreatorChannelLiveReplayAdapter( bindTag(ivCreatorChannelAudioContentPointTag, AudioContentTag.Point, item.tags) tvCreatorChannelAudioContentFreeTag.isVisible = AudioContentTag.Free in item.tags bindStatus(item.status) - root.setOnClickListener { onReplayClick(item) } + root.setOnClickListener { onAudioContentClick(item) } } private fun bindTag(view: View, tag: AudioContentTag, tags: Set) { view.isVisible = tag in tags } - private fun bindStatus(status: CreatorChannelLiveReplayStatus) = with(binding) { + private fun bindStatus(status: CreatorChannelAudioContentStatus) = with(binding) { ivCreatorChannelAudioContentPlay.setImageResource(R.drawable.ic_new_player_play) when (status) { - CreatorChannelLiveReplayStatus.Play -> { + CreatorChannelAudioContentStatus.Play -> { ivCreatorChannelAudioContentPlay.isVisible = true ivCreatorChannelAudioContentCan.isVisible = false layoutCreatorChannelAudioContentActionText.isVisible = false } - CreatorChannelLiveReplayStatus.Owned -> bindTextStatus(R.string.audio_content_badge_owned) - CreatorChannelLiveReplayStatus.Rented -> bindTextStatus(R.string.audio_content_badge_rented) - is CreatorChannelLiveReplayStatus.Price -> { + CreatorChannelAudioContentStatus.Owned -> bindTextStatus(R.string.audio_content_badge_owned) + CreatorChannelAudioContentStatus.Rented -> bindTextStatus(R.string.audio_content_badge_rented) + is CreatorChannelAudioContentStatus.Price -> { ivCreatorChannelAudioContentPlay.isVisible = false layoutCreatorChannelAudioContentActionText.isVisible = true ivCreatorChannelAudioContentCan.isVisible = true diff --git a/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveFragmentLayoutTest.kt b/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveFragmentLayoutTest.kt index 467b1422..b0f8ceca 100644 --- a/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveFragmentLayoutTest.kt +++ b/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveFragmentLayoutTest.kt @@ -119,7 +119,7 @@ class CreatorChannelLiveFragmentLayoutTest { val item = inflateView(R.layout.item_creator_channel_audio_content) val itemLayout = projectFile("app/src/main/res/layout/item_creator_channel_audio_content.xml").readText() val adapter = projectFile( - "app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/ui/CreatorChannelLiveReplayAdapter.kt" + "app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/ui/CreatorChannelAudioContentAdapter.kt" ).readText() val thumbnail = requireNotNull(item.findViewById(R.id.layout_creator_channel_audio_content_thumbnail)) @@ -195,7 +195,7 @@ class CreatorChannelLiveFragmentLayoutTest { "app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveFragment.kt" ).readText() val adapter = projectFile( - "app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/ui/CreatorChannelLiveReplayAdapter.kt" + "app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/ui/CreatorChannelAudioContentAdapter.kt" ).readText() val layout = projectFile("app/src/main/res/layout/fragment_creator_channel_live.xml").readText() val eagerLoadOnViewCreated = """ @@ -250,22 +250,23 @@ class CreatorChannelLiveFragmentLayoutTest { ).readText() val fragmentLayout = projectFile("app/src/main/res/layout/fragment_creator_channel_live.xml").readText() - assertTrue(activityLayout.contains("android:id=\"@+id/layout_creator_channel_live_owner_cta\"")) + assertTrue(activityLayout.contains("android:id=\"@+id/layout_creator_channel_owner_cta\"")) assertTrue(activityLayout.contains("android:layout_height=\"100dp\"")) assertTrue(activityLayout.contains("android:background=\"@color/black\"")) - assertTrue(activityLayout.contains("android:id=\"@+id/btn_creator_channel_live_owner_cta\"")) + assertTrue(activityLayout.contains("android:id=\"@+id/btn_creator_channel_owner_cta\"")) assertTrue(activityLayout.contains("android:layout_marginHorizontal=\"@dimen/spacing_14\"")) assertTrue(activityLayout.contains("android:layout_marginTop=\"@dimen/spacing_14\"")) assertTrue(activityLayout.contains("@drawable/bg_creator_channel_owner_fab")) assertTrue(activityLayout.contains("@drawable/ic_new_create_live")) assertTrue(activityLayout.contains("@string/creator_channel_live_start_button")) - assertTrue(activity.contains("setupLiveOwnerCtaInsets()")) - assertTrue(activity.contains("updateLiveOwnerCtaVisibility()")) - assertTrue(activity.contains("binding.viewPager.currentItem == CreatorChannelTab.Live.ordinal")) - assertTrue(activity.contains("binding.layoutCreatorChannelLiveOwnerCta.isVisible = shouldShowLiveOwnerCta")) + assertTrue(activity.contains("setupOwnerCtaInsets()")) + assertTrue(activity.contains("updateOwnerCtaVisibility()")) + assertTrue(activity.contains("CreatorChannelTab.Live.ordinal -> CreatorChannelTab.Live")) + assertTrue(activity.contains("CreatorChannelTab.Audio.ordinal -> CreatorChannelTab.Audio")) + assertTrue(activity.contains("binding.layoutCreatorChannelOwnerCta.isVisible = shouldShowOwnerCta")) assertTrue( activity.contains( - "findLiveFragment()?.onCreatorChannelLiveOwnerCtaVisibilityChanged(shouldShowLiveOwnerCta)" + "findLiveFragment()?.onCreatorChannelLiveOwnerCtaVisibilityChanged(ownerCtaTab == CreatorChannelTab.Live)" ) ) assertTrue(fragment.contains("fun onCreatorChannelLiveOwnerCtaVisibilityChanged(isVisible: Boolean)")) @@ -273,10 +274,10 @@ class CreatorChannelLiveFragmentLayoutTest { assertTrue(fragment.contains("LIVE_OWNER_CTA_LIST_BOTTOM_PADDING_DP.dpToPx().toInt()")) assertTrue(fragment.contains("DEFAULT_LIST_BOTTOM_PADDING_DP.dpToPx().toInt()")) assertTrue(fragment.contains("rvCreatorChannelLiveReplays.updatePadding(bottom = bottomPadding)")) - assertTrue(activity.contains("binding.btnCreatorChannelLiveOwnerCta.setOnClickListener")) + assertTrue(activity.contains("binding.btnCreatorChannelOwnerCta.setOnClickListener")) assertTrue(activity.contains("onOwnerFabLiveClicked()")) - assertFalse(fragmentLayout.contains("android:id=\"@+id/layout_creator_channel_live_owner_cta\"")) - assertFalse(fragment.contains("layoutCreatorChannelLiveOwnerCta")) + assertFalse(fragmentLayout.contains("android:id=\"@+id/layout_creator_channel_owner_cta\"")) + assertFalse(fragment.contains("layoutCreatorChannelOwnerCta")) } @Test diff --git a/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveMapperTest.kt b/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveMapperTest.kt index 2c6289a1..b1447aab 100644 --- a/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveMapperTest.kt +++ b/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveMapperTest.kt @@ -3,7 +3,7 @@ package kr.co.vividnext.sodalive.v2.creator.channel.live import kr.co.vividnext.sodalive.R import kr.co.vividnext.sodalive.v2.common.data.ContentSort import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelAudioContentResponse -import kr.co.vividnext.sodalive.v2.creator.channel.live.model.CreatorChannelLiveReplayStatus +import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelAudioContentStatus import kr.co.vividnext.sodalive.v2.creator.channel.live.model.toReplayUiModel import kr.co.vividnext.sodalive.v2.creator.channel.model.toLabelResId import kr.co.vividnext.sodalive.v2.widget.AudioContentTag @@ -18,14 +18,14 @@ class CreatorChannelLiveMapperTest { fun `소장과 대여가 동시에 true이면 소장중 상태를 우선 매핑한다`() { val item = audioContent(isOwned = true, isRented = true).toReplayUiModel() - assertEquals(CreatorChannelLiveReplayStatus.Owned, item.status) + assertEquals(CreatorChannelAudioContentStatus.Owned, item.status) } @Test fun `무료 콘텐츠는 무료 tag와 play CTA 상태로 매핑한다`() { val item = audioContent(price = 0).toReplayUiModel() - assertEquals(CreatorChannelLiveReplayStatus.Play, item.status) + assertEquals(CreatorChannelAudioContentStatus.Play, item.status) assertTrue(AudioContentTag.Free in item.tags) }