refactor(creator): 라이브 replay item을 공통화한다
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user