feat(home): 인기 커뮤니티 섹션을 바인딩한다
This commit is contained in:
@@ -19,7 +19,9 @@ import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationGenreCreato
|
|||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationGenreCreatorSection
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationGenreCreatorSection
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationLiveSection
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationLiveSection
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationLiveUiModel
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationLiveUiModel
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationPaidStatus
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationPopularCommunityPostSection
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationPopularCommunityPostSection
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationPopularCommunityPostUiModel
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationRecentlyActiveCreatorSection
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationRecentlyActiveCreatorSection
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationRecentlyActiveCreatorUiModel
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationRecentlyActiveCreatorUiModel
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationRecentDebutCreatorSection
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationRecentDebutCreatorSection
|
||||||
@@ -32,10 +34,12 @@ import kr.co.vividnext.sodalive.v2.main.home.ui.HomeCheerCreatorAdapter
|
|||||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeFirstAudioAdapter
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeFirstAudioAdapter
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeGenreCreatorAdapter
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeGenreCreatorAdapter
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeLiveAdapter
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeLiveAdapter
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomePopularCommunityAdapter
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeRecentActivityCreatorAdapter
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeRecentActivityCreatorAdapter
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeRecentDebutCreatorAdapter
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeRecentDebutCreatorAdapter
|
||||||
import kr.co.vividnext.sodalive.v2.widget.AudioContentTag
|
import kr.co.vividnext.sodalive.v2.widget.AudioContentTag
|
||||||
import kr.co.vividnext.sodalive.v2.widget.characterchatthumbnail.CharacterChatThumbnailItem
|
import kr.co.vividnext.sodalive.v2.widget.characterchatthumbnail.CharacterChatThumbnailItem
|
||||||
|
import kr.co.vividnext.sodalive.v2.widget.feed.FeedItem
|
||||||
|
|
||||||
class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||||
FragmentV2MainHomeBinding::inflate
|
FragmentV2MainHomeBinding::inflate
|
||||||
@@ -47,6 +51,7 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
|||||||
private val aiCharacterAdapter = HomeAiCharacterAdapter()
|
private val aiCharacterAdapter = HomeAiCharacterAdapter()
|
||||||
private val genreCreatorAdapter = HomeGenreCreatorAdapter { creatorIds -> onGenreFollowAllClick(creatorIds) }
|
private val genreCreatorAdapter = HomeGenreCreatorAdapter { creatorIds -> onGenreFollowAllClick(creatorIds) }
|
||||||
private val cheerCreatorAdapter = HomeCheerCreatorAdapter { creatorIds -> onCheerFollowAllClick(creatorIds) }
|
private val cheerCreatorAdapter = HomeCheerCreatorAdapter { creatorIds -> onCheerFollowAllClick(creatorIds) }
|
||||||
|
private val popularCommunityAdapter = HomePopularCommunityAdapter { }
|
||||||
private var bannerBinder: HomeBannerBinder? = null
|
private var bannerBinder: HomeBannerBinder? = null
|
||||||
private var onGenreFollowAllClick: (List<Long>) -> Unit = {}
|
private var onGenreFollowAllClick: (List<Long>) -> Unit = {}
|
||||||
private var onCheerFollowAllClick: (List<Long>) -> Unit = {}
|
private var onCheerFollowAllClick: (List<Long>) -> Unit = {}
|
||||||
@@ -82,6 +87,10 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
|||||||
layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||||
adapter = cheerCreatorAdapter
|
adapter = cheerCreatorAdapter
|
||||||
}
|
}
|
||||||
|
binding.rvHomePopularCommunityPosts.apply {
|
||||||
|
layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
adapter = popularCommunityAdapter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindHomeRecommendationContent(content: HomeRecommendationUiState.Content) {
|
private fun bindHomeRecommendationContent(content: HomeRecommendationUiState.Content) {
|
||||||
@@ -139,6 +148,7 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
|||||||
|
|
||||||
private fun bindPopularCommunitySection(section: HomeRecommendationPopularCommunityPostSection) {
|
private fun bindPopularCommunitySection(section: HomeRecommendationPopularCommunityPostSection) {
|
||||||
binding.llHomePopularCommunitySection.visibility = section.items.toSectionVisibility()
|
binding.llHomePopularCommunitySection.visibility = section.items.toSectionVisibility()
|
||||||
|
popularCommunityAdapter.submitSection(section)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpSectionTitles() {
|
private fun setUpSectionTitles() {
|
||||||
@@ -241,9 +251,72 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
cheerCreators = HomeRecommendationCheerCreatorSection(sampleCreators(701L, count = 8)),
|
cheerCreators = HomeRecommendationCheerCreatorSection(sampleCreators(701L, count = 8)),
|
||||||
popularCommunityPosts = HomeRecommendationPopularCommunityPostSection(emptyList())
|
popularCommunityPosts = HomeRecommendationPopularCommunityPostSection(samplePopularCommunityPosts())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private fun samplePopularCommunityPosts(): List<HomeRecommendationPopularCommunityPostUiModel> {
|
||||||
|
return listOf(
|
||||||
|
samplePopularCommunityPost(
|
||||||
|
id = 801L,
|
||||||
|
creatorName = "소다",
|
||||||
|
bodyText = "무료 커뮤니티 게시글 샘플입니다. 이미지 영역과 본문, 댓글/좋아요 영역을 함께 확인합니다.",
|
||||||
|
imageUrl = "https://picsum.photos/seed/sodalive-community-free/692/472",
|
||||||
|
price = 0,
|
||||||
|
existOrdered = false,
|
||||||
|
paidStatus = HomeRecommendationPaidStatus.Free
|
||||||
|
),
|
||||||
|
samplePopularCommunityPost(
|
||||||
|
id = 802L,
|
||||||
|
creatorName = "라임",
|
||||||
|
bodyText = "유료 미구매 커뮤니티 게시글 샘플입니다. 원본 이미지는 로드하지 않고 lock overlay와 가격만 표시합니다.",
|
||||||
|
imageUrl = "https://picsum.photos/seed/sodalive-community-locked/692/472",
|
||||||
|
price = 30,
|
||||||
|
existOrdered = false,
|
||||||
|
paidStatus = HomeRecommendationPaidStatus.Paid(30)
|
||||||
|
),
|
||||||
|
samplePopularCommunityPost(
|
||||||
|
id = 803L,
|
||||||
|
creatorName = "하루",
|
||||||
|
bodyText = "구매 완료 커뮤니티 게시글 샘플입니다. 유료지만 overlay 없이 이미지를 표시합니다.",
|
||||||
|
imageUrl = "https://picsum.photos/seed/sodalive-community-purchased/692/472",
|
||||||
|
price = 50,
|
||||||
|
existOrdered = true,
|
||||||
|
paidStatus = HomeRecommendationPaidStatus.Purchased
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun samplePopularCommunityPost(
|
||||||
|
id: Long,
|
||||||
|
creatorName: String,
|
||||||
|
bodyText: String,
|
||||||
|
imageUrl: String,
|
||||||
|
price: Int,
|
||||||
|
existOrdered: Boolean,
|
||||||
|
paidStatus: HomeRecommendationPaidStatus
|
||||||
|
): HomeRecommendationPopularCommunityPostUiModel {
|
||||||
|
return HomeRecommendationPopularCommunityPostUiModel(
|
||||||
|
item = FeedItem.Community(
|
||||||
|
feedId = "sample-community-$id",
|
||||||
|
creatorId = "sample-creator-$id",
|
||||||
|
creatorName = creatorName,
|
||||||
|
creatorImageUrl = "",
|
||||||
|
postId = id.toString(),
|
||||||
|
bodyText = bodyText,
|
||||||
|
keywordText = "",
|
||||||
|
createdAtText = "방금",
|
||||||
|
commentCount = 5,
|
||||||
|
likeCount = 12,
|
||||||
|
imageUrl = imageUrl,
|
||||||
|
audioUrl = "https://example.com/sample-community-$id.m4a",
|
||||||
|
price = price,
|
||||||
|
existOrdered = existOrdered,
|
||||||
|
showKeyword = false
|
||||||
|
),
|
||||||
|
paidStatus = paidStatus
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun sampleCreators(startId: Long, count: Int = 3): List<HomeRecommendationCreatorUiModel> {
|
private fun sampleCreators(startId: Long, count: Int = 3): List<HomeRecommendationCreatorUiModel> {
|
||||||
return List(count) { index ->
|
return List(count) { index ->
|
||||||
HomeRecommendationCreatorUiModel(startId + index, "크리에이터${index + 1}", null)
|
HomeRecommendationCreatorUiModel(startId + index, "크리에이터${index + 1}", null)
|
||||||
|
|||||||
@@ -210,9 +210,10 @@
|
|||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/rv_home_popular_community_posts"
|
android:id="@+id/rv_home_popular_community_posts"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="180dp"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:clipToPadding="false"
|
||||||
android:paddingHorizontal="@dimen/spacing_20"
|
android:orientation="vertical"
|
||||||
|
android:paddingHorizontal="@dimen/spacing_14"
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user