Skip to content

Commit

Permalink
fix: some user reward listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinTeqBlaze authored and Valentin Petrovych committed Oct 15, 2024
1 parent d38d6e4 commit f505764
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class AdMobVideoRewardedActivity : BaseAdActivity() {
override fun onAdLoaded(ad: RewardedAd) {
Log.d("AdMobRewarded", "Ad was loaded.")
rewardedAd = ad
rewardedAd?.show(this@AdMobVideoRewardedActivity) {}
rewardedAd?.show(this@AdMobVideoRewardedActivity) {
Log.d("AdExample", "User earned reward: ${it.amount} ${it.type}")
}
}

override fun onAdFailedToLoad(adError: LoadAdError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.prebid.mobile.prebidkotlindemo.activities.ads.applovin

import android.os.Bundle
import android.util.Log
import com.applovin.mediation.MaxAd
import com.applovin.mediation.MaxError
import com.applovin.mediation.MaxReward
Expand Down Expand Up @@ -56,7 +57,9 @@ class AppLovinMaxVideoRewardedActivity : BaseAdActivity() {
override fun onAdDisplayFailed(ad: MaxAd?, error: MaxError?) {}
override fun onRewardedVideoStarted(ad: MaxAd?) {}
override fun onRewardedVideoCompleted(ad: MaxAd?) {}
override fun onUserRewarded(ad: MaxAd?, reward: MaxReward?) {}
override fun onUserRewarded(ad: MaxAd?, reward: MaxReward?) {
Log.d("AdExample", "User earned reward: $reward")
}
})

val mediationUtils = MaxMediationRewardedUtils(maxRewardedAd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class GamRenderingApiVideoRewardedActivity : BaseAdActivity() {
override fun onAdClicked(rewardedAdUnit: RewardedAdUnit?) {}
override fun onAdClosed(rewardedAdUnit: RewardedAdUnit?) {}
override fun onUserEarnedReward(rewardedAdUnit: RewardedAdUnit?, reward: Reward?) {
Log.d("AdActivity", "User earned reward: $reward")
Log.d("AdExample", "User earned reward: $reward")
}
})
adUnit?.loadAd()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ open class AdMobRewardedFragment : AdFragment() {
val rewardAmount = rewardItem.amount
val rewardType = rewardItem.type
Log.d(TAG, "User earned the reward ($rewardAmount, $rewardType)")
events.rewarded(true)
}
binding.btnLoad.text = getString(R.string.text_retry)
} else if (binding.btnLoad.text == getString(R.string.text_retry)) {
Expand Down Expand Up @@ -155,6 +156,7 @@ open class AdMobRewardedFragment : AdFragment() {
fun impression(b: Boolean) = enable(R.id.btnAdImpression, b)
fun clicked(b: Boolean) = enable(R.id.btnAdClicked, b)
fun failed(b: Boolean) = enable(R.id.btnAdFailed, b)
fun rewarded(b: Boolean) = enable(R.id.btnUserRewarded, b)

fun showed(b: Boolean) = enable(R.id.btnAdShowed, b)
fun dismissed(b: Boolean) = enable(R.id.btnAdDismissed, b)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ abstract class BaseBidRewardedFragment : AdFragment() {
}

override fun onUserEarnedReward(rewardedAdUnit: RewardedAdUnit?, reward: Reward?) {
Log.d(TAG, "User earned reward: $reward")
events.reward(true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package org.prebid.mobile.renderingtestapp.plugplay.bidding.max
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Button
import android.widget.TextView
import com.applovin.mediation.MaxAd
import com.applovin.mediation.MaxError
import com.applovin.mediation.MaxReward
Expand All @@ -17,7 +15,6 @@ import org.prebid.mobile.renderingtestapp.R
import org.prebid.mobile.renderingtestapp.databinding.FragmentBiddingRewardedApplovinMaxBinding
import org.prebid.mobile.renderingtestapp.plugplay.config.AdConfiguratorDialogFragment
import org.prebid.mobile.renderingtestapp.utils.BaseEvents
import org.prebid.mobile.renderingtestapp.widgets.EventCounterView

open class MaxRewardedFragment : AdFragment() {

Expand Down Expand Up @@ -139,6 +136,7 @@ open class MaxRewardedFragment : AdFragment() {
}

override fun onUserRewarded(ad: MaxAd?, reward: MaxReward?) {
Log.d(TAG, "User earned reward: ${reward?.label} ${reward?.amount}")
events.userRewarded(true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ class DemoItemProvider private constructor() {
DemoItem(
getString(R.string.demo_bidding_in_app_display_rewarded_time),
ppmRewardedAction,
ppmInterstitialTagList,
ppmVideoTagList,
createBannerBundle(
R.string.imp_prebid_id_display_rewarded_time,
null,
Expand All @@ -1147,7 +1147,7 @@ class DemoItemProvider private constructor() {
DemoItem(
getString(R.string.demo_bidding_in_app_display_rewarded_event),
ppmRewardedAction,
ppmInterstitialTagList,
ppmVideoTagList,
createBannerBundle(
R.string.imp_prebid_id_display_rewarded_event,
null,
Expand All @@ -1160,7 +1160,7 @@ class DemoItemProvider private constructor() {
DemoItem(
getString(R.string.demo_bidding_in_app_display_rewarded_default),
ppmRewardedAction,
ppmInterstitialTagList,
ppmVideoTagList,
createBannerBundle(
R.string.imp_prebid_id_display_rewarded_default,
null,
Expand All @@ -1173,7 +1173,7 @@ class DemoItemProvider private constructor() {
DemoItem(
getString(R.string.demo_bidding_in_app_video_rewarded_time),
ppmRewardedAction,
ppmInterstitialTagList,
ppmVideoTagList,
createBannerBundle(
R.string.imp_prebid_id_video_rewarded_time,
null,
Expand All @@ -1186,7 +1186,7 @@ class DemoItemProvider private constructor() {
DemoItem(
getString(R.string.demo_bidding_in_app_video_rewarded_event),
ppmRewardedAction,
ppmInterstitialTagList,
ppmVideoTagList,
createBannerBundle(
R.string.imp_prebid_id_video_rewarded_event,
null,
Expand All @@ -1199,7 +1199,7 @@ class DemoItemProvider private constructor() {
DemoItem(
getString(R.string.demo_bidding_in_app_video_rewarded_default),
ppmRewardedAction,
ppmInterstitialTagList,
ppmVideoTagList,
createBannerBundle(
R.string.imp_prebid_id_video_rewarded_default,
null,
Expand All @@ -1212,7 +1212,7 @@ class DemoItemProvider private constructor() {
DemoItem(
getString(R.string.demo_bidding_in_app_video_rewarded_endcard_time),
ppmRewardedAction,
ppmInterstitialTagList,
ppmVideoTagList,
createBannerBundle(
R.string.imp_prebid_id_video_rewarded_endcard_time,
null,
Expand All @@ -1225,7 +1225,7 @@ class DemoItemProvider private constructor() {
DemoItem(
getString(R.string.demo_bidding_in_app_video_rewarded_endcard_event),
ppmRewardedAction,
ppmInterstitialTagList,
ppmVideoTagList,
createBannerBundle(
R.string.imp_prebid_id_video_rewarded_endcard_event,
null,
Expand All @@ -1238,7 +1238,7 @@ class DemoItemProvider private constructor() {
DemoItem(
getString(R.string.demo_bidding_in_app_video_rewarded_endcard_default),
ppmRewardedAction,
ppmInterstitialTagList,
ppmVideoTagList,
createBannerBundle(
R.string.imp_prebid_id_video_rewarded_endcard_default,
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,11 @@
android:text="@string/event_admob_failed"
android:layout_marginTop="@dimen/event_top_margin"/>

<org.prebid.mobile.renderingtestapp.widgets.EventCounterView
android:id="@+id/btnUserRewarded"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/onUserRewarded"
android:layout_marginTop="@dimen/event_top_margin" />

</LinearLayout>

0 comments on commit f505764

Please sign in to comment.