广告开关
This commit is contained in:
parent
f56455c269
commit
383b0a2be3
|
|
@ -12,6 +12,7 @@ import com.gamedog.vididin.beans.RecordGold
|
|||
import com.gamedog.vididin.core.login.login.AccountManager
|
||||
import com.viddin.videos.free.R
|
||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||
import com.gamedog.vididin.manager.TestingManager
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlin.getValue
|
||||
import com.viddin.videos.free.databinding.ActivityVersionBinding as ViewBinding
|
||||
|
|
@ -63,16 +64,14 @@ class VersionActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
|||
|
||||
|
||||
// ad
|
||||
val isRewardAdDisable = SpUtil.instance().getBoolean(SpUtil.KEY_TESTING_REWARD_AD_DISABLE)
|
||||
val isNormalAdDisable = SpUtil.instance().getBoolean(SpUtil.KEY_TESTING_REWARD_AD_DISABLE)
|
||||
checkerRewardAd.isChecked = isRewardAdDisable
|
||||
checkerNormalAd.isChecked = isNormalAdDisable
|
||||
checkerRewardAd.isChecked = TestingManager.instance().isRewardAdDisable()
|
||||
checkerNormalAd.isChecked = TestingManager.instance().isNormalAdDisable()
|
||||
|
||||
checkerRewardAd.setOnCheckedChangeListener {_, isChecked ->
|
||||
SpUtil.instance().putBoolean(SpUtil.KEY_TESTING_REWARD_AD_DISABLE, !isChecked)
|
||||
SpUtil.instance().putBoolean(SpUtil.KEY_TESTING_REWARD_AD_DISABLE, isChecked)
|
||||
}
|
||||
checkerNormalAd.setOnCheckedChangeListener {_, isChecked ->
|
||||
SpUtil.instance().putBoolean(SpUtil.KEY_TESTING_NORMAL_AD_DISABLE, !isChecked)
|
||||
SpUtil.instance().putBoolean(SpUtil.KEY_TESTING_NORMAL_AD_DISABLE, isChecked)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,12 @@ import com.gamedog.vididin.VidiConst
|
|||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.beans.WatchAdNotifyBean
|
||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||
import com.gamedog.vididin.manager.TestingManager
|
||||
import com.gamedog.vididin.manager.WithdrawItem
|
||||
import com.remax.bill.ads.AdResult
|
||||
import com.remax.bill.ads.ext.AdShowExt
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import com.viddin.videos.free.databinding.ActivityWatchAdBinding as ViewBinding
|
||||
|
||||
|
|
@ -39,7 +41,6 @@ class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyl
|
|||
with(binding) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun ViewBinding.initWindowInsets() {
|
||||
|
|
@ -51,12 +52,7 @@ class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyl
|
|||
}
|
||||
|
||||
override fun ViewBinding.initListeners() {
|
||||
/*onBackPressedDispatcher.addCallback(this@WatchAdActivity) {
|
||||
AndroidUtil.showToast("Can't exit while watching video")
|
||||
}*/
|
||||
|
||||
stateCounter()
|
||||
|
||||
showVideoAd()
|
||||
}
|
||||
|
||||
|
|
@ -174,27 +170,34 @@ class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyl
|
|||
|
||||
|
||||
private fun showVideoAd() {
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
when(AdShowExt.showRewardedVideoAd(this@WatchAdActivity, { rewardedData ->
|
||||
mRewardedDollarNum = rewardedData.rewardNum
|
||||
}, {
|
||||
notifyAdWatchFinish()
|
||||
})) {
|
||||
is AdResult.Success -> {
|
||||
val temp = 111
|
||||
}
|
||||
if (TestingManager.instance().isRewardAdDisable()) {
|
||||
lifecycleScope.launch {
|
||||
delay(2000)
|
||||
notifyAdWatchFinish()
|
||||
}
|
||||
} else {
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
when(AdShowExt.showRewardedVideoAd(this@WatchAdActivity, { rewardedData ->
|
||||
mRewardedDollarNum = rewardedData.rewardNum
|
||||
}, {
|
||||
notifyAdWatchFinish()
|
||||
})) {
|
||||
is AdResult.Success -> {
|
||||
val temp = 111
|
||||
}
|
||||
|
||||
is AdResult.Failure -> {
|
||||
val temp = 111
|
||||
}
|
||||
is AdResult.Failure -> {
|
||||
val temp = 111
|
||||
}
|
||||
|
||||
AdResult.Loading -> {
|
||||
val temp = 111
|
||||
AdResult.Loading -> {
|
||||
val temp = 111
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ class HomeFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnSwit
|
|||
}, false)
|
||||
|
||||
|
||||
//viewPager2.offscreenPageLimit = 3
|
||||
viewPager2.offscreenPageLimit = 3
|
||||
}
|
||||
|
||||
override fun ViewBinding.initObservers() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
package com.gamedog.vididin.manager
|
||||
|
||||
|
||||
import com.ama.core.architecture.util.SpUtil
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
|
||||
|
||||
|
||||
class TestingManager private constructor() {
|
||||
|
||||
private val mBgScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
|
||||
|
||||
companion object {
|
||||
@Volatile
|
||||
private var instance: TestingManager? = null
|
||||
fun instance(): TestingManager {
|
||||
return instance ?: synchronized(this) {
|
||||
instance ?: TestingManager().also {
|
||||
instance = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun isRewardAdDisable(): Boolean {
|
||||
return SpUtil.instance().getBoolean(SpUtil.KEY_TESTING_REWARD_AD_DISABLE)
|
||||
}
|
||||
|
||||
fun isNormalAdDisable(): Boolean {
|
||||
return SpUtil.instance().getBoolean(SpUtil.KEY_TESTING_NORMAL_AD_DISABLE)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@
|
|||
android:id="@+id/checker_reward_ad"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="关闭插屏广告"
|
||||
android:text="关闭激励广告"
|
||||
/>
|
||||
|
||||
|
||||
|
|
@ -124,7 +124,8 @@
|
|||
android:id="@+id/checker_normal_ad"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="关闭激励广告"
|
||||
android:text="关闭插屏广告"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
Loading…
Reference in New Issue