Google ads integration.
Player ads research with ad tag
This commit is contained in:
@@ -12,5 +12,10 @@ enum class ForPage(val value: String) {
|
||||
FM("fm"),
|
||||
GAME_INTERSTITIAL("game-interestial"),
|
||||
GAME_PLAYER("game-web-view"),
|
||||
KARAOKE_PLAYER("karaoke-player");
|
||||
KARAOKE_PLAYER("karaoke-player"),
|
||||
|
||||
MY_LIST_AND_NOTIFICATION("my-list"),
|
||||
MORE("more"),
|
||||
LIVE_TV_ADS("live-tv-ad"),
|
||||
WEB_SERIES_VIDEO_ADS("web-series-video-ad");
|
||||
}
|
||||
@@ -329,7 +329,7 @@ class MyListFragment : Fragment() {
|
||||
private fun loadGoogleAds() {
|
||||
lifecycleScope.launch {
|
||||
AdsRepository.getADs()?.let { ads ->
|
||||
val fmAds = ads.filter { it.slug == ForPage.FM.value }
|
||||
val fmAds = ads.filter { it.slug == ForPage.MY_LIST_AND_NOTIFICATION.value }
|
||||
|
||||
if (fmAds.isNotEmpty()){
|
||||
fmAds.first().google_ad?.let {
|
||||
|
||||
@@ -5,11 +5,18 @@ import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.google.android.gms.ads.AdRequest
|
||||
import com.google.android.gms.ads.AdSize
|
||||
import com.google.android.gms.ads.AdView
|
||||
import com.woka.R
|
||||
import com.woka.advertisements.AdsRepository
|
||||
import com.woka.advertisements.models.ForPage
|
||||
import com.woka.audiobooks.views.AudioBooksActivity
|
||||
import com.woka.database.helpers.ClicksHelper
|
||||
import com.woka.database.models.ContentType
|
||||
import com.woka.databinding.ActivityNotificationsBinding
|
||||
import com.woka.googleads.FM
|
||||
import com.woka.karaoke.views.KaraokeActivity
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.shop.views.ShopActivity
|
||||
@@ -19,6 +26,7 @@ import com.woka.utils.lightStatusBar
|
||||
import com.woka.utils.show
|
||||
import com.woka.webseries.views.WebSeriesActivity
|
||||
import com.woka.wokagames.views.GamesActivity
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class NotificationsActivity : WokaBaseActivity() {
|
||||
|
||||
@@ -49,6 +57,7 @@ class NotificationsActivity : WokaBaseActivity() {
|
||||
|
||||
NotificationRepository.loadNotifications()
|
||||
|
||||
loadGoogleAds()
|
||||
}
|
||||
|
||||
private fun initViews() {
|
||||
@@ -128,4 +137,29 @@ class NotificationsActivity : WokaBaseActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadGoogleAds() {
|
||||
lifecycleScope.launch {
|
||||
AdsRepository.getADs()?.let { ads ->
|
||||
val fmAds = ads.filter { it.slug == ForPage.MY_LIST_AND_NOTIFICATION.value }
|
||||
|
||||
if (fmAds.isNotEmpty()){
|
||||
fmAds.first().google_ad?.let {
|
||||
val adView = AdView(this@NotificationsActivity)
|
||||
|
||||
adView.adUnitId = FM
|
||||
adView.setAdSize(AdSize(AdSize.FULL_WIDTH, 60))
|
||||
|
||||
binding.adsContainer.removeAllViews()
|
||||
binding.adsContainer.addView(adView)
|
||||
|
||||
adView.loadAd(
|
||||
AdRequest.Builder()
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import android.view.WindowManager
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.media3.common.MediaItem
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator
|
||||
import com.google.android.gms.ads.AdRequest
|
||||
@@ -19,10 +20,13 @@ import com.google.android.gms.ads.AdView
|
||||
import com.jwplayer.pub.api.media.playlists.PlaylistItem
|
||||
import com.woka.R
|
||||
import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.advertisements.AdsRepository
|
||||
import com.woka.advertisements.models.ForPage
|
||||
import com.woka.database.helpers.ClicksHelper
|
||||
import com.woka.database.models.ContentType
|
||||
import com.woka.databinding.ActivityMoreHomeBinding
|
||||
import com.woka.databinding.DialogBlogsBinding
|
||||
import com.woka.googleads.FM
|
||||
import com.woka.googleads.MORE_ACTIVITY
|
||||
import com.woka.modules.blogs.BlogsAdapter
|
||||
import com.woka.modules.blogs.BlogsRepository
|
||||
@@ -37,6 +41,7 @@ import com.woka.utils.WokaBaseActivity
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.lightStatusBar
|
||||
import com.woka.utils.show
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
class MoreHomeActivity : WokaBaseActivity() {
|
||||
@@ -92,18 +97,32 @@ class MoreHomeActivity : WokaBaseActivity() {
|
||||
}
|
||||
|
||||
private fun loadGoogleAds() {
|
||||
// ad container 1
|
||||
val adView1 = AdView(this)
|
||||
adView1.adUnitId = MORE_ACTIVITY
|
||||
adView1.setAdSize(AdSize(AdSize.FULL_WIDTH, 200))
|
||||
lifecycleScope.launch {
|
||||
AdsRepository.getADs()?.let { ads ->
|
||||
val fmAds = ads.filter { it.slug == ForPage.MORE.value }
|
||||
|
||||
binding.adsContainer.removeAllViews()
|
||||
binding.adsContainer.addView(adView1)
|
||||
if (fmAds.isNotEmpty()){
|
||||
fmAds.first().google_ad?.let {
|
||||
val adView1 = AdView(this@MoreHomeActivity)
|
||||
adView1.adUnitId = MORE_ACTIVITY
|
||||
adView1.setAdSize(AdSize(AdSize.FULL_WIDTH, 200))
|
||||
|
||||
adView1.loadAd(
|
||||
AdRequest.Builder()
|
||||
.build()
|
||||
)
|
||||
binding.adsContainer.removeAllViews()
|
||||
binding.adsContainer.addView(adView1)
|
||||
|
||||
adView1.loadAd(
|
||||
AdRequest.Builder()
|
||||
.build()
|
||||
)
|
||||
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.comingSoonCard.show()
|
||||
binding.comingSoonTxt.show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initBlogDialog(){
|
||||
|
||||
@@ -12,6 +12,7 @@ import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.jwplayer.pub.api.JWPlayer
|
||||
import com.jwplayer.pub.api.PauseReason
|
||||
import com.jwplayer.pub.api.PlayReason
|
||||
@@ -32,6 +33,9 @@ import com.woka.userdata.userDataModels.VideoViewRequestData
|
||||
import com.woka.utils.WokaBaseActivity
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.show
|
||||
import com.woka.utils.toast
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
private const val TAG = "PlayerActivity_TAG"
|
||||
@@ -177,17 +181,17 @@ class PlayerActivity : WokaBaseActivity(), FullscreenHandler {
|
||||
|
||||
adSchedule.add(
|
||||
AdBreak.Builder()
|
||||
.tag("https://pubads.g.doubleclick.net/gampad/ads?iu=/23204950200/VideoAd&description_url=https%3A%2F%2Fwokaland.com%2F&tfcd=0&npa=0&ad_type=audio_video&sz=640x480%7C1280x720&gdfp_req=1&unviewed_position_start=1&output=vast&env=vp&impl=s&correlator=")
|
||||
.tag("https://pubads.g.doubleclick.net/gampad/ads?iu=/23204950200/testingvideo&description_url=https%3A%2F%2Fwokaland.com&tfcd=0&npa=0&sz=640x180%7C1280x720%7C1280x720&min_ad_duration=0&max_ad_duration=30000&gdfp_req=1&unviewed_position_start=1&output=vast&env=vp&impl=s&correlator=&vad_type=linear")
|
||||
.offset("pre")
|
||||
.build()
|
||||
)
|
||||
|
||||
adSchedule.add(
|
||||
AdBreak.Builder()
|
||||
.tag("https://pubads.g.doubleclick.net/gampad/live/ads?iu=/23204950200/VideoAd&description_url=https%3A%2F%2Fwokaland.com%2F&tfcd=0&npa=0&ad_type=audio_video&sz=640x480%7C1280x720&gdfp_req=1&unviewed_position_start=1&output=vast&env=vp&impl=s&correlator=&nofb=1")
|
||||
.offset("25%")
|
||||
.build()
|
||||
)
|
||||
// adSchedule.add(
|
||||
// AdBreak.Builder()
|
||||
// .tag("https://pubads.g.doubleclick.net/gampad/live/ads?iu=/23204950200/testingvideo&description_url=https%3A%2F%2Fwokaland.com&tfcd=0&npa=0&sz=640x180%7C1280x720%7C1280x720&gdfp_req=1&unviewed_position_start=1&output=vast&env=vp&impl=s&correlator=")
|
||||
// .offset("25%")
|
||||
// .build()
|
||||
// )
|
||||
|
||||
val imaAdvertising = ImaAdvertisingConfig.Builder()
|
||||
.schedule(adSchedule)
|
||||
|
||||
@@ -127,7 +127,7 @@ class ShopActivity : WokaBaseActivity() {
|
||||
private fun loadGoogleAds() {
|
||||
lifecycleScope.launch {
|
||||
AdsRepository.getADs()?.let { ads ->
|
||||
val fmAds = ads.filter { it.slug == ForPage.FM.value }
|
||||
val fmAds = ads.filter { it.slug == ForPage.SHOP_SUPER_CATEGORY.value }
|
||||
|
||||
if (fmAds.isNotEmpty()){
|
||||
fmAds.first().google_ad?.let {
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
/>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/coming_soon_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
|
||||
@@ -69,14 +69,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
||||
android:visibility="visible"
|
||||
android:visibility="gone"
|
||||
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/notification_view_holder"
|
||||
|
||||
android:layout_marginTop="10dp"
|
||||
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/ads_container"
|
||||
app:layout_constraintTop_toBottomOf="@id/progress_bar"
|
||||
|
||||
/>
|
||||
@@ -174,4 +174,13 @@
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ads_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -49,7 +49,7 @@
|
||||
android:layout_height="0dp"
|
||||
android:background="#D3EFF8"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
||||
app:layout_constraintBottom_toTopOf="@id/ads_container"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
>
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
@@ -75,18 +75,15 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/ads_container"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
||||
android:layout_marginBottom="15dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:paddingTop="0dp"
|
||||
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
@@ -477,17 +474,16 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ads_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:layout_marginBottom="25dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ads_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:layout_marginBottom="20dp"
|
||||
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user