feat(creator): 채널 홈 시리즈, 커뮤니티, 팬 Talk 섹션을 재구성한다
This commit is contained in:
@@ -82,11 +82,8 @@ data class CreatorChannelSeriesResponse(
|
||||
@SerializedName("seriesId") val seriesId: Long,
|
||||
@SerializedName("title") val title: String,
|
||||
@SerializedName("coverImageUrl") val coverImageUrl: String,
|
||||
@SerializedName("publishedDaysOfWeek") val publishedDaysOfWeek: String,
|
||||
@SerializedName("isComplete") val isComplete: Boolean,
|
||||
@SerializedName("numberOfContent") val numberOfContent: Int,
|
||||
@SerializedName("isNew") val isNew: Boolean,
|
||||
@SerializedName("isPopular") val isPopular: Boolean,
|
||||
@SerializedName("isOriginal") val isOriginal: Boolean
|
||||
)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ fun CreatorChannelHomeResponse.toUiContent(): CreatorChannelHomeUiState.Content
|
||||
audioContents.takeIf { it.isNotEmpty() }?.let { add(CreatorChannelHomeSection.AudioContents(it)) }
|
||||
series.takeIf { it.isNotEmpty() }?.let { add(CreatorChannelHomeSection.Series(it)) }
|
||||
communities.takeIf { it.isNotEmpty() }?.let { add(CreatorChannelHomeSection.Communities(it)) }
|
||||
fanTalk.takeIf { it.totalCount > 0 || it.latestFanTalk != null }?.let { add(CreatorChannelHomeSection.FanTalk(it)) }
|
||||
add(CreatorChannelHomeSection.FanTalk(fanTalk))
|
||||
introduce.takeIf { it.isNotBlank() }?.let { add(CreatorChannelHomeSection.Introduce(it)) }
|
||||
add(CreatorChannelHomeSection.Activity(activity))
|
||||
sns.toUiItems().takeIf { it.isNotEmpty() }?.let { add(CreatorChannelHomeSection.Sns(it)) }
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
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.LinearLayout
|
||||
import kr.co.vividnext.sodalive.R
|
||||
|
||||
class CreatorChannelFanTalkCardView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
init {
|
||||
clipToOutline = true
|
||||
outlineProvider = object : ViewOutlineProvider() {
|
||||
override fun getOutline(view: View, outline: Outline) {
|
||||
outline.setRoundRect(0, 0, view.width, view.height, resources.getDimension(R.dimen.radius_14))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.HorizontalScrollView
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
@@ -18,11 +17,17 @@ import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import coil.transform.CircleCropTransformation
|
||||
import kr.co.vividnext.sodalive.common.image.BlurTransformation
|
||||
import kr.co.vividnext.sodalive.extensions.loadUrl
|
||||
import kr.co.vividnext.sodalive.extensions.moneyFormat
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelAudioContentResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelCommunityPostResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelScheduleResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelSeriesResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelHomeSection
|
||||
import kr.co.vividnext.sodalive.v2.widget.feed.FeedCommunityView
|
||||
import kr.co.vividnext.sodalive.v2.widget.feed.FeedItem
|
||||
import kr.co.vividnext.sodalive.v2.widget.feed.FeedSize
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
@@ -30,7 +35,8 @@ import kotlin.math.roundToInt
|
||||
|
||||
class CreatorChannelHomeSectionAdapter(
|
||||
private val onScheduleClick: (CreatorChannelScheduleResponse) -> Unit = {},
|
||||
private val onAudioContentClick: (CreatorChannelAudioContentResponse) -> Unit = {}
|
||||
private val onAudioContentClick: (CreatorChannelAudioContentResponse) -> Unit = {},
|
||||
private val onSeriesClick: (CreatorChannelSeriesResponse) -> Unit = {}
|
||||
) : RecyclerView.Adapter<CreatorChannelHomeSectionAdapter.SectionViewHolder>() {
|
||||
|
||||
private var items: List<CreatorChannelHomeSection> = emptyList()
|
||||
@@ -44,7 +50,7 @@ class CreatorChannelHomeSectionAdapter(
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SectionViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(viewType, parent, false)
|
||||
return SectionViewHolder(view, onScheduleClick, onAudioContentClick)
|
||||
return SectionViewHolder(view, onScheduleClick, onAudioContentClick, onSeriesClick)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: SectionViewHolder, position: Int) {
|
||||
@@ -56,7 +62,8 @@ class CreatorChannelHomeSectionAdapter(
|
||||
class SectionViewHolder(
|
||||
view: View,
|
||||
private val onScheduleClick: (CreatorChannelScheduleResponse) -> Unit,
|
||||
private val onAudioContentClick: (CreatorChannelAudioContentResponse) -> Unit
|
||||
private val onAudioContentClick: (CreatorChannelAudioContentResponse) -> Unit,
|
||||
private val onSeriesClick: (CreatorChannelSeriesResponse) -> Unit
|
||||
) : RecyclerView.ViewHolder(view) {
|
||||
private val title: TextView? = view.findViewById(R.id.tv_section_title)
|
||||
private val sectionItems: LinearLayout? = view.findViewById(R.id.ll_section_items)
|
||||
@@ -74,6 +81,15 @@ class CreatorChannelHomeSectionAdapter(
|
||||
private val scheduleTimeline: LinearLayout? = view.findViewById(R.id.ll_schedule_timeline)
|
||||
private val scheduleItems: LinearLayout? = view.findViewById(R.id.ll_schedule_items)
|
||||
private val audioContentsRecyclerView: RecyclerView? = view.findViewById(R.id.rv_audio_contents)
|
||||
private val seriesItems: LinearLayout? = view.findViewById(R.id.ll_series_items)
|
||||
private val communityItems: LinearLayout? = view.findViewById(R.id.ll_community_items)
|
||||
private val fanTalkCard: View? = view.findViewById(R.id.layout_fantalk_card)
|
||||
private val fanTalkTotalRow: View? = view.findViewById(R.id.layout_fantalk_total_row)
|
||||
private val fanTalkLatestRow: View? = view.findViewById(R.id.layout_fantalk_latest_row)
|
||||
private val fanTalkEmpty: View? = view.findViewById(R.id.layout_fantalk_empty)
|
||||
private val fanTalkTotalCount: TextView? = view.findViewById(R.id.tv_fantalk_total_count)
|
||||
private val fanTalkProfile: ImageView? = view.findViewById(R.id.iv_fantalk_profile)
|
||||
private val fanTalkContent: TextView? = view.findViewById(R.id.tv_fantalk_content)
|
||||
private val audioContentGridAdapter = AudioContentGridAdapter(
|
||||
itemWidth = calculateCreatorChannelAudioItemWidthDp(itemView.resources.configuration.screenWidthDp).dp(),
|
||||
onAudioContentClick = onAudioContentClick
|
||||
@@ -90,6 +106,8 @@ class CreatorChannelHomeSectionAdapter(
|
||||
noticeItems?.removeAllViews()
|
||||
scheduleTimeline?.removeAllViews()
|
||||
scheduleItems?.removeAllViews()
|
||||
seriesItems?.removeAllViews()
|
||||
communityItems?.removeAllViews()
|
||||
when (item) {
|
||||
is CreatorChannelHomeSection.CurrentLive -> bindCurrentLive(item)
|
||||
is CreatorChannelHomeSection.LatestAudioContent -> bindLatestAudioContent(item)
|
||||
@@ -256,54 +274,118 @@ class CreatorChannelHomeSectionAdapter(
|
||||
}
|
||||
|
||||
private fun bindSeries(item: CreatorChannelHomeSection.Series) {
|
||||
val row = createHorizontalRow()
|
||||
item.series.forEach { series ->
|
||||
row.addView(
|
||||
createContentTile(
|
||||
title = series.title,
|
||||
body = itemView.context.getString(
|
||||
R.string.creator_channel_series_summary,
|
||||
series.numberOfContent,
|
||||
series.publishedDaysOfWeek
|
||||
),
|
||||
imageUrl = series.coverImageUrl,
|
||||
imageWidth = 163.dp(),
|
||||
imageHeight = 230.dp()
|
||||
)
|
||||
val visibleSeries = item.series.take(MAX_SERIES_ITEM_COUNT)
|
||||
visibleSeries.forEachIndexed { index, series ->
|
||||
val seriesWidthDp = calculateCreatorChannelSeriesCardWidthDp(itemView.resources.configuration.screenWidthDp)
|
||||
val row = LayoutInflater.from(itemView.context).inflate(
|
||||
R.layout.item_creator_channel_home_series_content,
|
||||
seriesItems,
|
||||
false
|
||||
)
|
||||
row.layoutParams = LinearLayout.LayoutParams(
|
||||
seriesWidthDp.dp(),
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
marginEnd = if (index == visibleSeries.lastIndex) 0 else 4.dp()
|
||||
}
|
||||
(row as CreatorChannelHomeSeriesCardView).apply {
|
||||
setThumbnailSize(seriesWidthDp, calculateCreatorChannelSeriesCardHeightDp(seriesWidthDp))
|
||||
bind(series)
|
||||
}
|
||||
row.setOnClickListener { onSeriesClick(series) }
|
||||
seriesItems?.addView(row)
|
||||
}
|
||||
sectionItems?.addView(createHorizontalScrollRow(row))
|
||||
}
|
||||
|
||||
private fun bindCommunities(item: CreatorChannelHomeSection.Communities) {
|
||||
item.communities.forEach { community ->
|
||||
addFeedCard(
|
||||
title = community.content,
|
||||
body = itemView.context.getString(
|
||||
R.string.creator_channel_community_summary,
|
||||
community.creatorNickname,
|
||||
community.likeCount,
|
||||
community.commentCount
|
||||
),
|
||||
imageUrl = community.imageUrl
|
||||
val visibleCommunities = item.communities.take(MAX_COMMUNITY_ITEM_COUNT)
|
||||
visibleCommunities.forEachIndexed { index, community ->
|
||||
val communityWidthDp = calculateCreatorChannelCommunityCardWidthDp(
|
||||
itemView.resources.configuration.screenWidthDp
|
||||
)
|
||||
val row = LayoutInflater.from(itemView.context).inflate(
|
||||
R.layout.view_feed_community,
|
||||
communityItems,
|
||||
false
|
||||
)
|
||||
(row as FeedCommunityView).apply {
|
||||
setFeedSize(
|
||||
FeedSize(
|
||||
rootWidthDp = communityWidthDp
|
||||
)
|
||||
)
|
||||
setHideEmptyTextRows(true)
|
||||
bind(community.toFeedCommunityItem())
|
||||
}
|
||||
bindCommunityImages(row, community)
|
||||
row.layoutParams = LinearLayout.LayoutParams(
|
||||
communityWidthDp.dp(),
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
bottomMargin = if (index == visibleCommunities.lastIndex) 0 else 8.dp()
|
||||
}
|
||||
communityItems?.addView(row)
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindFanTalk(item: CreatorChannelHomeSection.FanTalk) {
|
||||
item.fanTalk.latestFanTalk?.let { fanTalk ->
|
||||
addCommentCard(
|
||||
title = fanTalk.content,
|
||||
body = itemView.context.getString(
|
||||
R.string.creator_channel_fantalk_summary,
|
||||
fanTalk.nickname,
|
||||
item.fanTalk.totalCount
|
||||
),
|
||||
imageUrl = fanTalk.profileImageUrl
|
||||
)
|
||||
fanTalkCard?.layoutParams = fanTalkCard.layoutParams?.apply {
|
||||
width = calculateCreatorChannelFanTalkCardWidthDp(itemView.resources.configuration.screenWidthDp).dp()
|
||||
}
|
||||
fanTalkTotalCount?.text = item.fanTalk.totalCount.toString()
|
||||
val fanTalk = item.fanTalk.latestFanTalk
|
||||
fanTalkTotalRow?.isVisible = fanTalk != null && item.fanTalk.totalCount > 0
|
||||
fanTalkLatestRow?.isVisible = fanTalk != null && item.fanTalk.totalCount > 0
|
||||
fanTalkEmpty?.isVisible = fanTalk == null || item.fanTalk.totalCount <= 0
|
||||
if (fanTalk != null) {
|
||||
fanTalkContent?.text = fanTalk.content
|
||||
fanTalkProfile?.loadUrl(fanTalk.profileImageUrl) {
|
||||
placeholder(R.drawable.ic_placeholder_profile)
|
||||
transformations(CircleCropTransformation())
|
||||
}
|
||||
} else {
|
||||
fanTalkContent?.text = ""
|
||||
fanTalkProfile?.setImageResource(R.drawable.ic_placeholder_profile)
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindCommunityImages(row: View, community: CreatorChannelCommunityPostResponse) {
|
||||
val communityRow = row as FeedCommunityView
|
||||
communityRow.profileImageView().loadUrl(community.creatorProfileUrl) {
|
||||
placeholder(R.drawable.ic_placeholder_profile)
|
||||
transformations(CircleCropTransformation())
|
||||
}
|
||||
val isCommunityLocked = community.price > 0 && !community.existOrdered
|
||||
val communityImageUrl = community.imageUrl.takeIf { !it.isNullOrBlank() }
|
||||
if (communityImageUrl != null) {
|
||||
communityRow.communityImageView().loadUrl(communityImageUrl) {
|
||||
if (isCommunityLocked) {
|
||||
transformations(BlurTransformation(itemView.context, 25f, 2.5f))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
communityRow.communityImageView().setImageDrawable(null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun CreatorChannelCommunityPostResponse.toFeedCommunityItem(): FeedItem.Community = FeedItem.Community(
|
||||
feedId = postId.toString(),
|
||||
creatorId = creatorId.toString(),
|
||||
creatorName = creatorNickname,
|
||||
creatorImageUrl = creatorProfileUrl,
|
||||
postId = postId.toString(),
|
||||
bodyText = content,
|
||||
keywordText = "",
|
||||
createdAtText = dateUtc,
|
||||
commentCount = commentCount,
|
||||
likeCount = likeCount,
|
||||
imageUrl = imageUrl,
|
||||
audioUrl = audioUrl,
|
||||
price = price,
|
||||
existOrdered = existOrdered,
|
||||
showKeyword = false
|
||||
)
|
||||
|
||||
private fun bindIntroduce(item: CreatorChannelHomeSection.Introduce) {
|
||||
addTextCard(title = item.introduce, body = "", imageUrl = null)
|
||||
}
|
||||
@@ -371,26 +453,6 @@ class CreatorChannelHomeSectionAdapter(
|
||||
sectionItems?.addView(card)
|
||||
}
|
||||
|
||||
private fun addFeedCard(title: String, body: String, imageUrl: String?) {
|
||||
val card = LinearLayout(itemView.context).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setPadding(14.dp(), 14.dp(), 14.dp(), 14.dp())
|
||||
setBackgroundResource(R.drawable.bg_round_corner_16_7_222222)
|
||||
layoutParams = defaultBlockLayoutParams()
|
||||
}
|
||||
card.addView(createText(body, R.style.Typography_Caption2, R.color.gray_500, maxLines = 1))
|
||||
card.addView(createText(title, R.style.Typography_Body2, R.color.white, maxLines = 4))
|
||||
card.addView(createImage(imageUrl, LinearLayout.LayoutParams.MATCH_PARENT, 180.dp()))
|
||||
sectionItems?.addView(card)
|
||||
}
|
||||
|
||||
private fun addCommentCard(title: String, body: String, imageUrl: String?) {
|
||||
val card = createHorizontalCard()
|
||||
card.addView(createImage(imageUrl, 28.dp(), 28.dp()))
|
||||
card.addView(createTextGroup(title, body, bodyMaxLines = 2))
|
||||
sectionItems?.addView(card)
|
||||
}
|
||||
|
||||
private fun createHorizontalCard(): LinearLayout =
|
||||
LinearLayout(itemView.context).apply {
|
||||
orientation = LinearLayout.HORIZONTAL
|
||||
@@ -412,22 +474,6 @@ class CreatorChannelHomeSectionAdapter(
|
||||
return textGroup
|
||||
}
|
||||
|
||||
private fun createContentTile(
|
||||
title: String,
|
||||
body: String,
|
||||
imageUrl: String?,
|
||||
imageWidth: Int,
|
||||
imageHeight: Int
|
||||
): LinearLayout = LinearLayout(itemView.context).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
layoutParams = LinearLayout.LayoutParams(imageWidth, LinearLayout.LayoutParams.WRAP_CONTENT).apply {
|
||||
marginEnd = 12.dp()
|
||||
}
|
||||
addView(createImage(imageUrl, imageWidth, imageHeight))
|
||||
addView(createText(title, R.style.Typography_Body2, R.color.white, maxLines = 2))
|
||||
addView(createText(body, R.style.Typography_Caption2, R.color.gray_500, maxLines = 1))
|
||||
}
|
||||
|
||||
private fun createImage(imageUrl: String?, width: Int, height: Int): ImageView = ImageView(itemView.context).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(width, height).apply {
|
||||
bottomMargin = 8.dp()
|
||||
@@ -438,19 +484,6 @@ class CreatorChannelHomeSectionAdapter(
|
||||
imageUrl?.let(::loadUrl)
|
||||
}
|
||||
|
||||
private fun createHorizontalRow(): LinearLayout = LinearLayout(itemView.context).apply {
|
||||
orientation = LinearLayout.HORIZONTAL
|
||||
layoutParams = defaultBlockLayoutParams()
|
||||
}
|
||||
|
||||
private fun createHorizontalScrollRow(row: LinearLayout): HorizontalScrollView =
|
||||
HorizontalScrollView(itemView.context).apply {
|
||||
isHorizontalScrollBarEnabled = false
|
||||
overScrollMode = View.OVER_SCROLL_NEVER
|
||||
layoutParams = defaultBlockLayoutParams()
|
||||
addView(row)
|
||||
}
|
||||
|
||||
private fun defaultBlockLayoutParams(): LinearLayout.LayoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
@@ -618,6 +651,8 @@ class CreatorChannelHomeSectionAdapter(
|
||||
private const val MAX_NOTICE_ITEM_COUNT = 3
|
||||
private const val MAX_SCHEDULE_ITEM_COUNT = 3
|
||||
private const val MAX_AUDIO_ITEM_COUNT = 9
|
||||
private const val MAX_SERIES_ITEM_COUNT = 10
|
||||
private const val MAX_COMMUNITY_ITEM_COUNT = 3
|
||||
private const val AUDIO_GRID_SPAN_COUNT = 3
|
||||
|
||||
fun List<String>.joinToText(): String = filter(String::isNotBlank).joinToString(separator = " · ")
|
||||
@@ -699,4 +734,33 @@ internal fun calculateCreatorChannelAudioItemWidthDp(screenWidthDp: Int): Int {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun calculateCreatorChannelSeriesCardWidthDp(screenWidthDp: Int): Int {
|
||||
val width = screenWidthDp.takeIf { it > 0 } ?: 402
|
||||
return if (width >= 402) {
|
||||
163
|
||||
} else {
|
||||
(163f * width / 402f).roundToInt()
|
||||
}
|
||||
}
|
||||
|
||||
internal fun calculateCreatorChannelSeriesCardHeightDp(widthDp: Int): Int = (widthDp * 230f / 163f).roundToInt()
|
||||
|
||||
internal fun calculateCreatorChannelCommunityCardWidthDp(screenWidthDp: Int): Int {
|
||||
val width = screenWidthDp.takeIf { it > 0 } ?: 402
|
||||
return if (width >= 402) {
|
||||
374
|
||||
} else {
|
||||
(374f * width / 402f).roundToInt()
|
||||
}
|
||||
}
|
||||
|
||||
internal fun calculateCreatorChannelFanTalkCardWidthDp(screenWidthDp: Int): Int {
|
||||
val width = screenWidthDp.takeIf { it > 0 } ?: 402
|
||||
return if (width >= 402) {
|
||||
374
|
||||
} else {
|
||||
(374f * width / 402f).roundToInt()
|
||||
}
|
||||
}
|
||||
|
||||
internal fun calculateCreatorChannelScheduleTimelineLineCount(scheduleCount: Int): Int = (scheduleCount - 1).coerceAtLeast(0)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
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.ViewGroup
|
||||
import android.view.ViewOutlineProvider
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
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.CreatorChannelSeriesResponse
|
||||
|
||||
class CreatorChannelHomeSeriesCardView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private val thumbnailContainer: View by lazy { findViewById(R.id.layout_series_thumbnail) }
|
||||
private val thumbnail: ImageView by lazy { findViewById(R.id.iv_series_thumbnail) }
|
||||
private val originalTag: View by lazy { findViewById(R.id.layout_series_original_tag) }
|
||||
|
||||
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(series: CreatorChannelSeriesResponse) {
|
||||
thumbnail.loadUrl(series.coverImageUrl)
|
||||
originalTag.isVisible = series.isOriginal
|
||||
}
|
||||
|
||||
fun setThumbnailSize(widthDp: Int, heightDp: Int) {
|
||||
thumbnailContainer.layoutParams = thumbnailContainer.layoutParams.apply {
|
||||
width = widthDp.dp()
|
||||
height = heightDp.dp()
|
||||
} ?: ViewGroup.LayoutParams(widthDp.dp(), heightDp.dp())
|
||||
}
|
||||
|
||||
private fun Int.dp(): Int = (this * resources.displayMetrics.density).toInt()
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.dispose
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.image.BlurTransformation
|
||||
import kr.co.vividnext.sodalive.extensions.loadUrl
|
||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationPopularCommunityPostSection
|
||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationPopularCommunityPostUiModel
|
||||
@@ -49,15 +50,27 @@ class HomePopularCommunityAdapter(
|
||||
view.bind(item.item)
|
||||
view.setOnFeedClick { feedItem -> onClickItem(feedItem as FeedItem.Community) }
|
||||
bindImage(item.item.creatorImageUrl, view.profileImageView())
|
||||
bindImage(item.item.imageUrl.takeIf { item.item.price <= 0 || item.item.existOrdered }, view.communityImageView())
|
||||
bindImage(
|
||||
imageUrl = item.item.imageUrl,
|
||||
imageView = view.communityImageView(),
|
||||
shouldBlur = item.item.price > 0 && !item.item.existOrdered
|
||||
)
|
||||
}
|
||||
|
||||
private fun bindImage(imageUrl: String?, imageView: android.widget.ImageView) {
|
||||
private fun bindImage(
|
||||
imageUrl: String?,
|
||||
imageView: android.widget.ImageView,
|
||||
shouldBlur: Boolean = false
|
||||
) {
|
||||
if (imageUrl.isNullOrBlank()) {
|
||||
imageView.dispose()
|
||||
imageView.setImageDrawable(null)
|
||||
} else {
|
||||
imageView.loadUrl(imageUrl)
|
||||
imageView.loadUrl(imageUrl) {
|
||||
if (shouldBlur) {
|
||||
transformations(BlurTransformation(imageView.context, 25f, 2.5f))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.view.ViewOutlineProvider
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@@ -22,7 +23,6 @@ class FeedCommunityView @JvmOverloads constructor(
|
||||
private var creatorText: TextView? = null
|
||||
private var createdAtText: TextView? = null
|
||||
private var bodyText: TextView? = null
|
||||
private var keywordText: TextView? = null
|
||||
private var communityImageContainer: View? = null
|
||||
private var communityImage: ImageView? = null
|
||||
private var paidOverlay: View? = null
|
||||
@@ -39,7 +39,6 @@ class FeedCommunityView @JvmOverloads constructor(
|
||||
creatorText = findViewById(R.id.tv_feed_community_creator)
|
||||
createdAtText = findViewById(R.id.tv_feed_community_created_at)
|
||||
bodyText = findViewById(R.id.tv_feed_community_body)
|
||||
keywordText = findViewById(R.id.tv_feed_community_keyword)
|
||||
communityImageContainer = findViewById(R.id.fl_feed_community_image_container)
|
||||
communityImage = findViewById(R.id.iv_feed_community_image)
|
||||
paidOverlay = findViewById(R.id.ll_feed_community_paid_overlay)
|
||||
@@ -54,21 +53,20 @@ class FeedCommunityView @JvmOverloads constructor(
|
||||
requireNotNull(communityImageContainer).outlineProvider = roundedOutlineProvider(COMMUNITY_IMAGE_RADIUS_DP)
|
||||
}
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
updateCommunityImageHeight(MeasureSpec.getSize(widthMeasureSpec))
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
}
|
||||
|
||||
fun bind(item: FeedItem.Community) {
|
||||
currentItem = item
|
||||
requireNotNull(creatorText).text = item.creatorName
|
||||
requireNotNull(createdAtText).text = item.createdAtText
|
||||
requireNotNull(bodyText).text = item.bodyText
|
||||
requireNotNull(keywordText).text = item.keywordText
|
||||
requireNotNull(bodyText).visibility = visibilityForText(item.bodyText)
|
||||
requireNotNull(keywordText).visibility = if (item.showKeyword) visibilityForText(item.keywordText) else View.GONE
|
||||
requireNotNull(communityImageContainer).visibility = if (item.imageUrl.isNullOrBlank()) View.GONE else View.VISIBLE
|
||||
requireNotNull(paidOverlay).visibility = if (item.price > 0 && !item.existOrdered) View.VISIBLE else View.GONE
|
||||
val isLocked = item.price > 0 && !item.existOrdered
|
||||
val hasImage = !item.imageUrl.isNullOrBlank()
|
||||
requireNotNull(communityImageContainer).isVisible = hasImage || isLocked
|
||||
requireNotNull(communityImage).isVisible = hasImage
|
||||
if (!hasImage || isLocked) {
|
||||
requireNotNull(communityImage).setImageDrawable(null)
|
||||
}
|
||||
requireNotNull(paidOverlay).isVisible = isLocked
|
||||
requireNotNull(priceText).text = item.price.toString()
|
||||
requireNotNull(commentCountText).text = item.commentCount.toString()
|
||||
requireNotNull(likeCountText).text = item.likeCount.toString()
|
||||
@@ -113,20 +111,6 @@ class FeedCommunityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateCommunityImageHeight(rootWidth: Int) {
|
||||
val imageWidth = rootWidth - paddingLeft - paddingRight
|
||||
if (imageWidth <= 0) return
|
||||
|
||||
val container = requireNotNull(communityImageContainer)
|
||||
val currentLayoutParams = container.layoutParams
|
||||
val nextHeight = (imageWidth * COMMUNITY_IMAGE_FIGMA_HEIGHT_DP / COMMUNITY_IMAGE_FIGMA_WIDTH_DP.toFloat())
|
||||
.roundToInt()
|
||||
if (currentLayoutParams.height != nextHeight) {
|
||||
currentLayoutParams.height = nextHeight
|
||||
container.layoutParams = currentLayoutParams
|
||||
}
|
||||
}
|
||||
|
||||
private fun circleOutlineProvider() = object : ViewOutlineProvider() {
|
||||
override fun getOutline(view: View, outline: Outline) {
|
||||
outline.setOval(0, 0, view.width, view.height)
|
||||
@@ -144,7 +128,5 @@ class FeedCommunityView @JvmOverloads constructor(
|
||||
private companion object {
|
||||
const val CARD_RADIUS_DP = 14
|
||||
const val COMMUNITY_IMAGE_RADIUS_DP = 14
|
||||
const val COMMUNITY_IMAGE_FIGMA_WIDTH_DP = 346
|
||||
const val COMMUNITY_IMAGE_FIGMA_HEIGHT_DP = 236
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user