탐색 - 광고 배너 추가
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user