激励广告 revence 值回调
This commit is contained in:
parent
c981ffe950
commit
cef3efaa4e
|
|
@ -16,6 +16,7 @@ import com.gamedog.vididin.VididinEvents
|
||||||
import com.gamedog.vididin.beans.WatchAdNotifyBean
|
import com.gamedog.vididin.beans.WatchAdNotifyBean
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
import com.gamedog.vididin.manager.WithdrawItemBean
|
import com.gamedog.vididin.manager.WithdrawItemBean
|
||||||
|
import com.remax.bill.ads.AdResult
|
||||||
import com.remax.bill.ads.ext.AdShowExt
|
import com.remax.bill.ads.ext.AdShowExt
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
@ -27,6 +28,7 @@ import com.vididin.real.money.game.databinding.ActivityWatchAdBinding as ViewBin
|
||||||
class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyleListener {
|
class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyleListener {
|
||||||
|
|
||||||
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
||||||
|
private var mRewardedDollarNum: Float = 0F
|
||||||
override var mEnableBannerAd = false
|
override var mEnableBannerAd = false
|
||||||
|
|
||||||
private lateinit var mCountDownTimer: CountDownTimer
|
private lateinit var mCountDownTimer: CountDownTimer
|
||||||
|
|
@ -159,7 +161,22 @@ class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyl
|
||||||
private fun showVideoAd() {
|
private fun showVideoAd() {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
try {
|
try {
|
||||||
AdShowExt.showRewardedVideoAd(this@WatchAdActivity, null)
|
when(AdShowExt.showRewardedVideoAd(this@WatchAdActivity, { rewardedData ->
|
||||||
|
mRewardedDollarNum = rewardedData.rewardNum
|
||||||
|
})) {
|
||||||
|
is AdResult.Success -> {
|
||||||
|
val temp = 111
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
is AdResult.Failure -> {
|
||||||
|
val temp = 111
|
||||||
|
}
|
||||||
|
|
||||||
|
AdResult.Loading -> {
|
||||||
|
val temp = 111
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.google.android.gms.ads.rewarded.RewardItem
|
|
||||||
import com.remax.bill.BuildConfig
|
import com.remax.bill.BuildConfig
|
||||||
import com.remax.bill.ads.AdResult
|
import com.remax.bill.ads.AdResult
|
||||||
import com.remax.bill.ads.AppOpenAdController
|
import com.remax.bill.ads.AppOpenAdController
|
||||||
|
|
@ -295,7 +294,7 @@ object AdShowExt {
|
||||||
*/
|
*/
|
||||||
suspend fun showRewardedVideoAd(
|
suspend fun showRewardedVideoAd(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
rewardCallback: ((RewardItem) -> Unit)? = null
|
rewardCallback: ((CommonRewardedData) -> Unit)? = null
|
||||||
): AdResult<Unit> {
|
): AdResult<Unit> {
|
||||||
AdLogger.d("激励视频广告竞价开始")
|
AdLogger.d("激励视频广告竞价开始")
|
||||||
val winner = RewardedBiddingManager.bidding(activity)
|
val winner = RewardedBiddingManager.bidding(activity)
|
||||||
|
|
@ -306,24 +305,36 @@ object AdShowExt {
|
||||||
AdLogger.d("使用 AdMob 展示激励视频广告")
|
AdLogger.d("使用 AdMob 展示激励视频广告")
|
||||||
RewardedAdController.getInstance().showAd(
|
RewardedAdController.getInstance().showAd(
|
||||||
activity,
|
activity,
|
||||||
"",
|
BuildConfig.ADMOB_REWARDED_ID,
|
||||||
rewardCallback
|
{ rewardItem ->
|
||||||
|
val rewardedData = CommonRewardedData(rewardItem.amount.toFloat())
|
||||||
|
rewardCallback?.invoke(rewardedData)
|
||||||
|
AdLogger.e("AdMob激励视频奖励回调, 奖励值:${rewardItem.amount}")
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
BiddingWinner.PANGLE -> {
|
BiddingWinner.PANGLE -> {
|
||||||
AdLogger.d("使用 Pangle 展示激励视频广告")
|
AdLogger.d("使用 Pangle 展示激励视频广告")
|
||||||
PangleRewardedAdController.getInstance().showAd(
|
PangleRewardedAdController.getInstance().showAd(
|
||||||
activity,
|
activity,
|
||||||
"",
|
BuildConfig.PANGLE_REWARDED_ID,
|
||||||
null
|
{ pagRewardItem ->
|
||||||
|
val rewardedData = CommonRewardedData(pagRewardItem.rewardAmount.toFloat())
|
||||||
|
rewardCallback?.invoke(rewardedData)
|
||||||
|
AdLogger.e("Pangle激励视频奖励回调, 奖励值:${pagRewardItem.rewardAmount}")
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
BiddingWinner.TOPON -> {
|
BiddingWinner.TOPON -> {
|
||||||
AdLogger.d("使用 TopOn 展示激励视频广告")
|
AdLogger.d("使用 TopOn 展示激励视频广告")
|
||||||
TopOnRewardedAdController.getInstance().showAd(
|
TopOnRewardedAdController.getInstance().showAd(
|
||||||
activity,
|
activity,
|
||||||
"",
|
BuildConfig.TOPON_REWARDED_ID,
|
||||||
null
|
{ _, _, revenueValue ->
|
||||||
|
val rewardedData = CommonRewardedData(revenueValue.toFloat())
|
||||||
|
rewardCallback?.invoke(rewardedData)
|
||||||
|
AdLogger.e("TopOn激励视频奖励回调, 奖励值:$revenueValue")
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.remax.bill.ads.ext
|
||||||
|
|
||||||
|
data class CommonRewardedData (
|
||||||
|
val rewardNum: Float = 0F
|
||||||
|
)
|
||||||
|
|
@ -131,7 +131,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
suspend fun showAd(
|
suspend fun showAd(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
placementId: String? = null,
|
placementId: String? = null,
|
||||||
onRewardEarned: ((String, Int) -> Unit)? = null
|
onRewardEarned: ((String, Int, Double) -> Unit)? = null
|
||||||
): AdResult<Unit> {
|
): AdResult<Unit> {
|
||||||
val finalPlacementId = resolvePlacementId(placementId)
|
val finalPlacementId = resolvePlacementId(placementId)
|
||||||
if (finalPlacementId.isBlank()) {
|
if (finalPlacementId.isBlank()) {
|
||||||
|
|
@ -296,7 +296,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
private var lastAdInfo: TUAdInfo? = null
|
private var lastAdInfo: TUAdInfo? = null
|
||||||
private var cacheTime: Long = System.currentTimeMillis()
|
private var cacheTime: Long = System.currentTimeMillis()
|
||||||
private var hasRewarded: Boolean = false
|
private var hasRewarded: Boolean = false
|
||||||
private var rewardCallback: ((String, Int) -> Unit)? = null
|
private var rewardCallback: ((String, Int, Double) -> Unit)? = null
|
||||||
|
|
||||||
fun attachLoadContinuation(continuation: kotlinx.coroutines.CancellableContinuation<TopOnRewardedAdEntry?>) {
|
fun attachLoadContinuation(continuation: kotlinx.coroutines.CancellableContinuation<TopOnRewardedAdEntry?>) {
|
||||||
loadContinuation = continuation
|
loadContinuation = continuation
|
||||||
|
|
@ -324,7 +324,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
showContinuation = null
|
showContinuation = null
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun awaitShow(activity: Activity, onRewardEarned: ((String, Int) -> Unit)?): AdResult<Unit> {
|
suspend fun awaitShow(activity: Activity, onRewardEarned: ((String, Int, Double) -> Unit)?): AdResult<Unit> {
|
||||||
if (!rewardedVideoAd.isAdReady) {
|
if (!rewardedVideoAd.isAdReady) {
|
||||||
AdLogger.w("TopOn激励广告未准备好,展示终止,广告位ID: %s", placementId)
|
AdLogger.w("TopOn激励广告未准备好,展示终止,广告位ID: %s", placementId)
|
||||||
return AdResult.Failure(createAdException("广告未准备好"))
|
return AdResult.Failure(createAdException("广告未准备好"))
|
||||||
|
|
@ -528,8 +528,11 @@ class TopOnRewardedAdController private constructor() {
|
||||||
"ad_source" to (adInfo.networkName ?: "")
|
"ad_source" to (adInfo.networkName ?: "")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
var revenueValue = 0.0
|
||||||
rewardCallback?.invoke(rewardType, rewardAmount)
|
if ("USD" == adInfo.currency) {
|
||||||
|
revenueValue = adInfo.publisherRevenue ?: 0.0
|
||||||
|
}
|
||||||
|
rewardCallback?.invoke(rewardType, rewardAmount, revenueValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAdRevenuePaid(adInfo: TUAdInfo) {
|
override fun onAdRevenuePaid(adInfo: TUAdInfo) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue