feat(chat-original): 원작 상세 화면 및 캐릭터 무한 스크롤 로딩 구현

This commit is contained in:
2025-09-15 18:57:26 +09:00
parent f15c6be1a4
commit dcde2b125e
18 changed files with 796 additions and 21 deletions

View File

@@ -5,11 +5,14 @@ import android.view.View
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
/**
* Grid 간격 데코레이션. 헤더가 있는 경우 headerCount로 보정하여 첫 행 판단 및 컬럼 계산을 정확히 수행한다.
*/
class GridSpacingItemDecoration(
private val spanCount: Int,
private val spacing: Int,
private val includeEdge: Boolean
private val includeEdge: Boolean,
private val headerCount: Int = 0
) : ItemDecoration() {
override fun getItemOffsets(
outRect: Rect,
@@ -17,19 +20,26 @@ class GridSpacingItemDecoration(
parent: RecyclerView,
state: RecyclerView.State
) {
val position = parent.getChildAdapterPosition(view) // Item position
val column = position % spanCount // Current column
val position = parent.getChildAdapterPosition(view)
// 헤더 범위는 간격을 적용하지 않음
val adjustedPosition = position - headerCount
if (adjustedPosition < 0) {
outRect.set(0, 0, 0, 0)
return
}
val column = adjustedPosition % spanCount
if (includeEdge) {
outRect.left = spacing - column * spacing / spanCount
outRect.right = (column + 1) * spacing / spanCount
if (position < spanCount) { // Top edge
if (adjustedPosition < spanCount) { // Top edge (헤더 제외 첫 행)
outRect.top = spacing
}
outRect.bottom = spacing // Item bottom
} else {
outRect.left = column * spacing / spanCount
outRect.right = spacing - (column + 1) * spacing / spanCount
if (position >= spanCount) {
if (adjustedPosition >= spanCount) {
outRect.top = spacing // Item top
}
}