From 3f3bacebd918f98b1d403979fcb11fd0dd73dc10 Mon Sep 17 00:00:00 2001 From: klaus Date: Tue, 30 Jun 2026 23:54:10 +0900 Subject: [PATCH] =?UTF-8?q?fix(home):=20=ED=8C=94=EB=A1=9C=EC=9E=89=20?= =?UTF-8?q?=EC=B5=9C=EA=B7=BC=20=EC=86=8C=EC=8B=9D=20nested=20payload?= =?UTF-8?q?=EB=A5=BC=20=EB=B0=98=EC=98=81=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v2/main/home/data/HomeFollowingModels.kt | 50 ++++++-- .../main/home/model/HomeFollowingMappers.kt | 116 +++++++++++++----- .../main/home/model/HomeFollowingUiModels.kt | 44 ++++--- .../main/home/ui/HomeFollowingNewsAdapter.kt | 46 +++---- app/src/main/res/values-en/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 7 files changed, 178 insertions(+), 81 deletions(-) diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/data/HomeFollowingModels.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/data/HomeFollowingModels.kt index 33389b79..ff3802e6 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/data/HomeFollowingModels.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/data/HomeFollowingModels.kt @@ -48,15 +48,49 @@ data class FollowingScheduleResponse( data class FollowingNewsResponse( @SerializedName("newsId") val newsId: String, @SerializedName("type") val type: FollowingNewsType, - @SerializedName("creatorProfileImageUrl") val creatorProfileImageUrl: String, - @SerializedName("creatorNickname") val creatorNickname: String, - @SerializedName("title") val title: String, - @SerializedName("body") val body: String, - @SerializedName("thumbnailImageUrl") val thumbnailImageUrl: String?, - @SerializedName("targetId") val targetId: Long, - @SerializedName("occurredAtUtc") val occurredAtUtc: String, @SerializedName("visibleFromAtUtc") val visibleFromAtUtc: String, - @SerializedName("rank") val rank: Int? + @SerializedName("creatorRanking") val creatorRanking: FollowingCreatorRankingNewsResponse? = null, + @SerializedName("audioContent") val audioContent: FollowingContentNewsResponse? = null, + @SerializedName("photoContent") val photoContent: FollowingContentNewsResponse? = null, + @SerializedName("contentRanking") val contentRanking: FollowingContentRankingNewsResponse? = null, + @SerializedName("communityPost") val communityPost: FollowingCommunityPostNewsResponse? = null +) + +@Keep +data class FollowingCreatorRankingNewsResponse( + @SerializedName("rank") val rank: Int, + @SerializedName("creatorId") val creatorId: Long, + @SerializedName("nickname") val nickname: String, + @SerializedName("profileImageUrl") val profileImageUrl: String +) + +@Keep +data class FollowingContentNewsResponse( + @SerializedName("contentId") val contentId: Long, + @SerializedName("contentImageUrl") val contentImageUrl: String?, + @SerializedName("title") val title: String, + @SerializedName("creatorProfileImageUrl") val creatorProfileImageUrl: String, + @SerializedName("creatorNickname") val creatorNickname: String +) + +@Keep +data class FollowingContentRankingNewsResponse( + @SerializedName("rank") val rank: Int, + @SerializedName("contentId") val contentId: Long, + @SerializedName("contentImageUrl") val contentImageUrl: String?, + @SerializedName("title") val title: String +) + +@Keep +data class FollowingCommunityPostNewsResponse( + @SerializedName("postId") val postId: Long, + @SerializedName("creatorProfileImage") val creatorProfileImage: String, + @SerializedName("creatorNickname") val creatorNickname: String, + @SerializedName("imageUrl") val imageUrl: String?, + @SerializedName("content") val content: String, + @SerializedName("createdAt") val createdAt: String, + @SerializedName("likeCount") val likeCount: Int, + @SerializedName("commentCount") val commentCount: Int ) enum class FollowingNewsType { diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/model/HomeFollowingMappers.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/model/HomeFollowingMappers.kt index 05f2dc18..f8942e2d 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/model/HomeFollowingMappers.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/model/HomeFollowingMappers.kt @@ -4,7 +4,11 @@ import androidx.annotation.StringRes import kr.co.vividnext.sodalive.R import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter import kr.co.vividnext.sodalive.v2.main.chat.model.toUiItems +import kr.co.vividnext.sodalive.v2.main.home.data.FollowingCommunityPostNewsResponse +import kr.co.vividnext.sodalive.v2.main.home.data.FollowingContentNewsResponse +import kr.co.vividnext.sodalive.v2.main.home.data.FollowingContentRankingNewsResponse import kr.co.vividnext.sodalive.v2.main.home.data.FollowingCreatorResponse +import kr.co.vividnext.sodalive.v2.main.home.data.FollowingCreatorRankingNewsResponse import kr.co.vividnext.sodalive.v2.main.home.data.FollowingLiveResponse import kr.co.vividnext.sodalive.v2.main.home.data.FollowingNewsResponse import kr.co.vividnext.sodalive.v2.main.home.data.FollowingNewsType @@ -62,42 +66,88 @@ private fun FollowingNewsResponse.toUiItem( ): HomeFollowingNewsUiItem? { val visibleFromText = relativeTimeTextFormatter.format(visibleFromAtUtc) return when (type) { - FollowingNewsType.CREATOR_RANKING, - FollowingNewsType.CONTENT_RANKING -> rank?.let { - HomeFollowingNewsUiItem.Ranking( - newsId = newsId, - type = type, - creatorProfileImageUrl = creatorProfileImageUrl, - creatorNickname = creatorNickname, - title = title, - body = body, - thumbnailImageUrl = thumbnailImageUrl, - targetId = targetId, - occurredAtUtc = occurredAtUtc, - visibleFromAtUtc = visibleFromAtUtc, - visibleFromText = visibleFromText, - rank = it - ) - } - FollowingNewsType.COMMUNITY_POST, - FollowingNewsType.AUDIO_CONTENT, - FollowingNewsType.PHOTO_CONTENT -> HomeFollowingNewsUiItem.Content( - newsId = newsId, - type = type, - creatorProfileImageUrl = creatorProfileImageUrl, - creatorNickname = creatorNickname, - title = title, - body = body, - thumbnailImageUrl = thumbnailImageUrl, - targetId = targetId, - occurredAtUtc = occurredAtUtc, - visibleFromAtUtc = visibleFromAtUtc, - visibleFromText = visibleFromText, - labelResId = type.toLabelResId() - ) + FollowingNewsType.CREATOR_RANKING -> creatorRanking?.toUiItem(newsId, type, visibleFromAtUtc, visibleFromText) + FollowingNewsType.CONTENT_RANKING -> contentRanking?.toUiItem(newsId, type, visibleFromAtUtc, visibleFromText) + FollowingNewsType.COMMUNITY_POST -> communityPost?.toUiItem(newsId, type, visibleFromAtUtc, visibleFromText) + FollowingNewsType.AUDIO_CONTENT -> audioContent?.toUiItem(newsId, type, visibleFromAtUtc, visibleFromText) + FollowingNewsType.PHOTO_CONTENT -> photoContent?.toUiItem(newsId, type, visibleFromAtUtc, visibleFromText) } } +private fun FollowingCreatorRankingNewsResponse.toUiItem( + newsId: String, + type: FollowingNewsType, + visibleFromAtUtc: String, + visibleFromText: String +) = HomeFollowingNewsUiItem.Ranking( + newsId = newsId, + type = type, + targetId = creatorId, + visibleFromAtUtc = visibleFromAtUtc, + visibleFromText = visibleFromText, + rank = rank, + imageUrl = profileImageUrl, + title = nickname, + creatorNickname = nickname +) + +private fun FollowingContentRankingNewsResponse.toUiItem( + newsId: String, + type: FollowingNewsType, + visibleFromAtUtc: String, + visibleFromText: String +) = HomeFollowingNewsUiItem.Ranking( + newsId = newsId, + type = type, + targetId = contentId, + visibleFromAtUtc = visibleFromAtUtc, + visibleFromText = visibleFromText, + rank = rank, + imageUrl = contentImageUrl, + title = title, + creatorNickname = "" +) + +private fun FollowingContentNewsResponse.toUiItem( + newsId: String, + type: FollowingNewsType, + visibleFromAtUtc: String, + visibleFromText: String +) = HomeFollowingNewsUiItem.Content( + newsId = newsId, + type = type, + targetId = contentId, + visibleFromAtUtc = visibleFromAtUtc, + visibleFromText = visibleFromText, + contentId = contentId, + contentImageUrl = contentImageUrl, + title = title, + creatorProfileImageUrl = creatorProfileImageUrl, + creatorNickname = creatorNickname, + labelResId = type.toLabelResId() +) + +private fun FollowingCommunityPostNewsResponse.toUiItem( + newsId: String, + type: FollowingNewsType, + visibleFromAtUtc: String, + visibleFromText: String +) = HomeFollowingNewsUiItem.Community( + newsId = newsId, + type = type, + targetId = postId, + visibleFromAtUtc = visibleFromAtUtc, + visibleFromText = visibleFromText, + postId = postId, + creatorProfileImageUrl = creatorProfileImage, + creatorNickname = creatorNickname, + imageUrl = imageUrl, + content = content, + createdAt = createdAt, + likeCount = likeCount, + commentCount = commentCount +) + @StringRes private fun FollowingNewsType.toLabelResId(): Int = when (this) { FollowingNewsType.PHOTO_CONTENT -> R.string.screen_home_following_photo_content diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/model/HomeFollowingUiModels.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/model/HomeFollowingUiModels.kt index 8170b420..64408cdb 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/model/HomeFollowingUiModels.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/model/HomeFollowingUiModels.kt @@ -55,43 +55,49 @@ data class HomeFollowingScheduleUiItem( sealed interface HomeFollowingNewsUiItem { val newsId: String val type: FollowingNewsType - val creatorProfileImageUrl: String - val creatorNickname: String - val title: String - val body: String - val thumbnailImageUrl: String? val targetId: Long - val occurredAtUtc: String val visibleFromAtUtc: String val visibleFromText: String data class Ranking( override val newsId: String, override val type: FollowingNewsType, - override val creatorProfileImageUrl: String, - override val creatorNickname: String, - override val title: String, - override val body: String, - override val thumbnailImageUrl: String?, override val targetId: Long, - override val occurredAtUtc: String, override val visibleFromAtUtc: String, override val visibleFromText: String, - val rank: Int + val rank: Int, + val imageUrl: String?, + val title: String, + val creatorNickname: String ) : HomeFollowingNewsUiItem data class Content( override val newsId: String, override val type: FollowingNewsType, - override val creatorProfileImageUrl: String, - override val creatorNickname: String, - override val title: String, - override val body: String, - override val thumbnailImageUrl: String?, override val targetId: Long, - override val occurredAtUtc: String, override val visibleFromAtUtc: String, override val visibleFromText: String, + val contentId: Long, + val contentImageUrl: String?, + val title: String, + val creatorProfileImageUrl: String, + val creatorNickname: String, @param:StringRes val labelResId: Int ) : HomeFollowingNewsUiItem + + data class Community( + override val newsId: String, + override val type: FollowingNewsType, + override val targetId: Long, + override val visibleFromAtUtc: String, + override val visibleFromText: String, + val postId: Long, + val creatorProfileImageUrl: String, + val creatorNickname: String, + val imageUrl: String?, + val content: String, + val createdAt: String, + val likeCount: Int, + val commentCount: Int + ) : HomeFollowingNewsUiItem } diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingNewsAdapter.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingNewsAdapter.kt index 755c6db4..c547c68a 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingNewsAdapter.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingNewsAdapter.kt @@ -31,13 +31,8 @@ class HomeFollowingNewsAdapter( override fun getItemViewType(position: Int): Int = when (val item = items[position]) { is HomeFollowingNewsUiItem.Ranking -> VIEW_TYPE_RANKING - is HomeFollowingNewsUiItem.Content -> when (item.type) { - FollowingNewsType.COMMUNITY_POST -> VIEW_TYPE_COMMUNITY - FollowingNewsType.AUDIO_CONTENT, - FollowingNewsType.PHOTO_CONTENT -> VIEW_TYPE_CONTENT - FollowingNewsType.CREATOR_RANKING, - FollowingNewsType.CONTENT_RANKING -> VIEW_TYPE_CONTENT - } + is HomeFollowingNewsUiItem.Content -> VIEW_TYPE_CONTENT + is HomeFollowingNewsUiItem.Community -> VIEW_TYPE_COMMUNITY } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NewsViewHolder { @@ -80,14 +75,10 @@ class HomeFollowingNewsAdapter( val ranking = item as HomeFollowingNewsUiItem.Ranking val context = view.context val rankText = "${ranking.rank}위" - val message = context.getString( - R.string.screen_home_following_creator_ranking_news_message, - ranking.creatorNickname, - rankText - ) + val message = ranking.toRankingMessage(rankText) val feedItem = FeedItem.Rank( feedId = ranking.newsId, - imageUrl = ranking.thumbnailImageUrl.orEmpty(), + imageUrl = ranking.imageUrl.orEmpty(), rankText = ranking.rank.toString(), message = message, highlightRanges = listOf( @@ -102,6 +93,19 @@ class HomeFollowingNewsAdapter( bindImage(view.imageView(), feedItem.imageUrl) view.setOnFeedClick { onClickItem(ranking) } } + + private fun HomeFollowingNewsUiItem.Ranking.toRankingMessage(rankText: String): String { + val messageResId = when (type) { + FollowingNewsType.CREATOR_RANKING -> R.string.screen_home_following_creator_ranking_news_message + FollowingNewsType.CONTENT_RANKING -> R.string.screen_home_following_content_ranking_news_message + FollowingNewsType.COMMUNITY_POST, + FollowingNewsType.AUDIO_CONTENT, + FollowingNewsType.PHOTO_CONTENT -> R.string.screen_home_following_content_ranking_news_message + } + val subject = if (type == FollowingNewsType.CREATOR_RANKING) creatorNickname else title + val context = view.context + return context.getString(messageResId, subject, rankText) + } } class CommunityViewHolder( @@ -111,19 +115,19 @@ class HomeFollowingNewsAdapter( ) : NewsViewHolder(view) { override fun bind(item: HomeFollowingNewsUiItem) { - val community = item as HomeFollowingNewsUiItem.Content + val community = item as HomeFollowingNewsUiItem.Community val feedItem = FeedItem.Community( feedId = community.newsId, creatorId = community.targetId.toString(), creatorName = community.creatorNickname, creatorImageUrl = community.creatorProfileImageUrl, - postId = community.targetId.toString(), - bodyText = community.body.ifBlank { community.title }, + postId = community.postId.toString(), + bodyText = community.content, keywordText = "", createdAtText = community.visibleFromText, - commentCount = 0, - likeCount = 0, - imageUrl = community.thumbnailImageUrl + commentCount = community.commentCount, + likeCount = community.likeCount, + imageUrl = community.imageUrl ) view.setFeedSize(feedSize(FeedVariant.Community, parent)) view.bind(feedItem) @@ -146,9 +150,9 @@ class HomeFollowingNewsAdapter( creatorId = content.targetId.toString(), creatorName = content.creatorNickname, creatorImageUrl = content.creatorProfileImageUrl, - contentId = content.targetId.toString(), + contentId = content.contentId.toString(), contentTitle = content.title, - contentImageUrl = content.thumbnailImageUrl.orEmpty(), + contentImageUrl = content.contentImageUrl.orEmpty(), createdAtText = content.visibleFromText, category = content.type.toFeedContentCategory() ) diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index b45a22a9..01b857e5 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -313,6 +313,7 @@ On Air Photo %1$s reached %2$s in this week\'s ranking! + %1$s reached %2$s in this week\'s ranking! No following news to show. Could not load following news. Live diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 97529c08..69f2b41a 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -313,6 +313,7 @@ On Air グラビア %1$sさんが今週のランキング%2$sに入りました! + %1$sが今週のランキング%2$sに入りました! 表示できるフォロー中のお知らせがありません。 フォロー中のお知らせを読み込めませんでした。 ライブ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4936642a..1da09dda 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -312,6 +312,7 @@ On Air 화보 %1$s님이 이번 주 랭킹 %2$s에 올랐어요! + %1$s 콘텐츠가 이번 주 랭킹 %2$s에 올랐어요! 표시할 팔로잉 소식이 없습니다. 팔로잉 소식을 불러오지 못했습니다. 라이브