탐색 - 섹션 제목 아래에 description 추가

This commit is contained in:
klaus 2023-10-14 01:38:00 +09:00
parent 2cfc4b97f4
commit 8266167c02
3 changed files with 30 additions and 29 deletions

View File

@ -12,7 +12,6 @@ import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.gms.ads.AdRequest
import kr.co.vividnext.sodalive.databinding.ItemExplorerBinding
import kr.co.vividnext.sodalive.extensions.dpToPx
@ -26,21 +25,10 @@ class ExplorerAdapter(
private val context: Context,
private val binding: ItemExplorerBinding
) : RecyclerView.ViewHolder(binding.root) {
fun bind(item: GetExplorerSectionResponse, index: Int) {
fun bind(item: GetExplorerSectionResponse) {
setTitle(item)
setDesc(item)
setCreatorList(item)
if (index == 1) {
setupAdMob()
} else {
binding.adView.visibility = View.GONE
}
}
private fun setupAdMob() {
val adRequest = AdRequest.Builder().build()
binding.adView.visibility = View.VISIBLE
binding.adView.loadAd(adRequest)
}
private fun setTitle(item: GetExplorerSectionResponse) {
@ -69,6 +57,15 @@ class ExplorerAdapter(
}
}
private fun setDesc(item: GetExplorerSectionResponse) {
if (item.desc != null) {
binding.tvDesc.visibility = View.VISIBLE
binding.tvDesc.text = item.desc
} else {
binding.tvDesc.visibility = View.GONE
}
}
private fun setCreatorList(item: GetExplorerSectionResponse) {
val adapter = ExplorerSectionAdapter(onClickItem = onClickItem)
@ -121,7 +118,7 @@ class ExplorerAdapter(
)
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bind(items[position], index = position)
holder.bind(items[position])
}
override fun getItemCount() = items.size

View File

@ -10,6 +10,7 @@ data class GetExplorerSectionResponse(
@SerializedName("title") val title: String,
@SerializedName("coloredTitle") val coloredTitle: String?,
@SerializedName("color") val color: String?,
@SerializedName("desc") val desc: String?,
@SerializedName("creators") val creators: List<GetExplorerSectionCreatorResponse>
)

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@ -19,6 +18,22 @@
app:layout_constraintTop_toTopOf="parent"
tools:text="인기 급상승" />
<TextView
android:id="@+id/tv_desc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:fontFamily="@font/gmarket_sans_medium"
android:paddingHorizontal="13.3dp"
android:textColor="@color/color_777777"
android:textSize="11sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="@+id/tv_title"
app:layout_constraintStart_toStartOf="@+id/tv_title"
app:layout_constraintTop_toBottomOf="@+id/tv_title"
tools:ignore="SmallSp"
tools:text="큐레이션" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_explorer_section"
android:layout_width="0dp"
@ -28,17 +43,5 @@
android:paddingHorizontal="13.3dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
<com.google.android.gms.ads.AdView
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/admob_explorer_banner_unit_id"
app:layout_constraintEnd_toEndOf="@+id/rv_explorer_section"
app:layout_constraintStart_toStartOf="@+id/rv_explorer_section"
app:layout_constraintTop_toBottomOf="@+id/rv_explorer_section" />
app:layout_constraintTop_toBottomOf="@+id/tv_desc" />
</androidx.constraintlayout.widget.ConstraintLayout>