feat(creator): 후원 랭킹 레이아웃을 보정한다
This commit is contained in:
+24
@@ -1,6 +1,9 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.donation.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@@ -65,6 +68,9 @@ class CreatorChannelDonationAdapter(
|
||||
|
||||
init {
|
||||
binding.rvCreatorChannelDonationRankingMembers.layoutManager = GridLayoutManager(itemView.context, 4)
|
||||
binding.rvCreatorChannelDonationRankingMembers.addItemDecoration(
|
||||
CreatorChannelDonationRankingItemDecoration(itemView.context, spanCount = 4)
|
||||
)
|
||||
binding.rvCreatorChannelDonationRankingMembers.adapter = rankingAdapter
|
||||
binding.btnCreatorChannelDonationRankingAll.setOnClickListener { onRankingAllClick() }
|
||||
}
|
||||
@@ -106,3 +112,21 @@ private sealed interface CreatorChannelDonationListItem {
|
||||
data class Ranking(val rankings: List<CreatorChannelDonationRankingUiModel>) : CreatorChannelDonationListItem
|
||||
data class Donation(val donation: CreatorChannelDonationUiModel) : CreatorChannelDonationListItem
|
||||
}
|
||||
|
||||
private class CreatorChannelDonationRankingItemDecoration(
|
||||
context: Context,
|
||||
private val spanCount: Int
|
||||
) : RecyclerView.ItemDecoration() {
|
||||
|
||||
private val spacing: Int = (14 * context.resources.displayMetrics.density).toInt()
|
||||
|
||||
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
|
||||
val position = parent.getChildAdapterPosition(view)
|
||||
if (position == RecyclerView.NO_POSITION) return
|
||||
|
||||
val column = position % spanCount
|
||||
outRect.left = column * spacing / spanCount
|
||||
outRect.right = spacing - (column + 1) * spacing / spanCount
|
||||
outRect.top = if (position >= spanCount) spacing else 0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user