refactor(creator): 라이브 replay item을 공통화한다

This commit is contained in:
2026-06-19 19:11:38 +09:00
parent d97c2792f5
commit 6df7666cec
3 changed files with 42 additions and 42 deletions

View File

@@ -8,7 +8,7 @@ import android.view.ViewOutlineProvider
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.databinding.ItemCreatorChannelLiveReplayBinding
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
@@ -28,7 +28,7 @@ class CreatorChannelLiveReplayAdapter(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(
ItemCreatorChannelLiveReplayBinding.inflate(LayoutInflater.from(parent.context), parent, false),
ItemCreatorChannelAudioContentBinding.inflate(LayoutInflater.from(parent.context), parent, false),
onReplayClick
)
}
@@ -40,13 +40,13 @@ class CreatorChannelLiveReplayAdapter(
override fun getItemCount(): Int = items.size
class ViewHolder(
private val binding: ItemCreatorChannelLiveReplayBinding,
private val binding: ItemCreatorChannelAudioContentBinding,
private val onReplayClick: (CreatorChannelLiveReplayUiModel) -> Unit
) : RecyclerView.ViewHolder(binding.root) {
init {
binding.layoutCreatorChannelLiveReplayThumbnail.clipToOutline = true
binding.layoutCreatorChannelLiveReplayThumbnail.outlineProvider = object : ViewOutlineProvider() {
binding.layoutCreatorChannelAudioContentThumbnail.clipToOutline = true
binding.layoutCreatorChannelAudioContentThumbnail.outlineProvider = object : ViewOutlineProvider() {
override fun getOutline(view: View, outline: Outline) {
outline.setRoundRect(
0,
@@ -60,16 +60,16 @@ class CreatorChannelLiveReplayAdapter(
}
fun bind(item: CreatorChannelLiveReplayUiModel) = with(binding) {
ivCreatorChannelLiveReplayThumbnail.loadUrl(item.imageUrl)
tvCreatorChannelLiveReplayTitle.text = item.title
tvCreatorChannelLiveReplayDuration.text = item.secondaryText.orEmpty()
tvCreatorChannelLiveReplayDuration.isVisible = !item.secondaryText.isNullOrBlank()
ivCreatorChannelLiveReplayAdultBadge.setImageResource(R.drawable.ic_new_shield_small)
ivCreatorChannelLiveReplayAdultBadge.isVisible = item.showAdultBadge
bindTag(ivCreatorChannelLiveReplayOriginalTag, AudioContentTag.Original, item.tags)
bindTag(ivCreatorChannelLiveReplayFirstTag, AudioContentTag.First, item.tags)
bindTag(ivCreatorChannelLiveReplayPointTag, AudioContentTag.Point, item.tags)
tvCreatorChannelLiveReplayFreeTag.isVisible = AudioContentTag.Free in item.tags
ivCreatorChannelAudioContentThumbnail.loadUrl(item.imageUrl)
tvCreatorChannelAudioContentTitle.text = item.title
tvCreatorChannelAudioContentSecondaryText.text = item.secondaryText.orEmpty()
tvCreatorChannelAudioContentSecondaryText.isVisible = !item.secondaryText.isNullOrBlank()
ivCreatorChannelAudioContentAdultBadge.setImageResource(R.drawable.ic_new_shield_small)
ivCreatorChannelAudioContentAdultBadge.isVisible = item.showAdultBadge
bindTag(ivCreatorChannelAudioContentOriginalTag, AudioContentTag.Original, item.tags)
bindTag(ivCreatorChannelAudioContentFirstTag, AudioContentTag.First, item.tags)
bindTag(ivCreatorChannelAudioContentPointTag, AudioContentTag.Point, item.tags)
tvCreatorChannelAudioContentFreeTag.isVisible = AudioContentTag.Free in item.tags
bindStatus(item.status)
root.setOnClickListener { onReplayClick(item) }
}
@@ -79,29 +79,29 @@ class CreatorChannelLiveReplayAdapter(
}
private fun bindStatus(status: CreatorChannelLiveReplayStatus) = with(binding) {
ivCreatorChannelLiveReplayPlay.setImageResource(R.drawable.ic_new_player_play)
ivCreatorChannelAudioContentPlay.setImageResource(R.drawable.ic_new_player_play)
when (status) {
CreatorChannelLiveReplayStatus.Play -> {
ivCreatorChannelLiveReplayPlay.isVisible = true
ivCreatorChannelLiveReplayCan.isVisible = false
layoutCreatorChannelLiveReplayActionText.isVisible = false
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 -> {
ivCreatorChannelLiveReplayPlay.isVisible = false
layoutCreatorChannelLiveReplayActionText.isVisible = true
ivCreatorChannelLiveReplayCan.isVisible = true
tvCreatorChannelLiveReplayActionText.text = status.price.moneyFormat()
ivCreatorChannelAudioContentPlay.isVisible = false
layoutCreatorChannelAudioContentActionText.isVisible = true
ivCreatorChannelAudioContentCan.isVisible = true
tvCreatorChannelAudioContentActionText.text = status.price.moneyFormat()
}
}
}
private fun bindTextStatus(textResId: Int) = with(binding) {
ivCreatorChannelLiveReplayPlay.isVisible = true
layoutCreatorChannelLiveReplayActionText.isVisible = true
ivCreatorChannelLiveReplayCan.isVisible = false
tvCreatorChannelLiveReplayActionText.setText(textResId)
ivCreatorChannelAudioContentPlay.isVisible = true
layoutCreatorChannelAudioContentActionText.isVisible = true
ivCreatorChannelAudioContentCan.isVisible = false
tvCreatorChannelAudioContentActionText.setText(textResId)
}
}
}

View File

@@ -193,7 +193,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_creator_channel_live_current_card"
tools:itemCount="3"
tools:listitem="@layout/item_creator_channel_live_replay" />
tools:listitem="@layout/item_creator_channel_audio_content" />
<FrameLayout
android:id="@+id/layout_creator_channel_live_empty"

View File

@@ -9,7 +9,7 @@
android:orientation="horizontal">
<FrameLayout
android:id="@+id/layout_creator_channel_live_replay_thumbnail"
android:id="@+id/layout_creator_channel_audio_content_thumbnail"
android:layout_width="88dp"
android:layout_height="88dp"
android:background="@drawable/bg_audio_content_card_thumbnail"
@@ -17,7 +17,7 @@
android:outlineProvider="background">
<ImageView
android:id="@+id/iv_creator_channel_live_replay_thumbnail"
android:id="@+id/iv_creator_channel_audio_content_thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
@@ -25,7 +25,7 @@
tools:src="@drawable/ic_launcher_background" />
<ImageView
android:id="@+id/iv_creator_channel_live_replay_adult_badge"
android:id="@+id/iv_creator_channel_audio_content_adult_badge"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="top|end"
@@ -43,14 +43,14 @@
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_creator_channel_live_replay_original_tag"
android:id="@+id/iv_creator_channel_audio_content_original_tag"
android:layout_width="24dp"
android:layout_height="24dp"
android:contentDescription="@null"
android:src="@drawable/ic_content_tag_original" />
<ImageView
android:id="@+id/iv_creator_channel_live_replay_first_tag"
android:id="@+id/iv_creator_channel_audio_content_first_tag"
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@drawable/bg_audio_content_tag_first"
@@ -66,14 +66,14 @@
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_creator_channel_live_replay_point_tag"
android:id="@+id/iv_creator_channel_audio_content_point_tag"
android:layout_width="24dp"
android:layout_height="24dp"
android:contentDescription="@null"
android:src="@drawable/ic_content_tag_point" />
<TextView
android:id="@+id/tv_creator_channel_live_replay_free_tag"
android:id="@+id/tv_creator_channel_audio_content_free_tag"
style="@style/Typography.Body6"
android:layout_width="wrap_content"
android:layout_height="24dp"
@@ -96,7 +96,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/tv_creator_channel_live_replay_title"
android:id="@+id/tv_creator_channel_audio_content_title"
style="@style/Typography.Body1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -107,7 +107,7 @@
tools:text="라이브 다시 듣기 오디오 제목 라이브 다시 듣기 오디오 제목" />
<TextView
android:id="@+id/tv_creator_channel_live_replay_duration"
android:id="@+id/tv_creator_channel_audio_content_secondary_text"
style="@style/Typography.Body5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -120,14 +120,14 @@
</LinearLayout>
<LinearLayout
android:id="@+id/layout_creator_channel_live_replay_action"
android:id="@+id/layout_creator_channel_audio_content_action"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_creator_channel_live_replay_play"
android:id="@+id/iv_creator_channel_audio_content_play"
android:layout_width="28dp"
android:layout_height="28dp"
android:background="@drawable/bg_creator_channel_live_replay_play"
@@ -136,7 +136,7 @@
android:src="@drawable/ic_new_player_play" />
<LinearLayout
android:id="@+id/layout_creator_channel_live_replay_action_text"
android:id="@+id/layout_creator_channel_audio_content_action_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_8"
@@ -144,14 +144,14 @@
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_creator_channel_live_replay_can"
android:id="@+id/iv_creator_channel_audio_content_can"
android:layout_width="18dp"
android:layout_height="18dp"
android:contentDescription="@null"
android:src="@drawable/ic_bar_cash" />
<TextView
android:id="@+id/tv_creator_channel_live_replay_action_text"
android:id="@+id/tv_creator_channel_audio_content_action_text"
style="@style/Typography.Caption2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"