From 42613dfc76eee15727cb1d4a8890d3c5364a61d5 Mon Sep 17 00:00:00 2001 From: klaus Date: Sat, 16 Sep 2023 01:12:31 +0900 Subject: [PATCH] =?UTF-8?q?=ED=83=90=EC=83=89=20-=20=EA=B4=91=EA=B3=A0=20?= =?UTF-8?q?=EB=B0=B0=EB=84=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 ++ .../sodalive/explorer/ExplorerAdapter.kt | 17 +++++++++++++++-- app/src/main/res/layout/item_explorer.xml | 12 ++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f18e887..55dd6e7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 { diff --git a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerAdapter.kt b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerAdapter.kt index 64a7883..e53022d 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerAdapter.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerAdapter.kt @@ -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 diff --git a/app/src/main/res/layout/item_explorer.xml b/app/src/main/res/layout/item_explorer.xml index d8fc6e4..6e1808a 100644 --- a/app/src/main/res/layout/item_explorer.xml +++ b/app/src/main/res/layout/item_explorer.xml @@ -1,5 +1,6 @@ + +