refactor(home): 추천 활동 타입을 공용 타입으로 교체한다
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package kr.co.vividnext.sodalive.v2.main.home.model
|
package kr.co.vividnext.sodalive.v2.main.home.model
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import kr.co.vividnext.sodalive.v2.common.CreatorActivityType
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.data.HomeActiveCreatorItem
|
import kr.co.vividnext.sodalive.v2.main.home.data.HomeActiveCreatorItem
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.data.HomeAiCharacterItem
|
import kr.co.vividnext.sodalive.v2.main.home.data.HomeAiCharacterItem
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.data.HomeBannerItem
|
import kr.co.vividnext.sodalive.v2.main.home.data.HomeBannerItem
|
||||||
@@ -15,7 +16,7 @@ import kr.co.vividnext.sodalive.v2.widget.characterchatthumbnail.CharacterChatTh
|
|||||||
import kr.co.vividnext.sodalive.v2.widget.feed.FeedItem
|
import kr.co.vividnext.sodalive.v2.widget.feed.FeedItem
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
fun String.toRecommendedActivityTypeLabelRes(): Int? = RecommendedActivityType.from(this)?.labelResId
|
fun String.toCreatorActivityTypeLabelRes(): Int? = CreatorActivityType.from(this)?.labelResId
|
||||||
|
|
||||||
fun HomeRecommendationResponse.toContent(): HomeRecommendationUiState.Content = HomeRecommendationUiState.Content(
|
fun HomeRecommendationResponse.toContent(): HomeRecommendationUiState.Content = HomeRecommendationUiState.Content(
|
||||||
lives = HomeRecommendationLiveSection(lives.map { it.toUiModel() }),
|
lives = HomeRecommendationLiveSection(lives.map { it.toUiModel() }),
|
||||||
@@ -44,12 +45,12 @@ fun HomeBannerItem.toUiModel(): HomeRecommendationBannerUiModel = HomeRecommenda
|
|||||||
)
|
)
|
||||||
|
|
||||||
fun HomeActiveCreatorItem.toUiModel(): HomeRecommendationRecentlyActiveCreatorUiModel {
|
fun HomeActiveCreatorItem.toUiModel(): HomeRecommendationRecentlyActiveCreatorUiModel {
|
||||||
val recommendedActivityType = RecommendedActivityType.from(activityType)
|
val creatorActivityType = CreatorActivityType.from(activityType)
|
||||||
return HomeRecommendationRecentlyActiveCreatorUiModel(
|
return HomeRecommendationRecentlyActiveCreatorUiModel(
|
||||||
nickname = creatorNickname,
|
nickname = creatorNickname,
|
||||||
profileImage = creatorProfileImage,
|
profileImage = creatorProfileImage,
|
||||||
activityType = recommendedActivityType,
|
activityType = creatorActivityType,
|
||||||
activityLabelResId = recommendedActivityType?.labelResId,
|
activityLabelResId = creatorActivityType?.labelResId,
|
||||||
activityAt = activityAt,
|
activityAt = activityAt,
|
||||||
targetId = targetId
|
targetId = targetId
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import kr.co.vividnext.sodalive.explorer.profile.UserProfileActivity
|
|||||||
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.CreatorCommunityAllActivity
|
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.CreatorCommunityAllActivity
|
||||||
import kr.co.vividnext.sodalive.settings.event.EventDetailActivity
|
import kr.co.vividnext.sodalive.settings.event.EventDetailActivity
|
||||||
import kr.co.vividnext.sodalive.settings.event.EventItem
|
import kr.co.vividnext.sodalive.settings.event.EventItem
|
||||||
|
import kr.co.vividnext.sodalive.v2.common.CreatorActivityType
|
||||||
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
|
import kr.co.vividnext.sodalive.v2.widget.feed.FeedItem
|
||||||
@@ -133,7 +134,7 @@ private fun homeRecommendationAppLinkHost(): String = "${BuildConfig.APPSCHEME}.
|
|||||||
data class HomeRecommendationRecentlyActiveCreatorUiModel(
|
data class HomeRecommendationRecentlyActiveCreatorUiModel(
|
||||||
val nickname: String,
|
val nickname: String,
|
||||||
val profileImage: String,
|
val profileImage: String,
|
||||||
val activityType: RecommendedActivityType?,
|
val activityType: CreatorActivityType?,
|
||||||
val activityLabelResId: Int?,
|
val activityLabelResId: Int?,
|
||||||
val activityAt: String,
|
val activityAt: String,
|
||||||
val targetId: Long?
|
val targetId: Long?
|
||||||
@@ -149,10 +150,10 @@ fun HomeRecommendationRecentlyActiveCreatorUiModel.toHomeRecommendationRecentlyA
|
|||||||
HomeRecommendationRecentlyActiveCreatorRoute? {
|
HomeRecommendationRecentlyActiveCreatorRoute? {
|
||||||
val routeTargetId = targetId?.takeIf { it > 0 } ?: return null
|
val routeTargetId = targetId?.takeIf { it > 0 } ?: return null
|
||||||
return when (activityType) {
|
return when (activityType) {
|
||||||
RecommendedActivityType.Live -> null
|
CreatorActivityType.Live -> null
|
||||||
RecommendedActivityType.LiveReplay,
|
CreatorActivityType.LiveReplay,
|
||||||
RecommendedActivityType.Audio -> HomeRecommendationRecentlyActiveCreatorRoute.AudioContent(routeTargetId)
|
CreatorActivityType.Audio -> HomeRecommendationRecentlyActiveCreatorRoute.AudioContent(routeTargetId)
|
||||||
RecommendedActivityType.Community -> HomeRecommendationRecentlyActiveCreatorRoute.Community(routeTargetId)
|
CreatorActivityType.Community -> HomeRecommendationRecentlyActiveCreatorRoute.Community(routeTargetId)
|
||||||
null -> null
|
null -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package kr.co.vividnext.sodalive.v2.main.home.model
|
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
|
||||||
import kr.co.vividnext.sodalive.R
|
|
||||||
|
|
||||||
enum class RecommendedActivityType(
|
|
||||||
val code: String,
|
|
||||||
@StringRes val labelResId: Int
|
|
||||||
) {
|
|
||||||
Live("LIVE", R.string.home_recommendation_activity_live),
|
|
||||||
LiveReplay("LIVE_REPLAY", R.string.home_recommendation_activity_live),
|
|
||||||
Audio("AUDIO", R.string.home_recommendation_activity_audio),
|
|
||||||
Community("COMMUNITY", R.string.home_recommendation_activity_community);
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun from(code: String): RecommendedActivityType? = entries.firstOrNull { it.code.equals(code, ignoreCase = true) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
package kr.co.vividnext.sodalive.v2.main.home
|
package kr.co.vividnext.sodalive.v2.main.home
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.R
|
import kr.co.vividnext.sodalive.R
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.toRecommendedActivityTypeLabelRes
|
import kr.co.vividnext.sodalive.v2.main.home.model.toCreatorActivityTypeLabelRes
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertNull
|
import org.junit.Assert.assertNull
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class RecommendedActivityTypeTest {
|
class HomeCreatorActivityTypeLabelResTest {
|
||||||
@Test
|
@Test
|
||||||
fun `LIVE maps to live label`() {
|
fun `LIVE maps to live label`() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
R.string.home_recommendation_activity_live,
|
R.string.home_recommendation_activity_live,
|
||||||
"LIVE".toRecommendedActivityTypeLabelRes()
|
"LIVE".toCreatorActivityTypeLabelRes()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ class RecommendedActivityTypeTest {
|
|||||||
fun `LIVE_REPLAY maps to live label`() {
|
fun `LIVE_REPLAY maps to live label`() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
R.string.home_recommendation_activity_live,
|
R.string.home_recommendation_activity_live,
|
||||||
"LIVE_REPLAY".toRecommendedActivityTypeLabelRes()
|
"LIVE_REPLAY".toCreatorActivityTypeLabelRes()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ class RecommendedActivityTypeTest {
|
|||||||
fun `AUDIO maps to audio label`() {
|
fun `AUDIO maps to audio label`() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
R.string.home_recommendation_activity_audio,
|
R.string.home_recommendation_activity_audio,
|
||||||
"AUDIO".toRecommendedActivityTypeLabelRes()
|
"AUDIO".toCreatorActivityTypeLabelRes()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ class RecommendedActivityTypeTest {
|
|||||||
fun `COMMUNITY maps to community label`() {
|
fun `COMMUNITY maps to community label`() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
R.string.home_recommendation_activity_community,
|
R.string.home_recommendation_activity_community,
|
||||||
"COMMUNITY".toRecommendedActivityTypeLabelRes()
|
"COMMUNITY".toCreatorActivityTypeLabelRes()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ class RecommendedActivityTypeTest {
|
|||||||
fun `lowercase activity type maps to matching label`() {
|
fun `lowercase activity type maps to matching label`() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
R.string.home_recommendation_activity_live,
|
R.string.home_recommendation_activity_live,
|
||||||
"live".toRecommendedActivityTypeLabelRes()
|
"live".toCreatorActivityTypeLabelRes()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,12 +51,12 @@ class RecommendedActivityTypeTest {
|
|||||||
fun `mixed case activity type maps to matching label`() {
|
fun `mixed case activity type maps to matching label`() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
R.string.home_recommendation_activity_live,
|
R.string.home_recommendation_activity_live,
|
||||||
"Live_RePlay".toRecommendedActivityTypeLabelRes()
|
"Live_RePlay".toCreatorActivityTypeLabelRes()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `unknown activity type maps to null`() {
|
fun `unknown activity type maps to null`() {
|
||||||
assertNull("UNKNOWN".toRecommendedActivityTypeLabelRes())
|
assertNull("UNKNOWN".toCreatorActivityTypeLabelRes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationPopularComm
|
|||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationPaidStatus
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationPaidStatus
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationRecentlyActiveCreatorRoute
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationRecentlyActiveCreatorRoute
|
||||||
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.RecommendedActivityType
|
import kr.co.vividnext.sodalive.v2.common.CreatorActivityType
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.toHomeRecommendationBannerIntent
|
import kr.co.vividnext.sodalive.v2.main.home.model.toHomeRecommendationBannerIntent
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.toHomeRecommendationBannerRoute
|
import kr.co.vividnext.sodalive.v2.main.home.model.toHomeRecommendationBannerRoute
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.toHomeRecommendationRecentlyActiveCreatorIntent
|
import kr.co.vividnext.sodalive.v2.main.home.model.toHomeRecommendationRecentlyActiveCreatorIntent
|
||||||
@@ -1035,17 +1035,17 @@ class HomeMainFragmentLayoutTest {
|
|||||||
fun `home recent activity route maps activity type to target destination`() {
|
fun `home recent activity route maps activity type to target destination`() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
HomeRecommendationRecentlyActiveCreatorRoute.AudioContent(11L),
|
HomeRecommendationRecentlyActiveCreatorRoute.AudioContent(11L),
|
||||||
recentActivityCreator(RecommendedActivityType.LiveReplay, targetId = 11L)
|
recentActivityCreator(CreatorActivityType.LiveReplay, targetId = 11L)
|
||||||
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
HomeRecommendationRecentlyActiveCreatorRoute.AudioContent(12L),
|
HomeRecommendationRecentlyActiveCreatorRoute.AudioContent(12L),
|
||||||
recentActivityCreator(RecommendedActivityType.Audio, targetId = 12L)
|
recentActivityCreator(CreatorActivityType.Audio, targetId = 12L)
|
||||||
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
HomeRecommendationRecentlyActiveCreatorRoute.Community(13L),
|
HomeRecommendationRecentlyActiveCreatorRoute.Community(13L),
|
||||||
recentActivityCreator(RecommendedActivityType.Community, targetId = 13L)
|
recentActivityCreator(CreatorActivityType.Community, targetId = 13L)
|
||||||
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1054,7 +1054,7 @@ class HomeMainFragmentLayoutTest {
|
|||||||
fun `home recent activity route ignores live unknown and missing target`() {
|
fun `home recent activity route ignores live unknown and missing target`() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
null,
|
null,
|
||||||
recentActivityCreator(RecommendedActivityType.Live, targetId = 10L)
|
recentActivityCreator(CreatorActivityType.Live, targetId = 10L)
|
||||||
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@@ -1063,12 +1063,12 @@ class HomeMainFragmentLayoutTest {
|
|||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
null,
|
null,
|
||||||
recentActivityCreator(RecommendedActivityType.Audio, targetId = null)
|
recentActivityCreator(CreatorActivityType.Audio, targetId = null)
|
||||||
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
null,
|
null,
|
||||||
recentActivityCreator(RecommendedActivityType.Community, targetId = 0L)
|
recentActivityCreator(CreatorActivityType.Community, targetId = 0L)
|
||||||
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
.toHomeRecommendationRecentlyActiveCreatorRoute()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1406,7 +1406,7 @@ class HomeMainFragmentLayoutTest {
|
|||||||
val projectRoot = java.io.File("..").canonicalFile
|
val projectRoot = java.io.File("..").canonicalFile
|
||||||
return java.io.File(
|
return java.io.File(
|
||||||
projectRoot,
|
projectRoot,
|
||||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/HomeMainFragment.kt"
|
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragment.kt"
|
||||||
).readText()
|
).readText()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1517,7 +1517,7 @@ class HomeMainFragmentLayoutTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun recentActivityCreator(
|
private fun recentActivityCreator(
|
||||||
activityType: RecommendedActivityType?,
|
activityType: CreatorActivityType?,
|
||||||
targetId: Long?
|
targetId: Long?
|
||||||
): HomeRecommendationRecentlyActiveCreatorUiModel {
|
): HomeRecommendationRecentlyActiveCreatorUiModel {
|
||||||
return HomeRecommendationRecentlyActiveCreatorUiModel(
|
return HomeRecommendationRecentlyActiveCreatorUiModel(
|
||||||
|
|||||||
Reference in New Issue
Block a user