탐색 - 광고 배너 추가
This commit is contained in:
parent
90df714a44
commit
42613dfc76
|
@ -64,6 +64,7 @@ android {
|
|||
resValue 'string', 'admob_live_now_all_list_banner_unit_id', 'ca-app-pub-1299501215847962/7226255534'
|
||||
resValue 'string', 'admob_creator_channel_banner_unit_id', 'ca-app-pub-1299501215847962/4594592451'
|
||||
resValue 'string', 'admob_message_banner_unit_id', 'ca-app-pub-1299501215847962/1161494343'
|
||||
resValue 'string', 'admob_explorer_banner_unit_id', 'ca-app-pub-1299501215847962/6200754952'
|
||||
}
|
||||
|
||||
debug {
|
||||
|
@ -87,6 +88,7 @@ android {
|
|||
resValue 'string', 'admob_live_now_all_list_banner_unit_id', 'ca-app-pub-3940256099942544/6300978111'
|
||||
resValue 'string', 'admob_creator_channel_banner_unit_id', 'ca-app-pub-3940256099942544/6300978111'
|
||||
resValue 'string', 'admob_message_banner_unit_id', 'ca-app-pub-3940256099942544/6300978111'
|
||||
resValue 'string', 'admob_explorer_banner_unit_id', 'ca-app-pub-3940256099942544/6300978111'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?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"
|
||||
|
@ -29,4 +30,15 @@
|
|||
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_creator_channel_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" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
Loading…
Reference in New Issue