Bladeren bron

增加穿山甲广告SDK

liuxiaolong 2 jaren geleden
bovenliggende
commit
28b873f203
82 gewijzigde bestanden met toevoegingen van 1308 en 218 verwijderingen
  1. 1 0
      app/build.gradle
  2. 1 0
      app/src/main/AndroidManifest.xml
  3. 1 1
      app/src/main/java/com/convenient/android/lib/LibApplication.kt
  4. 9 6
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/AdMainActivity.kt
  5. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AdAppOpenActivity.kt
  6. 16 2
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AdBannerActivity.kt
  7. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AdFullScreenAdActivity.kt
  8. 12 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AdNativeActivity.kt
  9. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AdNativeListActivity.kt
  10. 8 27
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AppWelcomeActivity.kt
  11. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/adapter/NativeAdSampleListAdapter.kt
  12. 13 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/model/Datas.kt
  13. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/model/NativeListBean.kt
  14. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdAppOpenPage.kt
  15. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdBannerPage.kt
  16. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdHomePage.kt
  17. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdInterstitialPage.kt
  18. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdMainPage.kt
  19. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdNativePage.kt
  20. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdRewardVideoPage.kt
  21. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/util/CoilImageLoader.kt
  22. 3 1
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/viewmodel/AdConfigViewModel.kt
  23. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/media/MediaFilesPage.kt
  24. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/media/MediaFilesRepository.kt
  25. 1 1
      app/src/main/java/com/convenient/android/lib/ui/sample/media/MediaFilesViewModel.kt
  26. 0 1
      app/src/main/res/layout/activity_ad_native.xml
  27. 37 0
      app/src/main/res/layout/activity_app_welcome.xml
  28. 1 1
      build.gradle
  29. 0 25
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/bean/AdmobAdUnitBean.kt
  30. 19 0
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/impl/AdmobAdSize.kt
  31. 1 1
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/impl/AdmobInitialize.kt
  32. 3 6
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/AdmobAdLoader.kt
  33. 13 9
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdMobNativeRequestImpl.kt
  34. 19 14
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdmobAppOpenRequestImpl.kt
  35. 22 17
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdmobBannerRequestImpl.kt
  36. 17 14
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdmobInterstitialRequestImpl.kt
  37. 18 14
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdmobRewardInterstitialRequestImpl.kt
  38. 11 7
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdmobRewardRequestImpl.kt
  39. 1 1
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/view/AdmobBannerView.kt
  40. 1 1
      lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/view/AdmobNativeAdView.kt
  41. 4 3
      lib_ad_core/src/main/java/com/composition/android/lib/ad/AdLoad.kt
  42. 1 1
      lib_ad_core/src/main/java/com/composition/android/lib/ad/AdManager.kt
  43. 9 2
      lib_ad_core/src/main/java/com/composition/android/lib/ad/AdUnitConfigManager.kt
  44. 3 1
      lib_ad_core/src/main/java/com/composition/android/lib/ad/basic/Advertisers.kt
  45. 34 0
      lib_ad_core/src/main/java/com/composition/android/lib/ad/basic/BannerAdViewHolder.kt
  46. 4 2
      lib_ad_core/src/main/java/com/composition/android/lib/ad/basic/BasicAdView.kt
  47. 3 0
      lib_ad_core/src/main/java/com/composition/android/lib/ad/basic/NativeAdViewHolder.kt
  48. 1 1
      lib_ad_core/src/main/java/com/composition/android/lib/ad/basic/strategy/IStrategy.kt
  49. 5 4
      lib_ad_core/src/main/java/com/composition/android/lib/ad/bean/AdUnitBean.kt
  50. 1 1
      lib_ad_core/src/main/java/com/composition/android/lib/ad/bean/AdUnitLoadConfig.kt
  51. 1 1
      lib_ad_core/src/main/java/com/composition/android/lib/ad/factory/AdLoaderFactory.kt
  52. 1 1
      lib_ad_core/src/main/java/com/composition/android/lib/ad/factory/AdRequestFactory.kt
  53. 4 3
      lib_ad_core/src/main/java/com/composition/android/lib/ad/impl/Api.kt
  54. 1 1
      lib_ad_core/src/main/java/com/composition/android/lib/ad/impl/NormalStrategy.kt
  55. 2 5
      lib_ad_core/src/main/java/com/composition/android/lib/ad/impl/UnknownAdLoader.kt
  56. 19 18
      lib_ad_core/src/main/java/com/composition/android/lib/ad/interfaces/AdLoader.kt
  57. 1 1
      lib_ad_core/src/main/java/com/composition/android/lib/ad/interfaces/IAdFormatRequest.kt
  58. 13 0
      lib_ad_core/src/main/java/com/composition/android/lib/ad/interfaces/IAdSize.kt
  59. 1 1
      lib_ad_core/src/main/java/com/composition/android/lib/ad/interfaces/Initialize.kt
  60. 17 1
      lib_ad_core/src/main/java/com/composition/android/lib/ad/widget/BannerAdView.kt
  61. 12 2
      lib_ad_core/src/main/java/com/composition/android/lib/ad/widget/NativeAdView.kt
  62. 4 1
      lib_ad_csj/build.gradle
  63. BIN
      lib_ad_csj/libs/open_ad_sdk.aar
  64. 24 0
      lib_ad_csj/src/main/AndroidManifest.xml
  65. 17 0
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/impl/CSJBannerAdSize.kt
  66. 63 0
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/impl/CSJInitialize.kt
  67. 197 0
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/CSJAdLoader.kt
  68. 70 0
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/request/CSJAppOpenRequestImpl.kt
  69. 58 0
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/request/CSJBannerRequestImpl.kt
  70. 68 0
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/request/CSJInterstitialRequestImpl.kt
  71. 60 0
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/request/CSJNativeRequestImpl.kt
  72. 58 0
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/request/CSJRewardRequestImpl.kt
  73. 82 0
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/view/CSJBannerView.kt
  74. 110 0
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/view/CSJNativeAdView.kt
  75. 48 0
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/util/CSJAdExpan.kt
  76. 13 0
      lib_ad_csj/src/main/res/values-zh-rCN/strings.xml
  77. 14 0
      lib_ad_csj/src/main/res/values/strings.xml
  78. 9 0
      lib_ad_csj/src/main/res/xml/ttad_file_paths.xml
  79. 12 0
      lib_common/src/main/java/com/convenient/android/common/config/MyPdfBaseModule.kt
  80. 1 1
      lib_common/src/main/java/com/convenient/android/common/extension/ListExtensions.kt
  81. 5 0
      lib_common/src/main/java/com/convenient/android/common/extension/ScreenExtensions.kt
  82. 15 1
      lib_common/src/main/java/com/convenient/android/common/extension/ViewExtensions.kt

+ 1 - 0
app/build.gradle

@@ -52,6 +52,7 @@ dependencies {
     implementation project(':lib_common')
     implementation project(':lib_ad_core')
     implementation project(':lib_ad_admob')
+    implementation project(':lib_ad_csj')
 
     //compose依赖
     implementation "androidx.compose.ui:ui:$compose_version"

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -17,6 +17,7 @@
         android:requestLegacyExternalStorage="true"
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
+        android:usesCleartextTraffic="true"
         android:theme="@style/Theme.Lib"
         tools:targetApi="31">
 

+ 1 - 1
app/src/main/java/com/convenient/android/lib/LibApplication.kt

@@ -11,7 +11,7 @@ import kotlinx.coroutines.launch
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description:
  */

+ 9 - 6
app/src/main/java/com/convenient/android/lib/ui/sample/ad/AdMainActivity.kt

@@ -10,6 +10,8 @@ import com.convenient.android.lib.ui.sample.ad.model.Datas
 import com.convenient.android.lib.ui.sample.ad.page.AdMainPage
 import com.convenient.android.lib.ui.theme.SampleTheme
 import com.composition.android.ad.admob.impl.AdmobInitialize
+import com.composition.android.ad.csj.impl.CSJInitialize
+import com.composition.android.lib.ad.bean.AdUnitBean
 
 class AdMainActivity : AppCompatActivity() {
     override fun onCreate(savedInstanceState: Bundle?) {
@@ -25,15 +27,16 @@ class AdMainActivity : AppCompatActivity() {
 
 
     private fun initAd(){
-
         AdManager.instance.init(applicationContext, true)
-        AdManager.instance.initAdvertisersSDK(applicationContext, AdmobInitialize())
-        AdUnitConfigManager.instance.setAdUnits(Datas.AdmobAdUnitList)
+        AdManager.instance.initAdvertisersSDK(applicationContext, AdmobInitialize(),CSJInitialize("5320990"))
+        val list = mutableListOf<AdUnitBean>()
+        list.addAll(Datas.AdmobAdUnitList)
+        list.addAll(Datas.CSJAdUnitList)
+        AdUnitConfigManager.instance.setAdUnits(list)
         AdManager.instance.addGlobalAdShowListener {
-
             Log.e("广告全局展示监听", "广告位名称:${it.adSlotName}\n广告商:${it.advertisersName}\n广告id:${it.adUnitId}\n广告类型:${it.adType}")
-
         }
-
     }
+
+
 }

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AdAppOpenActivity.kt

@@ -17,7 +17,7 @@ import kotlinx.coroutines.launch
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/9
  * description:
  */

+ 16 - 2
app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AdBannerActivity.kt

@@ -1,10 +1,14 @@
 package com.convenient.android.lib.ui.sample.ad.activity
 
 import android.os.Bundle
+import androidx.core.view.isVisible
 import androidx.lifecycle.lifecycleScope
 import com.composition.android.lib.ad.AdLoad
 import com.composition.android.lib.ad.AdManager
 import com.composition.android.lib.ad.basic.AdResult
+import com.composition.android.lib.ad.basic.buildBannerAdViewHolder
+import com.composition.android.lib.ad.bean.AdUnitBean
+import com.composition.android.lib.ad.impl.NormalAdListener
 import com.composition.android.lib.ad.util.adLogE
 import com.convenient.android.common.base.viewbinding.BaseBindingActivity
 import com.convenient.android.common.extension.setViewsClick
@@ -17,7 +21,7 @@ import kotlinx.coroutines.launch
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description: 横幅广告示例
  */
@@ -69,9 +73,19 @@ class AdBannerActivity : BaseBindingActivity<ActivityAdBannerBinding>(ActivityAd
 
     private fun showBanner() {
         bannerAdResult?.let {
-            AdLoad.getBannerAdView(this, it)?.let { adView ->
+            AdLoad.getBannerAdView(this, it, buildBannerAdViewHolder {
+                this.activity = this@AdBannerActivity
+                this.adListener = object : NormalAdListener(){
+                    override fun onAdDisLike() {
+                        super.onAdDisLike()
+                        binding.llAdContent.removeAllViews()
+                        binding.llAdContent.isVisible = false
+                    }
+                }
+            })?.let { adView ->
                 binding.llAdContent.removeAllViews()
                 binding.llAdContent.addView(adView)
+                binding.llAdContent.isVisible = true
             }
         } ?: ToastUtil.showLongToast(this, "请先加载广告")
     }

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AdFullScreenAdActivity.kt

@@ -16,7 +16,7 @@ import kotlinx.coroutines.launch
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/8
  * description:
  */

+ 12 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AdNativeActivity.kt

@@ -1,11 +1,13 @@
 package com.convenient.android.lib.ui.sample.ad.activity
 
 import android.os.Bundle
+import androidx.core.view.isVisible
 import androidx.lifecycle.lifecycleScope
 import com.composition.android.lib.ad.AdLoad
 import com.composition.android.lib.ad.AdManager
 import com.composition.android.lib.ad.basic.AdResult
 import com.composition.android.lib.ad.basic.buildAdNativeViewHolder
+import com.composition.android.lib.ad.impl.NormalAdListener
 import com.composition.android.lib.ad.util.adLogE
 import com.convenient.android.common.base.viewbinding.BaseBindingActivity
 import com.convenient.android.common.extension.readyGo
@@ -20,7 +22,7 @@ import kotlinx.coroutines.launch
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description: 横幅广告示例
  */
@@ -86,11 +88,20 @@ class AdNativeActivity : BaseBindingActivity<ActivityAdNativeBinding>(ActivityAd
                 this.iconView = nativeViewBinding.ivAdIcon
                 this.contentMediaGroup = nativeViewBinding.flAdMediaContent
                 this.callActionView = nativeViewBinding.btnCallToAction
+                this.activity= this@AdNativeActivity
+                this.adListener = object : NormalAdListener(){
+                    override fun onAdDisLike() {
+                        super.onAdDisLike()
+                        binding.llAdContent.isVisible = false
+                        binding.llAdContent.removeAllViews()
+                    }
+                }
             }
 
             AdLoad.getNativeAdView(this, it, viewHolder)?.let {
                 binding.llAdContent.removeAllViews()
                 binding.llAdContent.addView(it)
+                binding.llAdContent.isVisible = true
             }
 
         } ?: ToastUtil.showLongToast(this, "请先加载广告")

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AdNativeListActivity.kt

@@ -11,7 +11,7 @@ import kotlinx.coroutines.launch
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/8
  * description:原生广告在RecyclerView中的使用示例
  */

+ 8 - 27
app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AppWelcomeActivity.kt

@@ -15,8 +15,10 @@ import androidx.lifecycle.lifecycleScope
 import com.composition.android.lib.ad.AdLoad
 import com.composition.android.lib.ad.basic.AdResult
 import com.convenient.android.common.base.view.BaseActivity
+import com.convenient.android.common.base.viewbinding.BaseBindingActivity
 import com.convenient.android.common.extension.readyGo
 import com.convenient.android.lib.R
+import com.convenient.android.lib.databinding.ActivityAppWelcomeBinding
 import com.convenient.android.lib.ui.sample.MainActivity
 import com.convenient.android.lib.ui.sample.ad.model.Datas
 import com.convenient.android.lib.ui.theme.SampleTheme
@@ -25,11 +27,11 @@ import kotlinx.coroutines.launch
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/9
  * description:
  */
-class AppWelcomeActivity : BaseActivity() {
+class AppWelcomeActivity : BaseBindingActivity<ActivityAppWelcomeBinding>(ActivityAppWelcomeBinding::inflate) {
 
     companion object {
         const val ONLY_SHOW = "only_show"
@@ -38,9 +40,6 @@ class AppWelcomeActivity : BaseActivity() {
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
-        setContent {
-            WelcomePage()
-        }
 
         lifecycleScope.launch {
 
@@ -66,7 +65,7 @@ class AppWelcomeActivity : BaseActivity() {
             .collect{
                 if (it is AdResult.Success){
                     delay(200)
-                    AdLoad.showSplash(this, null, it){
+                    AdLoad.showSplash(this, binding.llAdContent, it){
                         onAdClose {
                             result.invoke()
                         }
@@ -76,6 +75,9 @@ class AppWelcomeActivity : BaseActivity() {
                         onAdSkip {
                             result.invoke()
                         }
+                        onTimeOver {
+                            result.invoke()
+                        }
                     }
                 }else{
                     result.invoke()
@@ -95,24 +97,3 @@ class AppWelcomeActivity : BaseActivity() {
     }
 }
 
-
-
-@Composable
-fun WelcomePage() {
-
-    Column(modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally) {
-
-        Image(painter = painterResource(id = R.mipmap.ic_launcher), contentDescription = null, modifier = Modifier.size(60.dp))
-        Spacer(modifier = Modifier.padding(vertical = 16.dp))
-        Text(text = "组件Demo")
-    }
-
-}
-
-@Preview(showSystemUi = true)
-@Composable
-fun WelcomePagePreview() {
-    SampleTheme {
-        WelcomePage()
-    }
-}

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/adapter/NativeAdSampleListAdapter.kt

@@ -14,7 +14,7 @@ import com.convenient.android.lib.ui.sample.ad.model.NativeListBean
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/8
  * description:
  */

+ 13 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/model/Datas.kt

@@ -1,6 +1,7 @@
 package com.convenient.android.lib.ui.sample.ad.model
 
 import android.content.Context
+import com.composition.android.ad.csj.impl.CSJBannerAdSize
 import com.composition.android.lib.ad.AdLoad
 import com.composition.android.lib.ad.basic.AdResult
 import com.composition.android.lib.ad.basic.AdType
@@ -14,7 +15,7 @@ import kotlin.random.Random
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description:
  */
@@ -25,6 +26,7 @@ object Datas {
             Advertisers.Admob,
             Advertisers.AppLovin,
             Advertisers.CSJ,
+            Advertisers.GroMore,
             Advertisers.CUSTOM,
         )
     }
@@ -50,6 +52,16 @@ object Datas {
         )
 
 
+    val CSJAdUnitList : List<AdUnitBean> =
+        listOf(
+            AdUnitBean(BANNER, Advertisers.CSJ.name, AdType.BANNER.name, "949726232", adSize = CSJBannerAdSize(600F, 90F)),
+            AdUnitBean(NATIVE, Advertisers.CSJ.name, AdType.NATIVE.name, "949726254"),
+            AdUnitBean(INTERSTITIAL, Advertisers.CSJ.name, AdType.INTERSTITIAL.name, "949726267"),
+            AdUnitBean(REWARDED_VIDEO, Advertisers.CSJ.name, AdType.REWARDED_VIDEO.name, "949726565"),
+            AdUnitBean(APP_OPEN, Advertisers.CSJ.name, AdType.APP_OPEN.name, "887922330", requestAdConfig = AdUnitLoadConfig(adLoadRetryCount = 1, adLoadTimeOut = 5000))
+        )
+
+
     suspend fun getNativeADSampleLists(context: Context): List<NativeListBean> {
 
         val list = mutableListOf<NativeListBean>()

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/model/NativeListBean.kt

@@ -5,7 +5,7 @@ import com.convenient.android.common.media.MediaBean
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/8
  * description:
  */

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdAppOpenPage.kt

@@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description:
  */

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdBannerPage.kt

@@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description:
  */

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdHomePage.kt

@@ -26,7 +26,7 @@ import com.convenient.android.lib.ui.sample.ad.viewmodel.AdConfigViewModel
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description:
  */

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdInterstitialPage.kt

@@ -24,7 +24,7 @@ import kotlinx.coroutines.launch
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description:
  */

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdMainPage.kt

@@ -22,7 +22,7 @@ import com.convenient.android.lib.ui.theme.SampleTheme
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description:
  */

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdNativePage.kt

@@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description:
  */

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdRewardVideoPage.kt

@@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description:
  */

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/util/CoilImageLoader.kt

@@ -9,7 +9,7 @@ import com.composition.android.lib.ad.interfaces.ImageLoader
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/7
  * description:
  */

+ 3 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/viewmodel/AdConfigViewModel.kt

@@ -7,10 +7,11 @@ import com.composition.android.lib.ad.basic.Advertisers
 import com.composition.android.lib.ad.impl.UnknownAdLoader
 import com.composition.android.lib.ad.interfaces.AdLoader
 import com.composition.android.ad.admob.load.AdmobAdLoader
+import com.composition.android.ad.csj.load.CSJAdLoader
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description:
  */
@@ -31,6 +32,7 @@ class AdConfigViewModel : ViewModel() {
     fun getAdLoader(advertisers: Advertisers) : Pair<Advertisers, AdLoader>{
        return when(advertisers){
             Advertisers.Admob-> Advertisers.Admob to AdmobAdLoader()
+           Advertisers.CSJ -> Advertisers.CSJ to CSJAdLoader()
             else-> Advertisers.UNKNOWN to UnknownAdLoader()
         }
     }

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/media/MediaFilesPage.kt

@@ -49,7 +49,7 @@ import com.convenient.android.lib.ui.theme.SampleTheme
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/8/4
  * description:
  */

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/media/MediaFilesRepository.kt

@@ -8,7 +8,7 @@ import com.convenient.android.common.media.scan.MediaStore
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/8/4
  * description:
  * */

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/media/MediaFilesViewModel.kt

@@ -19,7 +19,7 @@ import kotlin.collections.ArrayList
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/8/4
  * description:
  */

+ 0 - 1
app/src/main/res/layout/activity_ad_native.xml

@@ -70,7 +70,6 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             app:native_ad_slot_name="native"
-            android:padding="8dp"
             app:native_admob_advertisers_root_view="@layout/layout_admob_native_ad_view_root"
             app:ad_view_title="@id/tv_ad_title_1"
             app:ad_view_title_desc="@id/tv_ad_title_desc_1"

+ 37 - 0
app/src/main/res/layout/activity_app_welcome.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <androidx.appcompat.widget.AppCompatImageView
+        android:layout_width="70dp"
+        android:layout_height="70dp"
+        android:src="@mipmap/ic_launcher"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        android:id="@+id/iv_icon"
+        app:layout_constraintBottom_toTopOf="@id/tv_name"
+        app:layout_constraintVertical_chainStyle="packed"
+        app:layout_constraintVertical_bias="0.4"
+        />
+
+    <androidx.appcompat.widget.AppCompatTextView
+        android:id="@+id/tv_name"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/app_name"
+        android:layout_marginTop="16dp"
+        app:layout_constraintTop_toBottomOf="@id/iv_icon"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/ll_ad_content"
+        />
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 1 - 1
build.gradle

@@ -9,7 +9,7 @@ buildscript {
 plugins {
     id 'com.android.application' version '7.2.0' apply false
     id 'com.android.library' version '7.2.0' apply false
-    id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
+    id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
 }
 
 

+ 0 - 25
lib_ad_admob/src/main/java/com/composition/android/ad/admob/bean/AdmobAdUnitBean.kt

@@ -1,25 +0,0 @@
-package com.composition.android.ad.admob.bean
-
-import com.composition.android.lib.ad.AdManager
-import com.composition.android.lib.ad.basic.strategy.IStrategy
-import com.composition.android.lib.ad.bean.AdUnitBean
-import com.composition.android.lib.ad.bean.AdUnitLoadConfig
-import com.composition.android.lib.ad.impl.NormalStrategy
-import com.google.android.gms.ads.AdSize
-import com.composition.android.ad.admob.util.getAdSize
-
-/**
- * @classname:
- * @auther: LiuXiaoLong
- * @date: 2022/9/5
- * description:
- */
-class AdmobAdUnitBean(
-    adSlotName: String,
-    advertisersName: String,
-    adType: String,
-    adUnitId: String,
-    var adSize: AdSize = getAdSize(AdManager.instance.context),
-    loadStrategy: IStrategy = NormalStrategy(),
-    requestAdConfig: AdUnitLoadConfig = AdUnitLoadConfig()
-) : AdUnitBean(adSlotName, advertisersName, adType, adUnitId, loadStrategy, requestAdConfig)

+ 19 - 0
lib_ad_admob/src/main/java/com/composition/android/ad/admob/impl/AdmobAdSize.kt

@@ -0,0 +1,19 @@
+package com.composition.android.ad.admob.impl
+
+import com.composition.android.lib.ad.AdManager
+import com.composition.android.lib.ad.interfaces.IAdSize
+import com.google.android.gms.ads.AdSize
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:
+ */
+class AdmobAdSize(var size: AdSize) : IAdSize<AdSize> {
+
+    override fun getAdSize(): AdSize {
+        return size
+    }
+
+}

+ 1 - 1
lib_ad_admob/src/main/java/com/composition/android/ad/admob/impl/AdmobInitialize.kt

@@ -8,7 +8,7 @@ import com.google.android.gms.ads.MobileAds
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/13
  * description: Admob广告初始化
  */

+ 3 - 6
lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/AdmobAdLoader.kt

@@ -5,10 +5,6 @@ import android.content.Context
 import android.view.View
 import android.view.ViewGroup
 import com.composition.android.lib.ad.AdManager
-import com.composition.android.lib.ad.basic.AdResult
-import com.composition.android.lib.ad.basic.AdType
-import com.composition.android.lib.ad.basic.BasicAdView
-import com.composition.android.lib.ad.basic.NativeAdViewHolder
 import com.composition.android.lib.ad.bean.AdUnitBean
 import com.composition.android.lib.ad.interfaces.AdListener
 import com.composition.android.lib.ad.interfaces.AdLoader
@@ -23,10 +19,11 @@ import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd
 import com.composition.android.ad.admob.load.request.*
 import com.composition.android.ad.admob.load.view.AdmobBannerView
 import com.composition.android.ad.admob.load.view.AdmobNativeAdView
+import com.composition.android.lib.ad.basic.*
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description: Admob广告加载类
  */
@@ -51,7 +48,7 @@ class AdmobAdLoader : AdLoader {
         return loadByStrategy(context, adUnitBean, adFormatRequestImpl)
     }
 
-    override fun getBannerView(context: Context, adResult: AdResult.Success): BasicAdView<*>? {
+    override fun getBannerView(context: Context, adResult: AdResult.Success,viewHolder: BannerAdViewHolder): BasicAdView<*>? {
         return if (adResult.adObject != null){
             AdmobBannerView(context).apply {
                 render(adResult)

+ 13 - 9
lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdMobNativeRequestImpl.kt

@@ -15,7 +15,7 @@ import kotlin.coroutines.resume
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description:Admob原生广告加载实现
  */
@@ -28,20 +28,24 @@ class AdMobNativeRequestImpl : IAdFormatRequest{
             val listener: AdListener = object : AdListener() {
                 override fun onAdFailedToLoad(p0: LoadAdError) {
                     printAdInfo(adUnitBean, p0.responseInfo)
-                    it.resume(AdResult.Fail(adUnitBean, msg = p0.message))
+                    if (it.isActive) {
+                        it.resume(AdResult.Fail(adUnitBean, msg = p0.message))
+                    }
                 }
             }
             val adLoader = AdLoader.Builder(context, adUnitBean.adUnitId)
                 .forNativeAd {nativeAd->
                     printAdInfo(adUnitBean, nativeAd.responseInfo)
-                    it.resume(
-                        AdResult.Success(
-                            nativeAd,
-                            adUnitBean,
-                            AdLoadCode.SUCCESS,
-                            "AdMob 原生广告加载成功"
+                    if (it.isActive) {
+                        it.resume(
+                            AdResult.Success(
+                                nativeAd,
+                                adUnitBean,
+                                AdLoadCode.SUCCESS,
+                                "AdMob 原生广告加载成功"
+                            )
                         )
-                    )
+                    }
                 }
                 .withAdListener(listener).build()
             val adRequest = AdRequest.Builder().build()

+ 19 - 14
lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdmobAppOpenRequestImpl.kt

@@ -15,7 +15,7 @@ import kotlin.coroutines.resume
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description:
  */
@@ -28,24 +28,29 @@ class AdmobAppOpenRequestImpl : IAdFormatRequest {
                 object : AppOpenAd.AppOpenAdLoadCallback() {
                     override fun onAdFailedToLoad(p0: LoadAdError) {
                         adLogE(AdManager.TAG, p0.message)
-                        it.resume(
-                            AdResult.Fail(
-                                adUnitBean,
-                                AdLoadCode.FAIL,
-                                p0.message
+                        if (it.isActive) {
+                            it.resume(
+                                AdResult.Fail(
+                                    adUnitBean,
+                                    AdLoadCode.FAIL,
+                                    p0.message
+                                )
                             )
-                        )
+                        }
+
                     }
                     override fun onAdLoaded(p0: AppOpenAd) {
                         printAdInfo(adUnitBean, p0.responseInfo)
-                        it.resume(
-                            AdResult.Success(
-                                p0,
-                                adUnitBean,
-                                AdLoadCode.SUCCESS,
-                                "Admob 开屏广告加载成功"
+                        if (it.isActive) {
+                            it.resume(
+                                AdResult.Success(
+                                    p0,
+                                    adUnitBean,
+                                    AdLoadCode.SUCCESS,
+                                    "Admob 开屏广告加载成功"
+                                )
                             )
-                        )
+                        }
                     }
                 }
             val adRequest = com.google.android.gms.ads.AdRequest.Builder()

+ 22 - 17
lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdmobBannerRequestImpl.kt

@@ -10,7 +10,7 @@ import com.composition.android.lib.ad.util.adLogE
 import com.google.android.gms.ads.AdListener
 import com.google.android.gms.ads.AdView
 import com.google.android.gms.ads.LoadAdError
-import com.composition.android.ad.admob.bean.AdmobAdUnitBean
+import com.composition.android.ad.admob.impl.AdmobAdSize
 import com.composition.android.ad.admob.util.getAdSize
 import com.composition.android.ad.admob.util.printAdInfo
 import kotlinx.coroutines.suspendCancellableCoroutine
@@ -18,7 +18,7 @@ import kotlin.coroutines.resume
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description:Admob横幅广告加载实现
  */
@@ -29,8 +29,8 @@ class AdmobBannerRequestImpl : IAdFormatRequest {
         return suspendCancellableCoroutine<AdResult> {
             val adView = AdView(context).apply {
                 adUnitId = adUnitBean.adUnitId
-                setAdSize(if (adUnitBean is AdmobAdUnitBean){
-                    adUnitBean.adSize
+                setAdSize(if (adUnitBean.adSize is AdmobAdSize){
+                    (adUnitBean.adSize as AdmobAdSize).size
                 }else{
                     getAdSize(context)
                 })
@@ -40,26 +40,31 @@ class AdmobBannerRequestImpl : IAdFormatRequest {
                 override fun onAdLoaded() {
                     super.onAdLoaded()
                     printAdInfo(adUnitBean, adView.responseInfo)
-                    it.resume(
-                        AdResult.Success(
-                            adView,
-                            adUnitBean,
-                            AdLoadCode.SUCCESS,
-                            "AdMob横幅广告加载成功"
+                    if (it.isActive) {
+                        it.resume(
+                            AdResult.Success(
+                                adView,
+                                adUnitBean,
+                                AdLoadCode.SUCCESS,
+                                "AdMob横幅广告加载成功"
+                            )
                         )
-                    )
+                    }
+
                 }
 
                 override fun onAdFailedToLoad(p0: LoadAdError) {
                     super.onAdFailedToLoad(p0)
                     adLogE(AdManager.TAG, p0.message)
-                    it.resume(
-                        AdResult.Fail(
-                            adUnitBean,
-                            AdLoadCode.FAIL,
-                            p0.message
+                    if (it.isActive){
+                        it.resume(
+                            AdResult.Fail(
+                                adUnitBean,
+                                AdLoadCode.FAIL,
+                                p0.message
+                            )
                         )
-                    )
+                    }
                 }
             }
 

+ 17 - 14
lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdmobInterstitialRequestImpl.kt

@@ -26,25 +26,28 @@ class AdmobInterstitialRequestImpl : IAdFormatRequest {
             val listener: InterstitialAdLoadCallback = object : InterstitialAdLoadCallback() {
                 override fun onAdLoaded(p0: InterstitialAd) {
                     printAdInfo(adUnitBean, p0.responseInfo)
-                    it.resume(
-                        AdResult.Success(
-                            adObject = p0,
-                            adBean = adUnitBean,
-                            code = AdLoadCode.SUCCESS,
-                            msg = "AdMob 插屏广告加载成功"
+                    if (it.isActive){
+                        it.resume(
+                            AdResult.Success(
+                                adObject = p0,
+                                adBean = adUnitBean,
+                                code = AdLoadCode.SUCCESS,
+                                msg = "AdMob 插屏广告加载成功"
+                            )
                         )
-                    )
+                    }
                 }
 
                 override fun onAdFailedToLoad(p0: LoadAdError) {
-                    printAdInfo(adUnitBean, p0.responseInfo)
-                    it.resume(
-                        AdResult.Fail(
-                            adUnitBean,
-                            AdLoadCode.FAIL,
-                            p0.message
+                    if (it.isActive){
+                        it.resume(
+                            AdResult.Fail(
+                                adUnitBean,
+                                AdLoadCode.FAIL,
+                                p0.message
+                            )
                         )
-                    )
+                    }
                 }
             }
 

+ 18 - 14
lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdmobRewardInterstitialRequestImpl.kt

@@ -15,7 +15,7 @@ import kotlin.coroutines.resume
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description:Admob激励插屏广告加载实现类
  */
@@ -28,24 +28,28 @@ class AdmobRewardInterstitialRequestImpl : IAdFormatRequest {
                 object : RewardedInterstitialAdLoadCallback() {
                     override fun onAdLoaded(p0: RewardedInterstitialAd) {
                         printAdInfo(adUnitBean, p0.responseInfo)
-                        it.resume(
-                            AdResult.Success(
-                                adBean = adUnitBean,
-                                adObject = p0,
-                                code = AdLoadCode.SUCCESS,
-                                msg = "AdMob激励插屏加载成功"
+                        if (it.isActive) {
+                            it.resume(
+                                AdResult.Success(
+                                    adBean = adUnitBean,
+                                    adObject = p0,
+                                    code = AdLoadCode.SUCCESS,
+                                    msg = "AdMob激励插屏加载成功"
+                                )
                             )
-                        )
+                        }
                     }
 
                     override fun onAdFailedToLoad(p0: LoadAdError) {
-                        it.resume(
-                            AdResult.Fail(
-                                adUnitBean,
-                                AdLoadCode.FAIL,
-                                getFailedCodeInfo(p0.code)
+                        if (it.isActive) {
+                            it.resume(
+                                AdResult.Fail(
+                                    adUnitBean,
+                                    AdLoadCode.FAIL,
+                                    getFailedCodeInfo(p0.code)
+                                )
                             )
-                        )
+                        }
                     }
                 }
 

+ 11 - 7
lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/request/AdmobRewardRequestImpl.kt

@@ -14,7 +14,7 @@ import kotlin.coroutines.resume
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description: Admob激励广告实现
  */
@@ -26,17 +26,21 @@ class AdmobRewardRequestImpl : IAdFormatRequest {
 
                 override fun onAdFailedToLoad(p0: LoadAdError) {
                     printAdInfo(adUnitBean, p0.responseInfo)
-                    it.resume(AdResult.Fail(adUnitBean, AdLoadCode.FAIL, p0.message))
+                    if (it.isActive) {
+                        it.resume(AdResult.Fail(adUnitBean, AdLoadCode.FAIL, p0.message))
+                    }
                 }
 
                 override fun onAdLoaded(p0: RewardedAd) {
                     printAdInfo(adUnitBean, p0.responseInfo)
-                    it.resume(
-                        AdResult.Success(
-                            p0,
-                            adUnitBean, AdLoadCode.SUCCESS, "AdMob激励广告加载成功"
+                    if (it.isActive) {
+                        it.resume(
+                            AdResult.Success(
+                                p0,
+                                adUnitBean, AdLoadCode.SUCCESS, "AdMob激励广告加载成功"
+                            )
                         )
-                    )
+                    }
                 }
             }
             val adRequest = com.google.android.gms.ads.AdRequest.Builder()

+ 1 - 1
lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/view/AdmobBannerView.kt

@@ -7,7 +7,7 @@ import com.google.android.gms.ads.AdView
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description:Admob横幅广告
  */

+ 1 - 1
lib_ad_admob/src/main/java/com/composition/android/ad/admob/load/view/AdmobNativeAdView.kt

@@ -16,7 +16,7 @@ import com.composition.android.ad.admob.R
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description: Admob原生广告View
  */

+ 4 - 3
lib_ad_core/src/main/java/com/composition/android/lib/ad/AdLoad.kt

@@ -6,6 +6,7 @@ import android.view.View
 import android.view.ViewGroup
 import com.composition.android.lib.ad.basic.NativeAdViewHolder
 import com.composition.android.lib.ad.basic.AdResult
+import com.composition.android.lib.ad.basic.BannerAdViewHolder
 import com.composition.android.lib.ad.bean.AdUnitBean
 import com.composition.android.lib.ad.impl.Api
 import com.composition.android.lib.ad.impl.NormalAdListener
@@ -13,7 +14,7 @@ import kotlinx.coroutines.flow.Flow
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/1
  * description:广告加载类,用于处理广告的加载、展示
  */
@@ -94,8 +95,8 @@ object AdLoad {
     /**
      * 获取Banner广告View
      */
-    fun getBannerAdView(context: Context, success: AdResult.Success): View? {
-        return Api.instance.getBannerView(context, success)
+    fun getBannerAdView(context: Context, success: AdResult.Success, viewHolder: BannerAdViewHolder): View? {
+        return Api.instance.getBannerView(context, success,viewHolder)
     }
 
 

+ 1 - 1
lib_ad_core/src/main/java/com/composition/android/lib/ad/AdManager.kt

@@ -10,7 +10,7 @@ import com.composition.android.lib.ad.interfaces.Initialize
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/1
  * description:广告管理类
  */

+ 9 - 2
lib_ad_core/src/main/java/com/composition/android/lib/ad/AdUnitConfigManager.kt

@@ -1,10 +1,11 @@
 package com.composition.android.lib.ad
 
+import com.composition.android.lib.ad.basic.Advertisers
 import com.composition.android.lib.ad.bean.AdUnitBean
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/1
  * description:广告单元配置管理类
  */
@@ -37,10 +38,16 @@ class AdUnitConfigManager {
      */
     fun getAdUnitBySlotName(adSlotNames: List<String>): List<AdUnitBean> {
         val list = adUnitLists.filter {
-            adSlotNames.contains(it.adSlotName)
+            adSlotNames.contains(it.adSlotName) && hasAdLoader(it.getAdvertisers())
         }
         return list
     }
 
 
+    private fun hasAdLoader(advertisers: Advertisers) : Boolean{
+        return AdManager.instance.adLoaderLists.any {
+            it.first == advertisers
+        }
+    }
+
 }

+ 3 - 1
lib_ad_core/src/main/java/com/composition/android/lib/ad/basic/Advertisers.kt

@@ -2,7 +2,7 @@ package com.composition.android.lib.ad.basic
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/1
  * description:广告提供商
  */
@@ -28,6 +28,8 @@ enum class Advertisers {
      */
     CSJ,
 
+    GroMore,
+
     /**
      * 自定义广告
      */

+ 34 - 0
lib_ad_core/src/main/java/com/composition/android/lib/ad/basic/BannerAdViewHolder.kt

@@ -0,0 +1,34 @@
+package com.composition.android.lib.ad.basic
+
+import android.app.Activity
+import android.view.View
+import android.view.ViewGroup
+import androidx.appcompat.widget.AppCompatButton
+import androidx.appcompat.widget.AppCompatImageView
+import androidx.appcompat.widget.AppCompatTextView
+import com.composition.android.lib.ad.interfaces.AdListener
+import com.composition.android.lib.ad.interfaces.ImageLoader
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/6
+ * description: 原生广告View配置类,指定相关视图
+ */
+class BannerAdViewHolder(
+    var adListener : AdListener? = null,
+    var activity : Activity? = null, //穿山甲广告需要
+) {
+
+
+    companion object{
+
+        fun buildBannerAdViewHolder(viewHolder : BannerAdViewHolder.()-> Unit) : BannerAdViewHolder{
+            return BannerAdViewHolder().also(viewHolder)
+        }
+
+    }
+
+}
+
+fun buildBannerAdViewHolder(viewHolder: BannerAdViewHolder.() -> Unit) = BannerAdViewHolder.buildBannerAdViewHolder(viewHolder)

+ 4 - 2
lib_ad_core/src/main/java/com/composition/android/lib/ad/basic/BasicAdView.kt

@@ -12,7 +12,7 @@ import com.composition.android.lib.ad.util.adLog
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/6
  * description:
  */
@@ -47,7 +47,6 @@ abstract class BasicAdView<T : View> : LinearLayout, DefaultLifecycleObserver {
     override fun onAttachedToWindow() {
         super.onAttachedToWindow()
         adLog(AdManager.TAG, javaClass.simpleName + " 绑定到Window")
-
         findViewTreeLifecycleOwner()?.lifecycle?.addObserver(this)
     }
 
@@ -55,6 +54,7 @@ abstract class BasicAdView<T : View> : LinearLayout, DefaultLifecycleObserver {
         super.onDetachedFromWindow()
         adLog(AdManager.TAG, javaClass.simpleName + " 从Window移除")
         onDestroy()
+        findViewTreeLifecycleOwner()?.lifecycle?.removeObserver(this)
     }
 
 
@@ -73,7 +73,9 @@ abstract class BasicAdView<T : View> : LinearLayout, DefaultLifecycleObserver {
     override fun onDestroy(owner: LifecycleOwner) {
         super.onDestroy(owner)
         adLog(AdManager.TAG, javaClass.simpleName + " onDestroy")
+        findViewTreeLifecycleOwner()?.lifecycle?.removeObserver(this)
         onDestroy()
+
     }
 
     abstract fun adContentView(): T?

+ 3 - 0
lib_ad_core/src/main/java/com/composition/android/lib/ad/basic/NativeAdViewHolder.kt

@@ -1,5 +1,6 @@
 package com.composition.android.lib.ad.basic
 
+import android.app.Activity
 import android.view.View
 import android.view.ViewGroup
 import androidx.appcompat.widget.AppCompatButton
@@ -25,6 +26,8 @@ class NativeAdViewHolder(
     var ratingBar : View? = null,
     var advertiserView : View? = null,
     var adListener : AdListener? = null,
+    var dislikeView : View? = null,
+    var activity : Activity? = null, //穿山甲广告需要
     var imageLoader : ImageLoader<AppCompatImageView>? = null
 ) {
 

+ 1 - 1
lib_ad_core/src/main/java/com/composition/android/lib/ad/basic/strategy/IStrategy.kt

@@ -2,7 +2,7 @@ package com.composition.android.lib.ad.basic.strategy
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/1
  * description:广告加载、展示策略接口,
  */

+ 5 - 4
lib_ad_core/src/main/java/com/composition/android/lib/ad/bean/AdUnitBean.kt

@@ -4,14 +4,12 @@ import com.composition.android.lib.ad.basic.AdType
 import com.composition.android.lib.ad.basic.Advertisers
 import com.composition.android.lib.ad.impl.NormalStrategy
 import com.composition.android.lib.ad.basic.strategy.IStrategy
-
-
-
+import com.composition.android.lib.ad.interfaces.IAdSize
 
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/1
  * description:广告单元信息
  * 一个广告位,包含使用的广告位名称,广告商、广告类型、广告ID、加载配置、展示配置
@@ -21,6 +19,7 @@ open class AdUnitBean(
     var advertisersName: String,
     var adType: String,
     var adUnitId: String,
+    var adSize : IAdSize<*>?  = null,
     var loadStrategy : IStrategy = NormalStrategy(),
     var requestAdConfig: AdUnitLoadConfig = AdUnitLoadConfig()
 ) {
@@ -64,3 +63,5 @@ open class AdUnitBean(
     }
 
 }
+
+

+ 1 - 1
lib_ad_core/src/main/java/com/composition/android/lib/ad/bean/AdUnitLoadConfig.kt

@@ -2,7 +2,7 @@ package com.composition.android.lib.ad.bean
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/1
  * description:广告单元加载配置
  */

+ 1 - 1
lib_ad_core/src/main/java/com/composition/android/lib/ad/factory/AdLoaderFactory.kt

@@ -7,7 +7,7 @@ import com.composition.android.lib.ad.interfaces.AdLoader
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description:
  */

+ 1 - 1
lib_ad_core/src/main/java/com/composition/android/lib/ad/factory/AdRequestFactory.kt

@@ -2,7 +2,7 @@ package com.composition.android.lib.ad.factory
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description:
  */

+ 4 - 3
lib_ad_core/src/main/java/com/composition/android/lib/ad/impl/Api.kt

@@ -7,6 +7,7 @@ import android.view.ViewGroup
 import com.composition.android.lib.ad.AdLoad
 import com.composition.android.lib.ad.basic.AdLoadCode
 import com.composition.android.lib.ad.basic.AdResult
+import com.composition.android.lib.ad.basic.BannerAdViewHolder
 import com.composition.android.lib.ad.basic.NativeAdViewHolder
 import com.composition.android.lib.ad.bean.AdUnitBean
 import com.composition.android.lib.ad.factory.AdLoaderFactory
@@ -16,7 +17,7 @@ import kotlinx.coroutines.flow.flow
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description:
  */
@@ -56,11 +57,11 @@ class Api {
     }
 
 
-    fun getBannerView(context: Context, adResult: AdResult.Success) : View?{
+    fun getBannerView(context: Context, adResult: AdResult.Success, viewHolder: BannerAdViewHolder) : View?{
         if (adResult.adBean.loadStrategy.allow().not()){
             return null
         }
-        return getAdLoader(adResult.adBean).getBannerView(context, adResult)
+        return getAdLoader(adResult.adBean).getBannerView(context, adResult, viewHolder)
     }
 
     fun getNativeAdView(context: Context, adResult : AdResult.Success, viewHolder: NativeAdViewHolder) : View?{

+ 1 - 1
lib_ad_core/src/main/java/com/composition/android/lib/ad/impl/NormalStrategy.kt

@@ -7,7 +7,7 @@ import com.convenient.android.common.extension.isNetworkAvailable
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/1
  * description:默认的广告展示策略,默认一直可以加载展示
  */

+ 2 - 5
lib_ad_core/src/main/java/com/composition/android/lib/ad/impl/UnknownAdLoader.kt

@@ -4,10 +4,7 @@ import android.app.Activity
 import android.content.Context
 import android.view.View
 import android.view.ViewGroup
-import com.composition.android.lib.ad.basic.AdLoadCode
-import com.composition.android.lib.ad.basic.AdResult
-import com.composition.android.lib.ad.basic.BasicAdView
-import com.composition.android.lib.ad.basic.NativeAdViewHolder
+import com.composition.android.lib.ad.basic.*
 import com.composition.android.lib.ad.bean.AdUnitBean
 import com.composition.android.lib.ad.interfaces.AdListener
 import com.composition.android.lib.ad.interfaces.AdLoader
@@ -27,7 +24,7 @@ class UnknownAdLoader : AdLoader {
         return AdResult.Fail(adUnitBean, AdLoadCode.FAIL, "未知的广告商,请检查Advertisers,当前:${adUnitBean.advertisersName}")
     }
 
-    override fun getBannerView(context: Context, adResult: AdResult.Success): BasicAdView<*>? {
+    override fun getBannerView(context: Context, adResult: AdResult.Success, viewHolder: BannerAdViewHolder): BasicAdView<*>? {
         return null
     }
 

+ 19 - 18
lib_ad_core/src/main/java/com/composition/android/lib/ad/interfaces/AdLoader.kt

@@ -4,10 +4,7 @@ import android.app.Activity
 import android.content.Context
 import android.view.View
 import android.view.ViewGroup
-import com.composition.android.lib.ad.basic.AdLoadCode
-import com.composition.android.lib.ad.basic.AdResult
-import com.composition.android.lib.ad.basic.BasicAdView
-import com.composition.android.lib.ad.basic.NativeAdViewHolder
+import com.composition.android.lib.ad.basic.*
 import com.composition.android.lib.ad.bean.AdUnitBean
 import com.composition.android.lib.ad.exception.AdLoadFailException
 import kotlinx.coroutines.flow.*
@@ -15,7 +12,7 @@ import kotlinx.coroutines.withTimeoutOrNull
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/1
  * description:广告商加载广告接口
  */
@@ -35,24 +32,28 @@ interface AdLoader {
         if (iAdFormatRequest == null){
             return AdResult.Fail(adUnitBean, msg = "广告类型解析出错,请检查adType")
         }
-        return withTimeoutOrNull(adUnitBean.requestAdConfig.adLoadTimeOut){
-
-            flow<AdResult> {
-                emit(iAdFormatRequest.load(context, adUnitBean))
-            }.onEach {
-                if (it is AdResult.Fail){
-                    throw AdLoadFailException()
-                }
-            }.retry(adUnitBean.requestAdConfig.adLoadRetryCount.toLong()){
-                it is AdLoadFailException
-            }.firstOrNull()
-        }?:AdResult.Fail(adUnitBean, AdLoadCode.FAIL, "加载失败")
+        return try {
+            withTimeoutOrNull(adUnitBean.requestAdConfig.adLoadTimeOut){
+
+                flow<AdResult> {
+                    emit(iAdFormatRequest.load(context, adUnitBean))
+                }.onEach {
+                    if (it is AdResult.Fail){
+                        throw AdLoadFailException()
+                    }
+                }.retry(adUnitBean.requestAdConfig.adLoadRetryCount.toLong()){
+                    it is AdLoadFailException
+                }.firstOrNull()
+            }?:AdResult.Fail(adUnitBean, AdLoadCode.FAIL, "加载失败")
+        }catch (e : Exception){
+            AdResult.Fail(adUnitBean, AdLoadCode.FAIL, "加载失败")
+        }
     }
 
     /**
      * 获取BannerAd View
      */
-    fun getBannerView(context: Context, adResult: AdResult.Success) : BasicAdView<*>?
+    fun getBannerView(context: Context, adResult: AdResult.Success, viewHolder: BannerAdViewHolder) : BasicAdView<*>?
 
     /**
      * 获取原生广告View

+ 1 - 1
lib_ad_core/src/main/java/com/composition/android/lib/ad/interfaces/IAdFormatRequest.kt

@@ -6,7 +6,7 @@ import com.composition.android.lib.ad.bean.AdUnitBean
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/5
  * description: 各类样式广告请求接口
  */

+ 13 - 0
lib_ad_core/src/main/java/com/composition/android/lib/ad/interfaces/IAdSize.kt

@@ -0,0 +1,13 @@
+package com.composition.android.lib.ad.interfaces
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:
+ */
+interface IAdSize<T> {
+
+    fun getAdSize() : T
+
+}

+ 1 - 1
lib_ad_core/src/main/java/com/composition/android/lib/ad/interfaces/Initialize.kt

@@ -4,7 +4,7 @@ import android.content.Context
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/13
  * description:
  */

+ 17 - 1
lib_ad_core/src/main/java/com/composition/android/lib/ad/widget/BannerAdView.kt

@@ -1,6 +1,8 @@
 package com.composition.android.lib.ad.widget
 
+import android.app.Activity
 import android.content.Context
+import android.content.ContextWrapper
 import android.content.res.TypedArray
 import android.util.AttributeSet
 import android.widget.LinearLayout
@@ -10,6 +12,9 @@ import androidx.lifecycle.lifecycleScope
 import com.composition.android.lib.ad.AdLoad
 import com.composition.android.lib.ad.R
 import com.composition.android.lib.ad.basic.AdResult
+import com.composition.android.lib.ad.basic.buildBannerAdViewHolder
+import com.composition.android.lib.ad.impl.NormalAdListener
+import com.convenient.android.common.extension.getActivityFromView
 import kotlinx.coroutines.flow.firstOrNull
 import kotlinx.coroutines.launch
 
@@ -56,14 +61,25 @@ class BannerAdView : LinearLayout{
             val adResult = AdLoad.loadAd(context, adSlotName)
                 .firstOrNull()
             if (adResult is AdResult.Success){
-                AdLoad.getBannerAdView(context, adResult)?.let {
+                AdLoad.getBannerAdView(context, adResult, buildBannerAdViewHolder {
+                    this.activity = getActivityFromView()
+                    this.adListener = object : NormalAdListener(){
+                        override fun onAdDisLike() {
+                            super.onAdDisLike()
+                            isVisible = false
+                            removeAllViews()
+                        }
+                    }
+                })?.let {
                     removeAllViews()
                     addView(it)
+                    isVisible = true
                 }
             }
         }
     }
 
+
     /**
      * 更新广告
      */

+ 12 - 2
lib_ad_core/src/main/java/com/composition/android/lib/ad/widget/NativeAdView.kt

@@ -17,12 +17,14 @@ import com.composition.android.lib.ad.basic.AdResult
 import com.composition.android.lib.ad.basic.Advertisers
 import com.composition.android.lib.ad.basic.NativeAdViewHolder
 import com.composition.android.lib.ad.basic.buildAdNativeViewHolder
+import com.composition.android.lib.ad.impl.NormalAdListener
+import com.convenient.android.common.extension.getActivityFromView
 import kotlinx.coroutines.flow.firstOrNull
 import kotlinx.coroutines.launch
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/9/7
  * description: 自定义的原生广告View, 通过在xml中的配置,view中进行加载广告并展示
  *
@@ -96,7 +98,7 @@ class NativeAdView : LinearLayout {
 
         when (adUnitBean?.getAdvertisers()) {
             Advertisers.Admob -> attachedAdvertisersNativeAdViewToRoot(typedArray, R.styleable.NativeAdView_native_admob_advertisers_root_view)
-            Advertisers.CSJ -> attachedAdvertisersNativeAdViewToRoot(typedArray, R.styleable.NativeAdView_native_csj_advertisers_root_view)
+            Advertisers.CSJ -> adRootView = this
             Advertisers.AppLovin-> attachedAdvertisersNativeAdViewToRoot(typedArray, R.styleable.NativeAdView_native_app_lovin_advertisers_root_view)
             Advertisers.AppLovinMax -> attachedAdvertisersNativeAdViewToRoot(typedArray, R.styleable.NativeAdView_native_app_lovin_max_advertisers_root_view)
             Advertisers.CUSTOM -> attachedAdvertisersNativeAdViewToRoot(typedArray, R.styleable.NativeAdView_native_custom_advertisers_root_view)
@@ -143,6 +145,14 @@ class NativeAdView : LinearLayout {
                 this.callActionView = findViewById(adCallToActionId)
                 this.ratingBar = findViewById(adRatingBarId)
                 this.contentMediaGroup = findViewById(adMediaContentId)
+                this.activity = getActivityFromView()
+                this.adListener = object : NormalAdListener(){
+                    override fun onAdDisLike() {
+                        super.onAdDisLike()
+                        isVisible = false
+                        removeAllViews()
+                    }
+                }
             }
         }
     }

+ 4 - 1
lib_ad_csj/build.gradle

@@ -30,8 +30,11 @@ android {
 }
 
 dependencies {
+    implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
+    implementation project(':lib_ad_core')
 
-    implementation 'androidx.core:core-ktx:1.7.0'
+    api 'androidx.legacy:legacy-support-v4:1.0.0'
+    implementation 'androidx.core:core-ktx:1.8.0'
     implementation 'androidx.appcompat:appcompat:1.5.1'
     implementation 'com.google.android.material:material:1.6.1'
     testImplementation 'junit:junit:4.13.2'

BIN
lib_ad_csj/libs/open_ad_sdk.aar


+ 24 - 0
lib_ad_csj/src/main/AndroidManifest.xml

@@ -2,4 +2,28 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.composition.android.ad.csj">
 
+    <permission
+        android:name="${applicationId}.openadsdk.permission.TT_PANGOLIN"
+        android:protectionLevel="signature" />
+    <uses-permission android:name="${applicationId}.openadsdk.permission.TT_PANGOLIN" />
+
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.GET_TASKS"/>
+
+
+    <application>
+
+        <provider
+            android:name="com.bytedance.sdk.openadsdk.TTFileProvider"
+            android:authorities="${applicationId}.TTFileProvider"
+            android:exported="false"
+            android:grantUriPermissions="true">
+            <meta-data
+                android:name="android.support.FILE_PROVIDER_PATHS"
+                android:resource="@xml/ttad_file_paths" />
+        </provider>
+    </application>
 </manifest>

+ 17 - 0
lib_ad_csj/src/main/java/com/composition/android/ad/csj/impl/CSJBannerAdSize.kt

@@ -0,0 +1,17 @@
+package com.composition.android.ad.csj.impl
+
+import com.composition.android.lib.ad.interfaces.IAdSize
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:穿山甲横幅广告尺寸
+ */
+class CSJBannerAdSize(var widthDp : Float, var heightDp : Float) : IAdSize<Pair<Float, Float>> {
+
+    override fun getAdSize(): Pair<Float, Float> {
+        return widthDp to heightDp
+    }
+
+}

+ 63 - 0
lib_ad_csj/src/main/java/com/composition/android/ad/csj/impl/CSJInitialize.kt

@@ -0,0 +1,63 @@
+package com.composition.android.ad.csj.impl
+
+import android.content.Context
+import com.bytedance.sdk.openadsdk.TTAdConfig
+import com.bytedance.sdk.openadsdk.TTAdConstant
+import com.bytedance.sdk.openadsdk.TTAdSdk
+import com.bytedance.sdk.openadsdk.TTCustomController
+import com.composition.android.lib.ad.AdManager
+import com.composition.android.lib.ad.interfaces.Initialize
+import com.composition.android.lib.ad.util.adLogE
+import com.convenient.android.common.config.MyPdfBaseModule
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:穿山甲广告SDK初始化
+ */
+class CSJInitialize(var appId: String) : Initialize {
+
+    override fun init(context: Context) {
+
+        TTAdSdk.init(context, TTAdConfig.Builder()
+            .appId(appId)
+            .useTextureView(true)
+            .appName(context.packageName)
+            .titleBarTheme(TTAdConstant.TITLE_BAR_THEME_DARK)
+            .allowShowNotify(true)
+            .debug(MyPdfBaseModule.isDebug)
+            .supportMultiProcess(false)
+            .asyncInit(true)
+            .needClearTaskReset()
+            .customController(object : TTCustomController() {
+                override fun getMacAddress(): String {
+                    return ""
+                }
+
+                override fun isCanUsePhoneState(): Boolean {
+                    return MyPdfBaseModule.isAgreeServerAgreement
+                }
+
+                override fun isCanUseAndroidId(): Boolean {
+                    return MyPdfBaseModule.isAgreeServerAgreement
+                }
+
+
+            })
+            .build(), object : TTAdSdk.InitCallback {
+            override fun success() {
+                adLogE(AdManager.TAG, "穿山甲广告SDK初始化完成 ---- 版本号:${TTAdSdk.getAdManager().sdkVersion}")
+            }
+
+            override fun fail(p0: Int, p1: String?) {
+                adLogE(AdManager.TAG, "穿山甲广告SDK初始化失败:${p1}")
+
+            }
+
+        })
+
+    }
+
+
+}

+ 197 - 0
lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/CSJAdLoader.kt

@@ -0,0 +1,197 @@
+package com.composition.android.ad.csj.load
+
+import android.app.Activity
+import android.content.Context
+import android.os.Bundle
+import android.view.View
+import android.view.ViewGroup
+import com.bytedance.sdk.openadsdk.*
+import com.composition.android.ad.csj.load.request.*
+import com.composition.android.ad.csj.load.view.CSJBannerView
+import com.composition.android.ad.csj.load.view.CSJNativeAdView
+import com.composition.android.lib.ad.AdManager
+import com.composition.android.lib.ad.basic.*
+import com.composition.android.lib.ad.bean.AdUnitBean
+import com.composition.android.lib.ad.interfaces.AdListener
+import com.composition.android.lib.ad.interfaces.AdLoader
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description: 穿山甲广告加载类
+ */
+class CSJAdLoader : AdLoader {
+
+
+    override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
+        if (adUnitBean.isAvailable().not()){
+            return AdResult.Fail(adUnitBean, msg = "AdUnitBean无效")
+        }
+        //获取到具体的广告格式加载类
+        val adFormatRequestImpl =
+            when(adUnitBean.getAdType()){
+            AdType.REWARDED_VIDEO, AdType.REWARDED_INTERSTITIAL-> CSJRewardRequestImpl()
+            AdType.INTERSTITIAL-> CSJInterstitialRequestImpl()
+            AdType.APP_OPEN -> CSJAppOpenRequestImpl()
+            AdType.BANNER-> CSJBannerRequestImpl()
+            AdType.NATIVE-> CSJNativeRequestImpl()
+            else-> null
+        }
+        return loadByStrategy(context, adUnitBean, adFormatRequestImpl)
+    }
+
+    override fun getBannerView(context: Context, adResult: AdResult.Success, viewHolder: BannerAdViewHolder): BasicAdView<*>? {
+       return if (adResult.adObject != null) {
+           AdManager.instance.globalListener?.invoke(adResult.adBean)
+           CSJBannerView(context, viewHolder).apply {
+               render(adResult)
+           }
+       }else{
+           null
+       }
+    }
+
+    override fun getNativeAdView(context: Context, adResult: AdResult.Success, viewHolder: NativeAdViewHolder): View? {
+        return if (adResult.adObject != null){
+            AdManager.instance.globalListener?.invoke(adResult.adBean)
+            CSJNativeAdView(context).apply {
+                setViewHolder(viewHolder)
+                render(adResult)
+            }
+        }else{
+            null
+        }
+    }
+
+    override fun populateNativeAdView(context: Context, adResult: AdResult.Success, viewHolder: NativeAdViewHolder, adRootView: View) {
+        AdManager.instance.globalListener?.invoke(adResult.adBean)
+        CSJNativeAdView.populateNativeAdView(context,adResult, viewHolder, adRootView)
+    }
+
+    override fun showInterstitialAd(activity: Activity, success: AdResult.Success, adListener: AdListener) {
+        if (success.adObject is TTFullScreenVideoAd){
+            val ttFullScreenVideoAd = success.adObject as TTFullScreenVideoAd
+            ttFullScreenVideoAd.setFullScreenVideoAdInteractionListener(object : TTFullScreenVideoAd.FullScreenVideoAdInteractionListener{
+                override fun onAdShow() {
+                    adListener.onAdShow(success.adBean)
+                    AdManager.instance.globalListener?.invoke(success.adBean)
+                }
+
+                override fun onAdVideoBarClick() {
+                    adListener.onAdClick()
+                }
+
+                override fun onAdClose() {
+                    adListener.onAdClose()
+                    success.adObject = null
+                }
+
+                override fun onVideoComplete() {
+
+                }
+
+                override fun onSkippedVideo() {
+                    adListener.onAdSkip()
+                }
+
+            })
+            ttFullScreenVideoAd.showFullScreenVideoAd(activity, TTAdConstant.RitScenes.CUSTOMIZE_SCENES, null)
+        }else{
+            adListener.onAdShowFail("adObject类型错误,当前为:${success.adObject?.javaClass?.simpleName}, 应该为:TTNativeExpressAd")
+        }
+    }
+
+    override fun showRewardedAd(activity: Activity, success: AdResult.Success, adListener: AdListener) {
+
+        if (success.adObject is TTRewardVideoAd){
+            val ttRewardVideoAd = success.adObject as TTRewardVideoAd
+
+
+            ttRewardVideoAd.setRewardAdInteractionListener(object : TTRewardVideoAd.RewardAdInteractionListener{
+                override fun onAdShow() {
+                    adListener.onAdShow(success.adBean)
+                    AdManager.instance.globalListener?.invoke(success.adBean)
+                }
+
+                override fun onAdVideoBarClick() {
+
+                }
+
+                override fun onAdClose() {
+                    adListener.onAdClose()
+                }
+
+                override fun onVideoComplete() {
+
+                }
+
+                override fun onVideoError() {
+                }
+
+                override fun onRewardVerify(p0: Boolean, p1: Int, p2: String?, p3: Int, p4: String?) {
+                    adListener.onAdRewarded()
+                }
+
+                override fun onRewardArrived(p0: Boolean, p1: Int, p2: Bundle?) {
+
+                }
+
+                override fun onSkippedVideo() {
+                   adListener.onAdSkip()
+                }
+
+            })
+
+            ttRewardVideoAd.showRewardVideoAd(activity)
+
+        }else{
+            adListener.onAdShowFail("穿山甲激励广告展示失败,类型错误,当前类型为:${success.adObject?.javaClass?.simpleName}, 应为:TTRewardVideoAd")
+        }
+
+
+    }
+
+    override fun showRewardedInterstitialAd(activity: Activity, success: AdResult.Success, adListener: AdListener) {
+       showRewardedAd(activity, success, adListener)
+    }
+
+    override fun showSplashAd(activity: Activity, splashViewGroup: ViewGroup?, success: AdResult.Success, adListener: AdListener) {
+        if (success.adObject is TTSplashAd){
+            val ttSplashAd = success.adObject as TTSplashAd
+            ttSplashAd.setSplashInteractionListener(object : TTSplashAd.AdInteractionListener{
+                override fun onAdClicked(p0: View?, p1: Int) {
+                    adListener.onAdClick()
+                }
+
+                override fun onAdShow(p0: View?, p1: Int) {
+                    adListener.onAdShow(success.adBean)
+                    AdManager.instance.globalListener?.invoke(success.adBean)
+                }
+
+                override fun onAdSkip() {
+                    adListener.onAdSkip()
+                }
+
+                override fun onAdTimeOver() {
+                    adListener.onTimeOver()
+                }
+            })
+            splashViewGroup?.removeAllViews()
+            splashViewGroup?.addView(ttSplashAd.splashView)
+        }else{
+            adListener.onAdShowFail("穿山甲激励广告展示失败,类型错误,当前类型为:${success.adObject?.javaClass?.simpleName}, 应为:TTRewardVideoAd")
+        }
+    }
+
+    override fun showFullScreenAd(activity: Activity, success: AdResult.Success, adListener: AdListener) {
+        when(success.adBean.getAdType()){
+            AdType.REWARDED_INTERSTITIAL,AdType.INTERSTITIAL-> showInterstitialAd(activity, success, adListener)
+            AdType.REWARDED_VIDEO -> showRewardedAd(activity, success, adListener)
+            else->{
+                adListener.onAdShowFail("不支持的广告类型:${success.adBean.adType}")
+            }
+        }
+
+    }
+}

+ 70 - 0
lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/request/CSJAppOpenRequestImpl.kt

@@ -0,0 +1,70 @@
+package com.composition.android.ad.csj.load.request
+
+import android.content.Context
+import com.bytedance.sdk.openadsdk.*
+import com.composition.android.ad.csj.util.printAdFailInfo
+import com.composition.android.ad.csj.util.printAdInfo
+import com.composition.android.lib.ad.basic.AdResult
+import com.composition.android.lib.ad.bean.AdUnitBean
+import com.composition.android.lib.ad.interfaces.IAdFormatRequest
+import com.convenient.android.common.extension.getScreenHeight
+import com.convenient.android.common.extension.getScreenHeightDp
+import com.convenient.android.common.extension.getScreenWidth
+import com.convenient.android.common.extension.getScreenWidthDp
+import kotlinx.coroutines.suspendCancellableCoroutine
+import kotlin.coroutines.resume
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:穿山甲开屏广告加载类
+ */
+class CSJAppOpenRequestImpl : IAdFormatRequest {
+    override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
+
+        return suspendCancellableCoroutine {
+            //step3:创建开屏广告请求参数AdSlot,具体参数含义参考文档
+            val splashWidthDp: Float = context.getScreenWidthDp()
+            val splashWidthPx: Int = context.getScreenWidth()
+            val screenHeightPx: Int = context.getScreenHeight()
+            val screenHeightDp: Float = context.getScreenHeightDp()
+
+            // 开屏高度 = 屏幕高度 - 下方预留的高度,demo中是预留了屏幕高度的1/5,因此开屏高度传入 屏幕高度*4/5
+            val splashHeightDp: Float = screenHeightDp * 4 / 5f
+            val splashHeightPx: Int = (screenHeightPx * 4 / 5f).toInt()
+
+            val adSlot = AdSlot.Builder()
+                .setCodeId(adUnitBean.adUnitId)
+                .setExpressViewAcceptedSize(splashWidthDp, splashHeightDp)
+                .setImageAcceptedSize(splashWidthPx, splashHeightPx)
+                .setAdLoadType(TTAdLoadType.PRELOAD)
+                .build()
+
+            TTAdSdk.getAdManager().createAdNative(context)
+                .loadSplashAd(adSlot, object : TTAdNative.SplashAdListener{
+                    override fun onError(p0: Int, p1: String?) {
+                        printAdFailInfo(p0, p1)
+                        if (it.isActive){
+                            it.resume(AdResult.Fail(adBean = adUnitBean, msg = p1?:"穿山甲开屏广告加载失败"))
+                        }
+                    }
+
+                    override fun onTimeout() {
+                        if (it.isActive){
+                            it.resume(AdResult.Fail(adBean = adUnitBean, msg = "穿山甲开屏广告加载失败,请求超时"))
+                        }
+                    }
+
+                    override fun onSplashAdLoad(p0: TTSplashAd?) {
+                        printAdInfo(adUnitBean)
+                        if (it.isActive){
+                            it.resume(AdResult.Success(adBean = adUnitBean, adObject = p0, msg = "穿山甲开屏广告成功"))
+                        }
+                    }
+                })
+        }
+
+
+    }
+}

+ 58 - 0
lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/request/CSJBannerRequestImpl.kt

@@ -0,0 +1,58 @@
+package com.composition.android.ad.csj.load.request
+
+import android.content.Context
+import com.bytedance.sdk.openadsdk.*
+import com.composition.android.ad.csj.impl.CSJBannerAdSize
+import com.composition.android.ad.csj.util.printAdFailInfo
+import com.composition.android.ad.csj.util.printAdInfo
+import com.composition.android.lib.ad.basic.AdResult
+import com.composition.android.lib.ad.bean.AdUnitBean
+import com.composition.android.lib.ad.interfaces.IAdFormatRequest
+import kotlinx.coroutines.suspendCancellableCoroutine
+import kotlin.coroutines.resume
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:穿山甲横幅广告加载类
+ */
+class CSJBannerRequestImpl : IAdFormatRequest {
+    override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
+        return suspendCancellableCoroutine {
+            val size = if (adUnitBean.adSize is CSJBannerAdSize) {
+                (adUnitBean.adSize as CSJBannerAdSize).getAdSize()
+            } else {
+                600F to 90F
+            }
+            val adSlot = AdSlot.Builder()
+                .setCodeId(adUnitBean.adUnitId)
+                .setAdCount(1)
+                .setImageAcceptedSize(600, 300)
+                .setExpressViewAcceptedSize(size.first, size.second)
+                .setAdLoadType(TTAdLoadType.LOAD)
+                .build()
+
+            TTAdSdk.getAdManager().createAdNative(context)
+                .loadBannerExpressAd(adSlot, object : TTAdNative.NativeExpressAdListener {
+                    override fun onError(p0: Int, p1: String?) {
+                        printAdFailInfo(p0, p1)
+                        if (it.isActive) {
+                            it.resume(AdResult.Fail(adUnitBean, msg = p1 ?: "穿山甲横幅广告加载失败"))
+                        }
+                    }
+
+                    override fun onNativeExpressAdLoad(p0: MutableList<TTNativeExpressAd>?) {
+                        printAdInfo(adUnitBean)
+                        if (it.isActive) {
+                            if (p0.isNullOrEmpty().not()) {
+                                it.resume(AdResult.Success(adBean = adUnitBean, adObject = p0?.get(0), msg = "穿山甲横幅广告加载成功"))
+                            } else {
+                                it.resume(AdResult.Fail(adUnitBean, msg = "穿山甲横幅广告加载失败, adList为空"))
+                            }
+                        }
+                    }
+                })
+        }
+    }
+}

+ 68 - 0
lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/request/CSJInterstitialRequestImpl.kt

@@ -0,0 +1,68 @@
+package com.composition.android.ad.csj.load.request
+
+import android.content.Context
+import com.bytedance.sdk.openadsdk.*
+import com.composition.android.ad.csj.util.printAdFailInfo
+import com.composition.android.ad.csj.util.printAdInfo
+import com.composition.android.lib.ad.basic.AdResult
+import com.composition.android.lib.ad.bean.AdUnitBean
+import com.composition.android.lib.ad.interfaces.IAdFormatRequest
+import kotlinx.coroutines.suspendCancellableCoroutine
+import kotlin.coroutines.resume
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:穿山甲激励广告加载
+ */
+class CSJInterstitialRequestImpl : IAdFormatRequest {
+    override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
+        return suspendCancellableCoroutine {
+
+            val adSlot = AdSlot.Builder()
+                .setCodeId(adUnitBean.adUnitId)
+                .setSupportDeepLink(true)
+                .setAdCount(1)
+                .setOrientation(TTAdConstant.VERTICAL)
+                .setAdLoadType(TTAdLoadType.PRELOAD)
+                .setExpressViewAcceptedSize(1080F, 1920F)
+                .build()
+
+            TTAdSdk.getAdManager().createAdNative(context)
+                .loadFullScreenVideoAd(adSlot, object : TTAdNative.FullScreenVideoAdListener{
+                    override fun onError(p0: Int, p1: String?) {
+                        printAdFailInfo(p0, p1)
+                        if (it.isActive) {
+                            it.resume(AdResult.Fail(adUnitBean, msg = p1?:"穿山甲模板插屏广告加载失败,code:${p0}"))
+                        }
+                    }
+
+                    override fun onFullScreenVideoAdLoad(p0: TTFullScreenVideoAd?) {
+                        printAdInfo(adUnitBean)
+                        if (it.isActive){
+                            if (p0 != null){
+                                it.resume(AdResult.Success(adBean = adUnitBean, adObject = p0, msg = "穿山甲模板插屏广告加载成功"))
+                            }else{
+                                it.resume(AdResult.Fail(adUnitBean, msg = "穿山甲模板插屏广告加载失败,adList为空"))
+                            }
+                        }
+                    }
+
+                    override fun onFullScreenVideoCached() {
+                    }
+
+                    override fun onFullScreenVideoCached(p0: TTFullScreenVideoAd?) {
+                        printAdInfo(adUnitBean)
+                        if (it.isActive){
+                            if (p0 != null){
+                                it.resume(AdResult.Success(adBean = adUnitBean, adObject = p0, msg = "穿山甲模板插屏广告加载成功"))
+                            }else{
+                                it.resume(AdResult.Fail(adUnitBean, msg = "穿山甲模板插屏广告加载失败,adList为空"))
+                            }
+                        }
+                    }
+                })
+        }
+    }
+}

+ 60 - 0
lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/request/CSJNativeRequestImpl.kt

@@ -0,0 +1,60 @@
+package com.composition.android.ad.csj.load.request
+
+import android.content.Context
+import com.bytedance.sdk.openadsdk.*
+import com.composition.android.ad.csj.impl.CSJBannerAdSize
+import com.composition.android.ad.csj.util.printAdFailInfo
+import com.composition.android.ad.csj.util.printAdInfo
+import com.composition.android.lib.ad.AdManager
+import com.composition.android.lib.ad.basic.AdResult
+import com.composition.android.lib.ad.bean.AdUnitBean
+import com.composition.android.lib.ad.interfaces.IAdFormatRequest
+import com.composition.android.lib.ad.util.adLogE
+import kotlinx.coroutines.suspendCancellableCoroutine
+import kotlin.coroutines.resume
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:穿山甲原生广告加载类
+ */
+class CSJNativeRequestImpl : IAdFormatRequest {
+
+    override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
+        return suspendCancellableCoroutine {
+            adLogE(AdManager.TAG, "穿山甲广告已不再支持原生广告格式,请使用横幅模板广告 AdType.Banner")
+            it.resume(AdResult.Fail(adUnitBean, msg = "穿山甲已不再支持原生广告格式,请改用横幅广告"))
+
+ /*           val adSlot = AdSlot.Builder()
+                .setCodeId(adUnitBean.adUnitId)
+                .setAdCount(1)
+                .setImageAcceptedSize(640, 320)
+                .setAdLoadType(TTAdLoadType.PRELOAD)
+                .setNativeAdType(AdSlot.TYPE_BANNER)
+                .build()
+
+            TTAdSdk.getAdManager().createAdNative(context)
+                .loadNativeExpressAd(adSlot, object : TTAdNative.NativeExpressAdListener {
+                    override fun onError(p0: Int, p1: String?) {
+                        printAdFailInfo(p0, p1)
+                        if (it.isActive) {
+                            it.resume(AdResult.Fail(adUnitBean, msg = p1 ?: "穿山甲原生广告加载失败"))
+                        }
+                    }
+
+                    override fun onNativeExpressAdLoad(p0: MutableList<TTNativeExpressAd>?) {
+                        printAdInfo(adUnitBean)
+                        if (it.isActive) {
+                            if (p0.isNullOrEmpty().not()) {
+                                it.resume(AdResult.Success(adBean = adUnitBean, adObject = p0?.get(0), msg = "穿山甲原生广告加载成功"))
+                            } else {
+                                it.resume(AdResult.Fail(adUnitBean, msg = "穿山甲原生广告加载失败, adList为空"))
+                            }
+                        }
+                    }
+                })*/
+
+        }
+    }
+}

+ 58 - 0
lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/request/CSJRewardRequestImpl.kt

@@ -0,0 +1,58 @@
+package com.composition.android.ad.csj.load.request
+
+import android.content.Context
+import com.bytedance.sdk.openadsdk.*
+import com.composition.android.ad.csj.util.printAdFailInfo
+import com.composition.android.ad.csj.util.printAdInfo
+import com.composition.android.lib.ad.basic.AdResult
+import com.composition.android.lib.ad.bean.AdUnitBean
+import com.composition.android.lib.ad.interfaces.IAdFormatRequest
+import kotlinx.coroutines.suspendCancellableCoroutine
+import kotlin.coroutines.resume
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:穿山甲激励广告加载
+ */
+class CSJRewardRequestImpl : IAdFormatRequest {
+    override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
+        return suspendCancellableCoroutine {
+
+            val adSlot = AdSlot.Builder()
+                .setCodeId(adUnitBean.adUnitId)
+                .setAdCount(1)
+                .setOrientation(TTAdConstant.VERTICAL)
+                .setAdLoadType(TTAdLoadType.PRELOAD)
+                .build()
+
+            TTAdSdk.getAdManager().createAdNative(context)
+                .loadRewardVideoAd(adSlot, object : TTAdNative.RewardVideoAdListener{
+                    override fun onError(code: Int, p1: String?) {
+                        printAdFailInfo(code, p1)
+                        if (it.isActive) {
+                            it.resume(AdResult.Fail(adBean = adUnitBean, msg = p1?:""))
+                        }
+                    }
+
+                    override fun onRewardVideoAdLoad(p0: TTRewardVideoAd?) {
+                        printAdInfo(adUnitBean)
+                        if (it.isActive){
+                            it.resume(AdResult.Success(adBean = adUnitBean, adObject = p0, msg = "穿山甲广告加载成功"))
+                        }
+                    }
+
+                    override fun onRewardVideoCached() {
+                    }
+
+                    override fun onRewardVideoCached(p0: TTRewardVideoAd?) {
+                        printAdInfo(adUnitBean)
+                        if (it.isActive){
+                            it.resume(AdResult.Success(adBean = adUnitBean, adObject = p0, msg = "穿山甲广告缓存加载成功"))
+                        }
+                    }
+                })
+        }
+    }
+}

+ 82 - 0
lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/view/CSJBannerView.kt

@@ -0,0 +1,82 @@
+package com.composition.android.ad.csj.load.view
+
+import android.content.Context
+import android.view.View
+import androidx.core.view.isVisible
+import com.bytedance.sdk.openadsdk.TTAdDislike
+import com.bytedance.sdk.openadsdk.TTNativeExpressAd
+import com.composition.android.lib.ad.AdManager
+import com.composition.android.lib.ad.basic.BannerAdViewHolder
+import com.composition.android.lib.ad.basic.BasicAdView
+import com.composition.android.lib.ad.util.adLog
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:
+ */
+class CSJBannerView(context: Context?,var viewHolder: BannerAdViewHolder) : BasicAdView<View>(context) {
+
+
+
+    override fun adContentView(): View? {
+        var adObj = adResult?.adObject as TTNativeExpressAd
+        adObj.setExpressInteractionListener(object : TTNativeExpressAd.ExpressAdInteractionListener{
+            override fun onAdClicked(p0: View?, p1: Int) {
+                viewHolder.adListener?.onAdClick()
+                adLog(AdManager.TAG, "穿山甲横幅广告点击")
+            }
+
+            override fun onAdShow(p0: View?, p1: Int) {
+                adResult?.adBean?.let { viewHolder.adListener?.onAdShow(it) }
+                adLog(AdManager.TAG, "穿山甲横幅广告展示")
+
+            }
+
+            override fun onRenderFail(p0: View?, p1: String?, p2: Int) {
+                viewHolder.adListener?.onAdShowFail("穿山甲广告渲染失败")
+                adLog(AdManager.TAG, "穿山甲横幅广告渲染失败")
+            }
+
+            override fun onRenderSuccess(p0: View?, p1: Float, p2: Float) {
+            }
+        })
+        viewHolder.activity?.let {
+            adObj.setDislikeCallback(it, object : TTAdDislike.DislikeInteractionCallback{
+                override fun onShow() {
+
+                }
+
+                override fun onSelected(p0: Int, p1: String?, p2: Boolean) {
+                    viewHolder.adListener?.onAdDisLike()
+                    this@CSJBannerView.isVisible = false
+                    adLog(AdManager.TAG, "点击了穿山甲横幅广告不喜欢按钮,隐藏广告")
+
+                }
+
+                override fun onCancel() {
+                }
+
+            })
+        }
+
+        adObj.render()
+
+        return adObj.expressAdView
+    }
+
+    override fun onResume() {
+    }
+
+    override fun onPause() {
+    }
+
+    override fun onDestroy() {
+        if (adResult?.adObject != null) {
+            (adResult?.adObject as? TTNativeExpressAd)?.destroy()
+            adResult?.adObject = null
+        }
+    }
+
+}

+ 110 - 0
lib_ad_csj/src/main/java/com/composition/android/ad/csj/load/view/CSJNativeAdView.kt

@@ -0,0 +1,110 @@
+package com.composition.android.ad.csj.load.view
+
+import android.content.Context
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.LinearLayout
+import androidx.appcompat.widget.AppCompatImageView
+import androidx.appcompat.widget.AppCompatTextView
+import androidx.core.view.isVisible
+import com.bytedance.sdk.openadsdk.*
+import com.composition.android.ad.csj.R
+import com.composition.android.lib.ad.basic.AdResult
+import com.composition.android.lib.ad.basic.BasicAdView
+import com.composition.android.lib.ad.basic.NativeAdViewHolder
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:
+ */
+class CSJNativeAdView(context: Context?) : BasicAdView<View>(context) {
+
+    private var viewHolder: NativeAdViewHolder? = null
+
+    fun setViewHolder(viewHolder: NativeAdViewHolder) {
+        this.viewHolder = viewHolder
+    }
+
+    override fun adContentView(): View? {
+
+        if (adResult == null || viewHolder == null) {
+            return null
+        }
+        populateNativeAdView(context, adResult = adResult!!, viewHolder = viewHolder!!, null)
+        val ttNativeExpressAd = adResult?.adObject as TTNativeExpressAd
+
+        return ttNativeExpressAd.expressAdView
+    }
+
+    override fun onResume() {
+    }
+
+    override fun onPause() {
+    }
+
+    override fun onDestroy() {
+        val ttNativeExpressAd = adResult?.adObject as? TTNativeExpressAd
+        ttNativeExpressAd?.destroy()
+    }
+
+    companion object {
+
+
+
+        fun populateNativeAdView(context: Context, adResult: AdResult.Success, viewHolder: NativeAdViewHolder, adRootView : View?) {
+            val ttNativeExpressAd = adResult.adObject as TTNativeExpressAd
+
+            viewHolder.activity?.let {
+                ttNativeExpressAd.setDislikeCallback(it, object : TTAdDislike.DislikeInteractionCallback {
+                    override fun onShow() {
+
+                    }
+
+                    override fun onSelected(p0: Int, p1: String?, p2: Boolean) {
+                        viewHolder.adListener?.onAdDisLike()
+                    }
+
+                    override fun onCancel() {
+                    }
+
+                })
+            }
+
+            ttNativeExpressAd.setExpressInteractionListener(object : TTNativeExpressAd.AdInteractionListener {
+                override fun onAdClicked(p0: View?, p1: Int) {
+                    viewHolder.adListener?.onAdClick()
+                }
+
+                override fun onAdShow(p0: View?, p1: Int) {
+                    viewHolder.adListener?.onAdShow(adResult.adBean)
+
+                }
+
+                override fun onRenderFail(p0: View?, p1: String?, p2: Int) {
+                    viewHolder.adListener?.onAdShowFail("穿山甲原生模板广告渲染失败")
+                }
+
+                override fun onRenderSuccess(p0: View?, p1: Float, p2: Float) {
+                }
+
+                override fun onAdDismiss() {
+                    viewHolder.adListener?.onAdClose()
+                }
+
+            })
+            ttNativeExpressAd.render()
+            (adRootView as? ViewGroup)?.let {
+                it.removeAllViews()
+                it.addView(ttNativeExpressAd.expressAdView)
+            }
+        }
+    }
+
+    override fun onDetachedFromWindow() {
+        super.onDetachedFromWindow()
+        adResult?.adObject = null
+    }
+}

+ 48 - 0
lib_ad_csj/src/main/java/com/composition/android/ad/csj/util/CSJAdExpan.kt

@@ -0,0 +1,48 @@
+package com.composition.android.ad.csj.util
+
+import com.composition.android.lib.ad.AdManager
+import com.composition.android.lib.ad.bean.AdUnitBean
+import com.composition.android.lib.ad.util.adLog
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description:
+ */
+
+internal fun printAdFailInfo(code : Int, msg : String?){
+    adLog(
+        AdManager.TAG,
+        "-------------------------------------------------------------------"
+    )
+
+    adLog(AdManager.TAG, "广告加载失败")
+    adLog(AdManager.TAG, "Code:${code}")
+    adLog(AdManager.TAG, "错误信息:${msg}")
+
+    adLog(
+        AdManager.TAG,
+        "-------------------------------------------------------------------"
+    )
+}
+
+
+internal fun printAdInfo(adBean: AdUnitBean){
+
+    adLog(
+        AdManager.TAG,
+        "-------------------------------------------------------------------"
+    )
+
+    adLog(AdManager.TAG, "广告加载成功")
+    adLog(AdManager.TAG, "广告商:${adBean.advertisersName}")
+    adLog(AdManager.TAG, "广告位:${adBean.adSlotName}")
+    adLog(AdManager.TAG, "广告ID:${adBean.adUnitId}")
+    adLog(AdManager.TAG, "广告类型:${adBean.adType}")
+
+    adLog(
+        AdManager.TAG,
+        "-------------------------------------------------------------------"
+    )
+}

+ 13 - 0
lib_ad_csj/src/main/res/values-zh-rCN/strings.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="start_download">开始下载</string>
+    <string name="downloading">下载中</string>
+    <string name="download_pause">下载暂停</string>
+    <string name="download_again">重新下载</string>
+    <string name="click_to_open">点击打开</string>
+    <string name="click_to_install">点击安装</string>
+    <string name="call_now">立即拨打</string>
+    <string name="check_the_details">查看详情</string>
+
+</resources>

+ 14 - 0
lib_ad_csj/src/main/res/values/strings.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="start_download">start download</string>
+    <string name="downloading">downloading</string>
+    <string name="download_pause">download pause</string>
+    <string name="download_again">download again</string>
+    <string name="click_to_open">click to open</string>
+    <string name="click_to_install">click to install</string>
+
+    <string name="call_now">call now</string>
+    <string name="check_the_details">check the details</string>
+
+</resources>

+ 9 - 0
lib_ad_csj/src/main/res/xml/ttad_file_paths.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<paths xmlns:android="http://schemas.android.com/apk/res/android">
+    <!--为了适配所有路径可以设置 path = "." -->
+    <external-path name="tt_external_root" path="." />
+    <external-path name="tt_external_download" path="Download" />
+    <external-files-path name="tt_external_files_download" path="Download" />
+    <files-path name="tt_internal_file_download" path="Download" />
+    <cache-path name="tt_internal_cache_download" path="Download" />
+</paths>

+ 12 - 0
lib_common/src/main/java/com/convenient/android/common/config/MyPdfBaseModule.kt

@@ -2,6 +2,8 @@ package com.convenient.android.common.config
 
 import android.app.Application
 import android.content.Context
+import com.convenient.android.common.extension.spGetBoolean
+import com.convenient.android.common.extension.spSave
 
 /**
  *    @author : hubowen
@@ -16,6 +18,16 @@ object MyPdfBaseModule {
 
     var versionName: String = ""
 
+    /**
+     * 是否有同意隐私政策合规
+     */
+    var isAgreeServerAgreement: Boolean = false
+        set(value) {
+            field = value
+            this.getAppContext()?.spSave("agree_server_agreement", field)
+        }
+        get() = this.getAppContext()?.spGetBoolean("agree_server_agreement", false) ?: false
+
     /**
      * 子模块和主模块需要共享全局上下文,故需要在app module初始化时传入
      */

+ 1 - 1
lib_common/src/main/java/com/convenient/android/common/extension/ListExtensions.kt

@@ -5,7 +5,7 @@ import com.convenient.android.common.media.config.SortUtils
 
 /**
  * @classname:
- * @auther: LiuXiaoLong
+ * @author: LiuXiaoLong
  * @date: 2022/8/4
  * description:
  */

+ 5 - 0
lib_common/src/main/java/com/convenient/android/common/extension/ScreenExtensions.kt

@@ -35,11 +35,16 @@ import kotlin.math.sqrt
  */
 fun Context?.getScreenWidth(): Int = this?.resources?.displayMetrics?.widthPixels ?: 0
 
+
 /**
  * 屏幕高度
  */
 fun Context?.getScreenHeight(): Int = this?.resources?.displayMetrics?.heightPixels ?: 0
 
+fun Context?.getScreenWidthDp() : Float = getScreenWidth() / (if (getDensity() <= 0) 1F else getDensity()) + 0.5f
+
+fun Context.getScreenHeightDp() : Float = px2dip(getScreenHeight().toFloat()).toFloat()
+
 /**
  * 获取屏幕密度
  */

+ 15 - 1
lib_common/src/main/java/com/convenient/android/common/extension/ViewExtensions.kt

@@ -1,6 +1,8 @@
 package com.convenient.android.common.extension
 
+import android.app.Activity
 import android.content.Context
+import android.content.ContextWrapper
 import android.view.View
 import androidx.annotation.DrawableRes
 import androidx.core.content.ContextCompat
@@ -124,4 +126,16 @@ private fun <T : View> T.clickEnable(): Boolean {
     triggerLastTime = currentClickTime
     return flag
 }
-/****** 防重点击相关扩展属性 End ******/
+/****** 防重点击相关扩展属性 End ******/
+
+
+fun View.getActivityFromView() : Activity?{
+    var cont = context
+    while (cont is ContextWrapper){
+        if (cont is Activity){
+            return cont as Activity
+        }
+        cont = cont.baseContext
+    }
+    return null
+}