fix(widget): 캐릭터 채팅 썸네일 clipping을 Kotlin에서 설정한다

This commit is contained in:
2026-06-02 19:34:19 +09:00
parent a5b4d5046d
commit 4629ef00a9
3 changed files with 34 additions and 8 deletions

View File

@@ -33,8 +33,7 @@ class CharacterChatThumbnailView @JvmOverloads constructor(
characterNameText = findViewById(R.id.tv_character_chat_name)
characterDescriptionText = findViewById(R.id.tv_character_chat_description)
originalTitleText = findViewById(R.id.tv_character_chat_original_title)
clipToOutline = true
outlineProvider = roundedCardOutlineProvider()
setCardOutline()
}
fun bind(item: CharacterChatThumbnailItem) {
@@ -63,10 +62,12 @@ class CharacterChatThumbnailView @JvmOverloads constructor(
isClickable = listener != null
}
private fun roundedCardOutlineProvider() = object : ViewOutlineProvider() {
private fun setCardOutline() {
clipToOutline = true
outlineProvider = object : ViewOutlineProvider() {
override fun getOutline(view: View, outline: Outline) {
val radius = resources.getDimension(R.dimen.radius_14)
outline.setRoundRect(0, 0, view.width, view.height, radius)
outline.setRoundRect(0, 0, view.width, view.height, resources.getDimension(R.dimen.radius_14))
}
}
}
}

View File

@@ -3,8 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="185dp"
android:layout_height="wrap_content"
android:background="@drawable/bg_character_chat_thumbnail"
android:clipToOutline="true">
android:background="@drawable/bg_character_chat_thumbnail">
<ImageView
android:id="@+id/iv_character_chat_thumbnail_image"

View File

@@ -10,7 +10,9 @@ import androidx.test.core.app.ApplicationProvider
import kr.co.vividnext.sodalive.R
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@@ -51,6 +53,30 @@ class CharacterChatThumbnailViewTest {
assertSame(view.findViewById<ImageView>(R.id.iv_character_chat_thumbnail_image), view.imageView())
}
@Test
@Config(sdk = [23])
fun `card clipping is configured from Kotlin outline provider`() {
val view = inflateView()
assertTrue(view.clipToOutline)
assertNotNull(view.outlineProvider)
}
@Test
fun `layout does not declare xml clipToOutline`() {
val context = ApplicationProvider.getApplicationContext<Context>()
val parser = context.resources.getXml(R.layout.view_character_chat_thumbnail)
while (parser.eventType != org.xmlpull.v1.XmlPullParser.START_TAG) {
parser.next()
}
val hasClipToOutline = (0 until parser.attributeCount).any { index ->
parser.getAttributeName(index) == "clipToOutline"
}
assertFalse(hasClipToOutline)
}
@Test
fun `setOnCharacterClick invokes listener with bound item`() {
val view = inflateView()