广告开关
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.gamedog.vididin.core.login.login.AccountManager
|
||||||
import com.viddin.videos.free.R
|
import com.viddin.videos.free.R
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
|
import com.gamedog.vididin.manager.TestingManager
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlin.getValue
|
import kotlin.getValue
|
||||||
import com.viddin.videos.free.databinding.ActivityVersionBinding as ViewBinding
|
import com.viddin.videos.free.databinding.ActivityVersionBinding as ViewBinding
|
||||||
|
|
@ -63,16 +64,14 @@ class VersionActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
|
|
||||||
|
|
||||||
// ad
|
// ad
|
||||||
val isRewardAdDisable = SpUtil.instance().getBoolean(SpUtil.KEY_TESTING_REWARD_AD_DISABLE)
|
checkerRewardAd.isChecked = TestingManager.instance().isRewardAdDisable()
|
||||||
val isNormalAdDisable = SpUtil.instance().getBoolean(SpUtil.KEY_TESTING_REWARD_AD_DISABLE)
|
checkerNormalAd.isChecked = TestingManager.instance().isNormalAdDisable()
|
||||||
checkerRewardAd.isChecked = isRewardAdDisable
|
|
||||||
checkerNormalAd.isChecked = isNormalAdDisable
|
|
||||||
|
|
||||||
checkerRewardAd.setOnCheckedChangeListener {_, isChecked ->
|
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 ->
|
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.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.TestingManager
|
||||||
import com.gamedog.vididin.manager.WithdrawItem
|
import com.gamedog.vididin.manager.WithdrawItem
|
||||||
import com.remax.bill.ads.AdResult
|
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.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import com.viddin.videos.free.databinding.ActivityWatchAdBinding as ViewBinding
|
import com.viddin.videos.free.databinding.ActivityWatchAdBinding as ViewBinding
|
||||||
|
|
||||||
|
|
@ -39,7 +41,6 @@ class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyl
|
||||||
with(binding) {
|
with(binding) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initWindowInsets() {
|
override fun ViewBinding.initWindowInsets() {
|
||||||
|
|
@ -51,12 +52,7 @@ class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyl
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initListeners() {
|
override fun ViewBinding.initListeners() {
|
||||||
/*onBackPressedDispatcher.addCallback(this@WatchAdActivity) {
|
|
||||||
AndroidUtil.showToast("Can't exit while watching video")
|
|
||||||
}*/
|
|
||||||
|
|
||||||
stateCounter()
|
stateCounter()
|
||||||
|
|
||||||
showVideoAd()
|
showVideoAd()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,27 +170,34 @@ class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyl
|
||||||
|
|
||||||
|
|
||||||
private fun showVideoAd() {
|
private fun showVideoAd() {
|
||||||
lifecycleScope.launch {
|
if (TestingManager.instance().isRewardAdDisable()) {
|
||||||
try {
|
lifecycleScope.launch {
|
||||||
when(AdShowExt.showRewardedVideoAd(this@WatchAdActivity, { rewardedData ->
|
delay(2000)
|
||||||
mRewardedDollarNum = rewardedData.rewardNum
|
notifyAdWatchFinish()
|
||||||
}, {
|
}
|
||||||
notifyAdWatchFinish()
|
} else {
|
||||||
})) {
|
lifecycleScope.launch {
|
||||||
is AdResult.Success -> {
|
try {
|
||||||
val temp = 111
|
when(AdShowExt.showRewardedVideoAd(this@WatchAdActivity, { rewardedData ->
|
||||||
}
|
mRewardedDollarNum = rewardedData.rewardNum
|
||||||
|
}, {
|
||||||
|
notifyAdWatchFinish()
|
||||||
|
})) {
|
||||||
|
is AdResult.Success -> {
|
||||||
|
val temp = 111
|
||||||
|
}
|
||||||
|
|
||||||
is AdResult.Failure -> {
|
is AdResult.Failure -> {
|
||||||
val temp = 111
|
val temp = 111
|
||||||
}
|
}
|
||||||
|
|
||||||
AdResult.Loading -> {
|
AdResult.Loading -> {
|
||||||
val temp = 111
|
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)
|
}, false)
|
||||||
|
|
||||||
|
|
||||||
//viewPager2.offscreenPageLimit = 3
|
viewPager2.offscreenPageLimit = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initObservers() {
|
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:id="@+id/checker_reward_ad"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="关闭插屏广告"
|
android:text="关闭激励广告"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -124,7 +124,8 @@
|
||||||
android:id="@+id/checker_normal_ad"
|
android:id="@+id/checker_normal_ad"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="关闭激励广告"
|
android:text="关闭插屏广告"
|
||||||
|
android:visibility="gone"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue