Commit 980231a8 authored by wanglei's avatar wanglei

...模块化

parent 0a6d5908
......@@ -16,6 +16,7 @@ import com.koko.batteryinfo.databinding.ActivityBatteryInfoBinding
import com.koko.router.ad.InterAdService
import com.koko.router.ad.NativeBatteryType
import com.koko.router.ad.NativeAdService
import com.koko.router.app.AppService
import java.math.BigDecimal
import java.math.RoundingMode
......@@ -47,6 +48,15 @@ class BatteryInfoActivity : BaseActivity<ActivityBatteryInfoBinding>() {
}
}
private fun backMainShowAd() {
val interAdService = DRouter.build(InterAdService::class.java).getService()
val appService = DRouter.build(AppService::class.java).getService()
interAdService.showInterAdBack(this) {
appService.finishToMainTop(this)
}
}
private fun showNative() {
val nativeService = DRouter.build(NativeAdService::class.java).getService()
nativeService.showNative(this, binding.flAd, NativeBatteryType)
......@@ -55,11 +65,7 @@ class BatteryInfoActivity : BaseActivity<ActivityBatteryInfoBinding>() {
override fun initView() {
registerReceiver()
onBackPressedDispatcher.addCallback {
// if (AdmobHelper.isBackShowAd()) {
// AdmobInterstitialUtils.showInterstitialAd(this@com.koko.batteryinfo.BatteryInfoActivity) {
// finishToMain()
// }
// }
backMainShowAd()
}
binding.flBack.setOnClickListener { onBackPressedDispatcher.onBackPressed() }
}
......
......@@ -6,5 +6,7 @@ const val INTER_BATTERY_INFO = "INTER_BATTERY_INFO"
interface InterAdService {
fun showInterAd(activity: Activity, interWhere: String = "", callBack: () -> Unit)
fun showInterAd(activity: Activity, interWhere: String = "", callBack: () -> Unit) = Unit
fun showInterAdBack(activity: Activity, interWhere: String = "", callBack: () -> Unit) = Unit
}
\ No newline at end of file
package com.koko.router.app
import android.app.Activity
interface AppService {
fun eventActivity() = Unit
fun finishToMain() = Unit
fun finishToMainTop(activity: Activity) = Unit
}
\ No newline at end of file
package com.base.appzxhy.drouterimp
import android.app.Activity
import android.content.Intent
import com.base.appzxhy.ui.main.MainActivity
import com.didi.drouter.annotation.Service
import com.koko.router.app.AppService
@Service(function = [AppService::class])
class AppServiceImp : AppService {
override fun finishToMainTop(activity: Activity) {
val intent = Intent(activity, MainActivity::class.java)
intent.putExtra("where", "finishToMainTop")
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
activity.startActivity(intent)
activity.finish()
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.base.appzxhy.drouterimp
import android.app.Activity
import com.base.appzxhy.ads.AdsMgr
import com.base.appzxhy.ads.AdsShowCallBack
import com.base.appzxhy.bean.config.AdConfigBean
import com.didi.drouter.annotation.Service
import com.koko.router.ad.InterAdService
......@@ -13,6 +14,7 @@ class InterAdServiceImp : InterAdService {
val isUnLimit = false
if (AdConfigBean.adsConfigBean.functionInShowAd) {
AdsMgr.showInsert(activity, isUnLimit, object : AdsShowCallBack() {
override fun close(where: Int) {
callBack.invoke()
......@@ -26,6 +28,32 @@ class InterAdServiceImp : InterAdService {
callBack.invoke()
}
})
} else {
callBack.invoke()
}
}
override fun showInterAdBack(activity: Activity, interWhere: String, callBack: () -> Unit) {
val isUnLimit = false
if (AdConfigBean.adsConfigBean.functionBackShowAd) {
AdsMgr.showInsert(activity, isUnLimit, object : AdsShowCallBack() {
override fun close(where: Int) {
callBack.invoke()
}
override fun failed(where: Int) {
callBack.invoke()
}
override fun googleFailed(where: Int) {
callBack.invoke()
}
})
} else {
callBack.invoke()
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment