feat(creator): 채널 홈 오디오 콘텐츠 카드를 추가한다
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Outline
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewOutlineProvider
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.extensions.loadUrl
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelAudioContentResponse
|
||||
|
||||
class CreatorChannelHomeAudioContentCardView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private val thumbnailContainer: View by lazy { findViewById(R.id.layout_audio_content_thumbnail) }
|
||||
private val thumbnail: ImageView by lazy { findViewById(R.id.iv_audio_content_thumbnail) }
|
||||
private val originalTag: ImageView by lazy { findViewById(R.id.iv_audio_content_original_tag) }
|
||||
private val pointTag: ImageView by lazy { findViewById(R.id.iv_audio_content_point_tag) }
|
||||
private val firstTag: ImageView by lazy { findViewById(R.id.iv_audio_content_first_tag) }
|
||||
private val freeTag: TextView by lazy { findViewById(R.id.tv_audio_content_free_tag) }
|
||||
private val title: TextView by lazy { findViewById(R.id.tv_audio_content_title) }
|
||||
private val secondary: TextView by lazy { findViewById(R.id.tv_audio_content_secondary) }
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
thumbnailContainer.clipToOutline = true
|
||||
thumbnailContainer.outlineProvider = object : ViewOutlineProvider() {
|
||||
override fun getOutline(view: View, outline: Outline) {
|
||||
outline.setRoundRect(0, 0, view.width, view.height, resources.getDimension(R.dimen.radius_14))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bind(audioContent: CreatorChannelAudioContentResponse) {
|
||||
title.text = audioContent.title
|
||||
secondary.text = listOfNotNull(audioContent.duration, audioContent.seriesName).joinToCreatorChannelAudioText()
|
||||
thumbnail.loadUrl(audioContent.imageUrl)
|
||||
originalTag.isVisible = audioContent.isOriginalSeries == true
|
||||
pointTag.isVisible = audioContent.isPointAvailable
|
||||
firstTag.isVisible = audioContent.isFirstContent
|
||||
freeTag.isVisible = audioContent.price <= 0
|
||||
}
|
||||
|
||||
private fun List<String?>.joinToCreatorChannelAudioText(): String =
|
||||
filterNot { it.isNullOrBlank() }.joinToString(separator = " • ") { it.orEmpty() }
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<kr.co.vividnext.sodalive.v2.creator.channel.ui.CreatorChannelHomeAudioContentCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_audio_content_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="88dp"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/layout_audio_content_thumbnail"
|
||||
android:layout_width="88dp"
|
||||
android:layout_height="88dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/bg_audio_content_card_thumbnail">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_audio_content_thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@null"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/ic_launcher_background" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="top|start"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_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_audio_content_first_tag"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:background="@drawable/bg_audio_content_tag_first"
|
||||
android:contentDescription="@null"
|
||||
android:padding="3dp"
|
||||
android:src="@drawable/ic_content_tag_first_star" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="bottom|start"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_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_audio_content_free_tag"
|
||||
style="@style/Typography.Body6"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="24dp"
|
||||
android:background="@drawable/bg_audio_content_tag_free"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:text="@string/audio_content_tag_free"
|
||||
android:textColor="@color/white" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="88dp"
|
||||
android:layout_marginStart="@dimen/spacing_14"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_audio_content_title"
|
||||
style="@style/Typography.Body2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/white"
|
||||
tools:text="콘텐츠 이름이 한 줄 콘텐츠 이름이 한 ..." />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_audio_content_secondary"
|
||||
style="@style/Typography.Body6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/gray_500"
|
||||
tools:text="3:00 • 시리즈 이름" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</kr.co.vividnext.sodalive.v2.creator.channel.ui.CreatorChannelHomeAudioContentCardView>
|
||||
Reference in New Issue
Block a user