탐색 - 광고 배너 추가

This commit is contained in:
2023-09-16 01:12:31 +09:00
parent 90df714a44
commit 42613dfc76
3 changed files with 29 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ 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
@@ -25,9 +26,21 @@ class ExplorerAdapter(
private val context: Context,
private val binding: ItemExplorerBinding
) : RecyclerView.ViewHolder(binding.root) {
fun bind(item: GetExplorerSectionResponse) {
fun bind(item: GetExplorerSectionResponse, index: Int) {
setTitle(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) {
@@ -108,7 +121,7 @@ class ExplorerAdapter(
)
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bind(items[position])
holder.bind(items[position], index = position)
}
override fun getItemCount() = items.size