fix(content): 콘텐츠 랭킹 순위 표시를 보완한다
This commit is contained in:
@@ -116,17 +116,12 @@ class ContentRankingHorizontalCardView @JvmOverloads constructor(
|
|||||||
private fun positionViews(size: ContentRankingCardSize) {
|
private fun positionViews(size: ContentRankingCardSize) {
|
||||||
val scale = size.widthPx / 374f
|
val scale = size.widthPx / 374f
|
||||||
requireNotNull(rankGroup).layoutParams = LayoutParams(
|
requireNotNull(rankGroup).layoutParams = LayoutParams(
|
||||||
(49 * scale).roundToInt(),
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
).apply {
|
).apply {
|
||||||
leftMargin = (14 * scale).roundToInt()
|
leftMargin = (14 * scale).roundToInt()
|
||||||
topMargin = (14 * scale).roundToInt()
|
topMargin = (14 * scale).roundToInt()
|
||||||
}
|
}
|
||||||
requireNotNull(rankText).layoutParams = android.widget.LinearLayout.LayoutParams(
|
|
||||||
(48 * scale).roundToInt(),
|
|
||||||
(52 * scale).roundToInt()
|
|
||||||
)
|
|
||||||
requireNotNull(rankText).setPadding(0, 0, 0, (4 * scale).roundToInt())
|
|
||||||
requireNotNull(rankText).applyContentRankingRankGradient()
|
requireNotNull(rankText).applyContentRankingRankGradient()
|
||||||
imageView().layoutParams = LayoutParams((80 * scale).roundToInt(), (80 * scale).roundToInt()).apply {
|
imageView().layoutParams = LayoutParams((80 * scale).roundToInt(), (80 * scale).roundToInt()).apply {
|
||||||
leftMargin = (77 * scale).roundToInt()
|
leftMargin = (77 * scale).roundToInt()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/ll_content_ranking_rank_group"
|
android:id="@+id/ll_content_ranking_rank_group"
|
||||||
android:layout_width="49dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|||||||
@@ -75,22 +75,18 @@ class ContentRankingCardViewTest {
|
|||||||
val view = inflateView<ContentRankingHorizontalCardView>(R.layout.view_content_ranking_horizontal_card)
|
val view = inflateView<ContentRankingHorizontalCardView>(R.layout.view_content_ranking_horizontal_card)
|
||||||
|
|
||||||
view.setCardSize(ContentRankingCardSize(widthPx = 374, heightPx = 100))
|
view.setCardSize(ContentRankingCardSize(widthPx = 374, heightPx = 100))
|
||||||
|
view.bind(sampleItem(rank = 20))
|
||||||
|
|
||||||
val rankGroup = view.findViewById<View>(R.id.ll_content_ranking_rank_group)
|
val rankGroup = view.findViewById<View>(R.id.ll_content_ranking_rank_group)
|
||||||
val rankGroupParams = rankGroup.layoutParams as ViewGroup.MarginLayoutParams
|
val rankGroupParams = rankGroup.layoutParams as ViewGroup.MarginLayoutParams
|
||||||
assertEquals(49, rankGroupParams.width)
|
assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, rankGroupParams.width)
|
||||||
assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, rankGroupParams.height)
|
assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, rankGroupParams.height)
|
||||||
assertEquals(14, rankGroupParams.leftMargin)
|
assertEquals(14, rankGroupParams.leftMargin)
|
||||||
assertEquals(14, rankGroupParams.topMargin)
|
assertEquals(14, rankGroupParams.topMargin)
|
||||||
|
|
||||||
assertRankTextBox(
|
val rankText = view.findViewById<TextView>(R.id.tv_content_ranking_rank)
|
||||||
view = view.findViewById(R.id.tv_content_ranking_rank),
|
assertEquals("20", rankText.text.toString())
|
||||||
expectedWidth = 48,
|
assertRankTextWrapContent(rankText)
|
||||||
expectedHeight = 52,
|
|
||||||
expectedLeft = 0,
|
|
||||||
expectedTop = 0,
|
|
||||||
expectedBottomPadding = 4
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -188,6 +184,14 @@ class ContentRankingCardViewTest {
|
|||||||
assertEquals(expectedBottomPadding, view.paddingBottom)
|
assertEquals(expectedBottomPadding, view.paddingBottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun assertRankTextWrapContent(view: TextView) {
|
||||||
|
val params = view.layoutParams as ViewGroup.MarginLayoutParams
|
||||||
|
assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, params.width)
|
||||||
|
assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, params.height)
|
||||||
|
assertEquals(Gravity.CENTER, view.gravity)
|
||||||
|
assertEquals(false, view.includeFontPadding)
|
||||||
|
}
|
||||||
|
|
||||||
private fun sampleItem(
|
private fun sampleItem(
|
||||||
rank: Int = 1,
|
rank: Int = 1,
|
||||||
showRankChange: Boolean = true
|
showRankChange: Boolean = true
|
||||||
|
|||||||
Reference in New Issue
Block a user