parent
fef49a0d6a
commit
108eb759ec
|
@ -40,8 +40,8 @@ android {
|
|||
applicationId "kr.co.vividnext.sodalive"
|
||||
minSdk 23
|
||||
targetSdk 33
|
||||
versionCode 63
|
||||
versionName "1.10.5"
|
||||
versionCode 64
|
||||
versionName "1.10.0"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
|
|
@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import kr.co.vividnext.sodalive.audio_content.series.detail.SeriesDetailActivity
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.common.Constants
|
||||
import kr.co.vividnext.sodalive.common.GridSpacingItemDecoration
|
||||
import kr.co.vividnext.sodalive.common.DifferentSpacingItemDecoration
|
||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.databinding.ActivitySeriesListAllBinding
|
||||
import org.koin.android.ext.android.inject
|
||||
|
@ -58,15 +58,18 @@ class SeriesListAllActivity : BaseActivity<ActivitySeriesListAllBinding>(
|
|||
)
|
||||
|
||||
val spanCount = 3
|
||||
val spacing = 20
|
||||
val horizontalSpacing = 20
|
||||
val verticalSpacing = 100
|
||||
val recyclerView = binding.rvSeriesAll
|
||||
recyclerView.layoutManager = GridLayoutManager(this, spanCount)
|
||||
|
||||
recyclerView.addItemDecoration(
|
||||
GridSpacingItemDecoration(
|
||||
spanCount,
|
||||
spacing,
|
||||
true
|
||||
DifferentSpacingItemDecoration(
|
||||
spanCount = spanCount,
|
||||
horizontalSpacing = horizontalSpacing,
|
||||
verticalSpacing = verticalSpacing,
|
||||
includeEdge = true
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package kr.co.vividnext.sodalive.common
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class DifferentSpacingItemDecoration(
|
||||
private val spanCount: Int,
|
||||
private val horizontalSpacing: Int,
|
||||
private val verticalSpacing: Int,
|
||||
private val includeEdge: Boolean
|
||||
) : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
val position = parent.getChildAdapterPosition(view) // 아이템의 위치
|
||||
val column = position % spanCount // 아이템의 열 위치
|
||||
|
||||
if (includeEdge) {
|
||||
outRect.left = horizontalSpacing - column * horizontalSpacing / spanCount
|
||||
outRect.right = (column + 1) * horizontalSpacing / spanCount
|
||||
|
||||
if (position < spanCount) {
|
||||
outRect.top = verticalSpacing
|
||||
}
|
||||
outRect.bottom = verticalSpacing
|
||||
} else {
|
||||
outRect.left = column * horizontalSpacing / spanCount
|
||||
outRect.right = horizontalSpacing - (column + 1) * horizontalSpacing / spanCount
|
||||
|
||||
if (position >= spanCount) {
|
||||
outRect.top = verticalSpacing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,8 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/black">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
|
|
Loading…
Reference in New Issue