Prechádzať zdrojové kódy

【升级合并】1.合并GroMore 和 穿山甲

hubowen 1 rok pred
rodič
commit
cbe2d40547
39 zmenil súbory, kde vykonal 903 pridanie a 688 odobranie
  1. 27 15
      app/build.gradle
  2. BIN
      app/libs/mediation_test_tools_3.9.0.0.aar
  3. 5 7
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/AdMainActivity.kt
  4. 6 9
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/activity/AdAppOpenActivity.kt
  5. 4 4
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/model/Datas.kt
  6. 8 14
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/page/AdHomePage.kt
  7. 1 2
      app/src/main/java/com/convenient/android/lib/ui/sample/ad/viewmodel/AdConfigViewModel.kt
  8. 4 12
      app/src/main/res/layout/activity_ad_native_template.xml
  9. 2 2
      build.gradle
  10. 1 1
      gradle/wrapper/gradle-wrapper.properties
  11. 4 4
      keystore.properties
  12. 8 7
      lib_ad_core/build.gradle
  13. 7 13
      lib_ad_core/src/androidTest/java/com/composition/android/lib/ad/ExampleInstrumentedTest.kt
  14. 17 14
      lib_ad_core/src/main/java/com/composition/android/lib/ad/bean/AdUnitBean.kt
  15. 9 13
      lib_ad_core/src/test/java/com/composition/android/lib/ad/ExampleUnitTest.kt
  16. 1 1
      lib_ad_csj/build.gradle
  17. 0 11
      lib_ad_csj/src/main/java/com/composition/android/ad/csj/impl/CSJInitialize.kt
  18. 26 29
      lib_ad_gromore/build.gradle
  19. 10 26
      lib_ad_gromore/src/main/AndroidManifest.xml
  20. 41 0
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/impl/CSJAppDownloadListener.kt
  21. 20 32
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/impl/GroMoreInitialize.kt
  22. 127 128
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/GroMoreAdLoader.kt
  23. 22 32
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMAppOpenRequestImpl.kt
  24. 23 49
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMBannerRequestImpl.kt
  25. 31 41
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMInterstitialRequestImpl.kt
  26. 58 0
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMNativeRequestImpl.kt
  27. 29 51
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMNativeTemplateRequestImpl.kt
  28. 26 32
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMRewardRequestImpl.kt
  29. 191 0
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/view/CSJNativeAdView.kt
  30. 43 33
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/view/GMBannerView.kt
  31. 43 65
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/view/GMNativeTemplateAdView.kt
  32. 29 29
      lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/util/GMSettingConfig.kt
  33. 38 0
      lib_ad_gromore/src/main/res/layout/csj_native_ad_media_image_views.xml
  34. 0 3
      lib_ad_gromore/src/main/res/layout/layout_gro_more_native_template_ad_view_root.xml
  35. 13 0
      lib_ad_gromore/src/main/res/values-zh-rCN/strings.xml
  36. 14 0
      lib_ad_gromore/src/main/res/values/strings.xml
  37. 9 0
      lib_ad_gromore/src/main/res/xml/ttad_file_paths.xml
  38. 4 7
      lib_ad_gromore/src/test/java/com/composition/android/ad/gromore/ExampleUnitTest.kt
  39. 2 2
      lib_common/build.gradle

+ 27 - 15
app/build.gradle

@@ -26,13 +26,13 @@ android {
     }
 
     defaultConfig {
-        applicationId "com.convenient.android.lib"
+        applicationId "com.kdanmobile.android.pdfreader.google.pad"
 
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.targetSdkVersion
         versionCode rootProject.ext.versionCode
         versionName rootProject.ext.versionName
-        flavorDimensions "lib"
+//        flavorDimensions "lib"
 
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
 
@@ -46,21 +46,28 @@ android {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
-    }
-
-    productFlavors {
-
-        defaultTest {
 
-        }
-
-        appLovinMaxTest {
-            applicationId "com.pdftechnologies.pdfreaderpro"
+        debug {
             signingConfig signingConfigs.release
-
         }
-
     }
+//
+//    productFlavors {
+//
+//        defaultTest {
+//            applicationId "com.kdanmobile.android.pdfreader.google.pad"
+//
+//            signingConfig signingConfigs.release
+//
+//        }
+//
+//        appLovinMaxTest {
+//            applicationId "com.pdftechnologies.pdfreaderpro"
+//            signingConfig signingConfigs.release
+//
+//        }
+//
+//    }
 
 
     compileOptions {
@@ -122,6 +129,12 @@ dependencies {
     implementation project(':lib_ad_scope')
     implementation project(':lib_pdf_base')
 
+    /*GroMore 百度*/
+    implementation "by.gm_mediation.com:baidu-adapter:9.26.0"
+    /*GroMore 优量汇*/
+    implementation "by.gm_mediation.com:gdt-adapter:4.510.1380.0"
+
+
     //compose依赖
     implementation "androidx.compose.ui:ui:$compose_version"
     implementation 'androidx.compose.material3:material3:1.1.0-rc01'
@@ -150,5 +163,4 @@ dependencies {
     androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
     debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
     debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
-
-}
+}

BIN
app/libs/mediation_test_tools_3.9.0.0.aar


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

@@ -5,8 +5,6 @@ import android.util.Log
 import androidx.activity.compose.setContent
 import androidx.appcompat.app.AppCompatActivity
 import com.composition.android.ad.admob.impl.AdmobInitialize
-import com.composition.android.ad.applovinmax.impl.AppLovinMaxInitialize
-import com.composition.android.ad.csj.impl.CSJInitialize
 import com.composition.android.ad.gromore.impl.GroMoreInitialize
 import com.composition.android.lib.ad.AdManager
 import com.composition.android.lib.ad.AdUnitConfigManager
@@ -30,14 +28,14 @@ class AdMainActivity : AppCompatActivity() {
 
     private fun initAd() {
         AdManager.instance.init(applicationContext, true)
-        AdManager.instance.initAdvertisersSDK(applicationContext, AdmobInitialize(), CSJInitialize("5320990"), GroMoreInitialize("5320990"), AppLovinMaxInitialize(logging = true))
+        AdManager.instance.initAdvertisersSDK(applicationContext, AdmobInitialize(), GroMoreInitialize("5089223"))
         val list = mutableListOf<AdUnitBean>()
-        list.addAll(Datas.AdmobAdUnitList)
-        AdUnitConfigManager.instance.setAdUnits(list)
-
+//        list.addAll(Datas.AdmobAdUnitList)
 //        list.addAll(Datas.CSJAdUnitList)
-//        list.addAll(Datas.GroMoreAdUnitList)
+        list.addAll(Datas.GroMoreAdUnitList)
 //        list.addAll(Datas.AppLovinMaxAdUnitList)
+        AdUnitConfigManager.instance.setAdUnits(list)
+
         AdManager.instance.addGlobalAdShowListener {
             Log.e("广告全局展示监听", "广告位名称:${it.adSlotName}\n广告商:${it.advertisersName}\n广告id:${it.adUnitId}\n广告类型:${it.adType}")
         }

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

@@ -26,9 +26,8 @@ class AdAppOpenActivity : BaseBindingActivity<ActivityAdAppOpenBinding>(Activity
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
-
         lifecycleScope.launch {
-            status.collect{
+            status.collect {
                 binding.btnOpenBgAppOpen.text = getString(R.string.app_open_1, if (it) getString(R.string.open) else getString(R.string.close))
             }
         }
@@ -37,20 +36,20 @@ class AdAppOpenActivity : BaseBindingActivity<ActivityAdAppOpenBinding>(Activity
                 R.id.btn_load_app_open -> {
                     lifecycleScope.launch {
                         AdLoad.loadAd(this@AdAppOpenActivity, Datas.APP_OPEN)
-                            .collect{
-                                if (it is AdResult.Success){
-                                    AdLoad.addToCache(it)
+                            .collect { adResult ->
+                                if (adResult is AdResult.Success) {
+                                    AdLoad.addToCache(adResult)
                                     ToastUtil.showLongToast(this@AdAppOpenActivity, "开屏广告加载成功")
                                 }
                             }
                     }
                 }
                 R.id.btn_show_app_open -> {
-                    readyGo(AppWelcomeActivity::class.java){
+                    readyGo(AppWelcomeActivity::class.java) {
                         it.putExtra(AppWelcomeActivity.ONLY_SHOW, true)
                     }
                 }
-                R.id.btn_open_bg_app_open->{
+                R.id.btn_open_bg_app_open -> {
                     Datas.bgShowAppOpen = Datas.bgShowAppOpen.not()
                     status.value = Datas.bgShowAppOpen
                 }
@@ -58,6 +57,4 @@ class AdAppOpenActivity : BaseBindingActivity<ActivityAdAppOpenBinding>(Activity
             }
         }, binding.btnLoadAppOpen, binding.btnShowAppOpen, binding.btnOpenBgAppOpen)
     }
-
-
 }

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

@@ -67,11 +67,11 @@ object Datas {
 
     val GroMoreAdUnitList: List<AdUnitBean> =
         listOf(
-            AdUnitBean(BANNER, Advertisers.GroMore.name, AdType.BANNER.name, "102138574", adSize = AdSize.Builder.create().buildGroMoreAdImageSize(600, 90)),
-            AdUnitBean(INTERSTITIAL, Advertisers.GroMore.name, AdType.INTERSTITIAL.name, "102138039"),
-            AdUnitBean(APP_OPEN, Advertisers.GroMore.name, AdType.APP_OPEN.name, "102137355"),
+            AdUnitBean(BANNER, Advertisers.GroMore.name, AdType.BANNER.name, "102217403", adSize = AdSize.Builder.create().buildGroMoreAdImageSize(600, 90)),
+            AdUnitBean(INTERSTITIAL, Advertisers.GroMore.name, AdType.INTERSTITIAL.name, "948013677"),
+            AdUnitBean(APP_OPEN, Advertisers.GroMore.name, AdType.APP_OPEN.name, "887622184"),
             AdUnitBean(REWARDED_VIDEO, Advertisers.GroMore.name, AdType.REWARDED_VIDEO.name, "102137844"),
-            AdUnitBean(NATIVE_TEMPLATE, Advertisers.GroMore.name, AdType.NATIVE_TEMPLATE.name, "102140510")
+            AdUnitBean(NATIVE_TEMPLATE, Advertisers.GroMore.name, AdType.NATIVE_TEMPLATE.name, "948013677")
         )
 
 

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

@@ -19,11 +19,9 @@ import androidx.compose.ui.unit.dp
 import androidx.navigation.NavHostController
 import com.applovin.sdk.AppLovinSdk
 import com.bumptech.glide.Glide
-import com.bytedance.msdk.api.TTMediationAdSdk
 import com.bytedance.mtesttools.api.TTMediationTestTool
 import com.composition.android.lib.ad.basic.Advertisers
 import com.convenient.android.common.extension.readyGo
-import com.convenient.android.lib.BuildConfig
 import com.convenient.android.lib.ui.sample.ad.activity.*
 import com.convenient.android.lib.ui.sample.ad.model.Datas
 import com.convenient.android.lib.ui.sample.ad.viewmodel.AdConfigViewModel
@@ -40,9 +38,9 @@ import com.convenient.android.lib.ui.sample.ad.viewmodel.AdConfigViewModel
 fun AdHomePage(viewModel: AdConfigViewModel, navHostController: NavHostController) {
 
     val list = Datas.getAdvertisers().toMutableList().apply {
-        if (!BuildConfig.FLAVOR.equals("appLovinMaxTest")) {
-            remove(Advertisers.AppLovinMax)
-        }
+//        if (!BuildConfig.FLAVOR.equals("appLovinMaxTest")) {
+//            remove(Advertisers.AppLovinMax)
+//        }
     }
 
     val registerAdvertisers = remember {
@@ -119,17 +117,13 @@ fun AdHomePage(viewModel: AdConfigViewModel, navHostController: NavHostControlle
                 }
             }
 
-            if (registerAdvertisers.value == Advertisers.GroMore ||registerAdvertisers.value == Advertisers.CSJ) {
-                Item(modifier = modifier, title = "AppLovinMax 中介测试套件") {
-//                    TTMediationAdSdk.
-                    TTMediationTestTool.launchTestTools(context) { p0, p1 ->
+            if (registerAdvertisers.value == Advertisers.GroMore || registerAdvertisers.value == Advertisers.CSJ) {
+                Item(modifier = modifier, title = "GroMore 中介测试套件") {
+                    TTMediationTestTool.launchTestTools(context) { imageView, s ->
                         Glide.with(context)
-                            .load(p1)
-                            .into(
-                                p0
-                            )
+                            .load(s)
+                            .into(imageView)
                     }
-
                 }
             }
         }

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

@@ -5,7 +5,6 @@ import androidx.lifecycle.ViewModel
 import com.ad.scope.load.ScopeAdLoader
 import com.composition.android.ad.admob.load.AdmobAdLoader
 import com.composition.android.ad.applovinmax.load.AppLovinMaxLoader
-import com.composition.android.ad.csj.load.CSJAdLoader
 import com.composition.android.ad.gromore.load.GroMoreAdLoader
 import com.composition.android.lib.ad.AdManager
 import com.composition.android.lib.ad.basic.Advertisers
@@ -34,7 +33,7 @@ class AdConfigViewModel : ViewModel() {
     fun getAdLoader(advertisers: Advertisers): AdLoader {
         return when (advertisers) {
             Advertisers.Admob -> AdmobAdLoader()
-            Advertisers.CSJ -> CSJAdLoader()
+            Advertisers.CSJ -> GroMoreAdLoader()
             Advertisers.GroMore -> GroMoreAdLoader()
             Advertisers.AppLovinMax -> AppLovinMaxLoader()
             Advertisers.AdScope -> ScopeAdLoader()

+ 4 - 12
app/src/main/res/layout/activity_ad_native_template.xml

@@ -56,26 +56,18 @@
             android:layout_height="wrap_content"
             android:orientation="vertical" />
 
-
         <androidx.appcompat.widget.AppCompatTextView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="16dp"
-            android:text="原生模板广告自行加载填充模式,在Xml NativeAdView中设置好配置, View中自动完成加载"
-            />
+            android:text="原生模板广告自行加载填充模式,在Xml NativeAdView中设置好配置, View中自动完成加载" />
 
         <com.composition.android.lib.ad.widget.NativeAdView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            app:ad_slot_name="NativeTemplate"
-            app:ad_auto_populate="true"
             app:ad_admob_native_ad_view_layout="@layout/layout_admob_native_ad_view_root"
-            app:ad_gro_more_tt_native_ad_view_layout="@layout/layout_gro_more_native_template_ad_view_root"
-            >
-
-
-        </com.composition.android.lib.ad.widget.NativeAdView>
-
+            app:ad_auto_populate="true"
+            app:ad_gro_more_tt_native_ad_view_layout="@layout/layout_admob_native_ad_view_root"
+            app:ad_slot_name="NativeTemplate" />
     </LinearLayout>
-
 </ScrollView>

+ 2 - 2
build.gradle

@@ -7,8 +7,8 @@ buildscript {
 }
 
 plugins {
-    id 'com.android.application' version '7.2.0' apply false
-    id 'com.android.library' version '7.2.0' apply false
+    id 'com.android.application' version '7.4.2' apply false
+    id 'com.android.library' version '7.4.2' apply false
     id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
     id 'org.jetbrains.kotlin.jvm' version '1.8.10' apply false
 }

+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
 #Wed Jul 27 15:06:45 CST 2022
 distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
 distributionPath=wrapper/dists
 zipStorePath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME

+ 4 - 4
keystore.properties

@@ -1,4 +1,4 @@
-keystore=/Users/kdan/git_work/keystore/PDF_Reader_Pro_Keystore/pdfreaderpro.jks
-keystore.password=pdfpro777777
-keyAlias=propropro
-keyAlias.password=pdfpro7896541230
+keystore=/Users/hubowen/Git_Work/Kdan/Kdan_Librarys/app_keys/17PDF_Reader_old/pdfreader.keystore
+keystore.password=kdan24373514
+keyAlias=noteledgekey
+keyAlias.password=2437key3514

+ 8 - 7
lib_ad_core/build.gradle

@@ -2,7 +2,8 @@ plugins {
     id 'com.android.library'
     id 'org.jetbrains.kotlin.android'
 }
-def version = '1.0.1'
+def version = '1.0.2'
+
 def releaseTime() {
     return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
 }
@@ -35,7 +36,7 @@ android {
             minifyEnabled true
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
 
-            libraryVariants.all { variant->
+            libraryVariants.all { variant ->
                 variant.outputs.all { output ->
                     if (outputFile != null && outputFileName.endsWith('.aar')) {
                         outputFileName = "ad_core_${version}_${releaseTime()}_release.aar"
@@ -54,16 +55,16 @@ android {
 }
 
 dependencies {
-    testImplementation 'junit:junit:4.13.2'
-    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
-    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
     /*Base*/
     api 'androidx.appcompat:appcompat:1.6.1'
     api 'com.google.android.material:material:1.8.0'
     /*Kotlin*/
     api "androidx.core:core-ktx:1.10.0"
     api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
-    api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.3'
+    api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
     api 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
-    api("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
+    api 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
+    /*GroMore*/
+    api 'com.pangle.cn:mediation-sdk:5.1.6.1'
+    api 'com.pangle.cn:mediation-test-tools:5.1.6.1'//测试工具
 }

+ 7 - 13
lib_ad_core/src/androidTest/java/com/composition/android/lib/ad/ExampleInstrumentedTest.kt

@@ -1,22 +1,16 @@
 package com.composition.android.lib.ad
 
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.platform.app.InstrumentationRegistry
-import org.junit.Assert.*
-import org.junit.Test
-import org.junit.runner.RunWith
-
 /**
  * Instrumented test, which will execute on an Android device.
  *
  * See [testing documentation](http://d.android.com/tools/testing).
  */
-@RunWith(AndroidJUnit4::class)
+//@RunWith(AndroidJUnit4::class)
 class ExampleInstrumentedTest {
-    @Test
-    fun useAppContext() {
-        // Context of the app under test.
-        val appContext = InstrumentationRegistry.getInstrumentation().targetContext
-        assertEquals("com.composition.android.lib.ad.test", appContext.packageName)
-    }
+//    @Test
+//    fun useAppContext() {
+//        // Context of the app under test.
+//        val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+//        assertEquals("com.composition.android.lib.ad.test", appContext.packageName)
+//    }
 }

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

@@ -15,17 +15,17 @@ import com.composition.android.lib.ad.interfaces.IAdSize
  * 一个广告位,包含使用的广告位名称,广告商、广告类型、广告ID、加载配置、展示配置
  */
 open class AdUnitBean(
-    var adSlotName : String,
+    var adSlotName: String,
     var advertisersName: String,
     var adType: String,
     var adUnitId: String,
-    var adSize : IAdSize<*>?  = null,
-    var loadStrategy : IStrategy = NormalStrategy(),
-    var requestAdConfig: AdUnitLoadConfig = AdUnitLoadConfig()
-) : java.io.Serializable{
+    var adSize: IAdSize<*>? = null,
+    var loadStrategy: IStrategy = NormalStrategy(),
+    var requestAdConfig: AdUnitLoadConfig = AdUnitLoadConfig(),
+) : java.io.Serializable {
 
-    companion object{
-        fun emptyAdUnitBean() : AdUnitBean = AdUnitBean(adSlotName = "", advertisersName = "", adType = "", adUnitId = "")
+    companion object {
+        fun emptyAdUnitBean(): AdUnitBean = AdUnitBean(adSlotName = "", advertisersName = "", adType = "", adUnitId = "")
     }
 
     /**
@@ -33,7 +33,10 @@ open class AdUnitBean(
      */
     fun getAdvertisers(): Advertisers {
         return try {
-            Advertisers.valueOf(advertisersName)
+            when (Advertisers.CSJ) {
+                Advertisers.valueOf(advertisersName) -> Advertisers.GroMore
+                else -> Advertisers.valueOf(advertisersName)
+            }
         } catch (e: Exception) {
             Advertisers.UNKNOWN
         }
@@ -44,21 +47,21 @@ open class AdUnitBean(
     }
 
     override fun equals(other: Any?): Boolean {
-        return when(other){
-            !is AdUnitBean-> false
-            else-> this === other || this.adSlotName.equals(other.adSlotName) && this.advertisersName.equals(other.advertisersName) && this.adType.equals(other.adType) && this.adUnitId.equals(other.adUnitId)
+        return when (other) {
+            !is AdUnitBean -> false
+            else -> this === other || this.adSlotName.equals(other.adSlotName) && this.advertisersName.equals(other.advertisersName) && this.adType.equals(other.adType) && this.adUnitId.equals(other.adUnitId)
         }
     }
 
-    fun getAdType() : AdType{
+    fun getAdType(): AdType {
         return try {
             AdType.valueOf(adType)
-        }catch (e : Exception){
+        } catch (e: Exception) {
             AdType.UNKNOWN
         }
     }
 
-    fun isAvailable() : Boolean{
+    fun isAvailable(): Boolean {
         return adUnitId.isNotEmpty() && advertisersName.isNotEmpty() && adType.isNotEmpty() && adSlotName.isNotEmpty()
     }
 

+ 9 - 13
lib_ad_core/src/test/java/com/composition/android/lib/ad/ExampleUnitTest.kt

@@ -1,22 +1,18 @@
 package com.composition.android.lib.ad
 
-import com.composition.android.lib.ad.basic.Advertisers
-
-import org.junit.Test
-
 /**
  * Example local unit test, which will execute on the development machine (host).
  *
  * See [testing documentation](http://d.android.com/tools/testing).
  */
 class ExampleUnitTest {
-    @Test
-    fun addition_isCorrect() {
-        val advertisers = try {
-            Advertisers.valueOf("sdf")
-        }catch (e : Exception){
-            Advertisers.UNKNOWN
-        }
-       println(advertisers.name)
-    }
+//    @Test
+//    fun addition_isCorrect() {
+//        val advertisers = try {
+//            Advertisers.valueOf("sdf")
+//        }catch (e : Exception){
+//            Advertisers.UNKNOWN
+//        }
+//       println(advertisers.name)
+//    }
 }

+ 1 - 1
lib_ad_csj/build.gradle

@@ -57,6 +57,6 @@ dependencies {
     implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
     implementation project(':lib_ad_core')
 
-    api 'com.pangle.cn:ads-sdk-pro:5.1.0.2'
+//    implementation 'com.pangle.cn:ads-sdk-pro:5.3.0.3'
     implementation 'androidx.legacy:legacy-support-v4:1.0.0'
 }

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

@@ -16,9 +16,7 @@ import com.composition.android.lib.ad.util.adLogE
  * description:穿山甲广告SDK初始化
  */
 class CSJInitialize(var appId: String) : Initialize {
-
     override fun init(context: Context) {
-
         TTAdSdk.init(context, TTAdConfig.Builder()
             .appId(appId)
             .useTextureView(true)
@@ -27,8 +25,6 @@ class CSJInitialize(var appId: String) : Initialize {
             .allowShowNotify(true)
             .debug(AdManager.instance.isDebug)
             .supportMultiProcess(false)
-            .asyncInit(true)
-            .needClearTaskReset()
             .customController(object : TTCustomController() {
                 override fun getMacAddress(): String {
                     return ""
@@ -41,8 +37,6 @@ class CSJInitialize(var appId: String) : Initialize {
                 override fun isCanUseAndroidId(): Boolean {
                     return false
                 }
-
-
             })
             .build(), object : TTAdSdk.InitCallback {
             override fun success() {
@@ -51,12 +45,7 @@ class CSJInitialize(var appId: String) : Initialize {
 
             override fun fail(p0: Int, p1: String?) {
                 adLogE(AdManager.TAG, "穿山甲广告SDK初始化失败:${p1}")
-
             }
-
         })
-
     }
-
-
 }

+ 26 - 29
lib_ad_gromore/build.gradle

@@ -2,7 +2,8 @@ plugins {
     id 'com.android.library'
     id 'org.jetbrains.kotlin.android'
 }
-def version = '1.0.1'
+def version = '1.0.2'
+
 def releaseTime() {
     return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
 }
@@ -21,10 +22,9 @@ android {
 
 
     buildTypes {
-
         debug {
-            libraryVariants.all { variant->
-                variant.outputs.all { output->
+            libraryVariants.all { variant ->
+                variant.outputs.all { output ->
                     if (outputFile != null && outputFileName.endsWith('.aar')) {
                         outputFileName = "ad_gromore_${version}_${releaseTime()}_debug.aar"
                     }
@@ -34,8 +34,8 @@ android {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
-            libraryVariants.all { variant->
-                variant.outputs.all { output->
+            libraryVariants.all { variant ->
+                variant.outputs.all { output ->
                     if (outputFile != null && outputFileName.endsWith('.aar')) {
                         outputFileName = "ad_gromore_${version}_${releaseTime()}_release.aar"
                     }
@@ -45,7 +45,6 @@ android {
     }
 
 
-
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
@@ -57,32 +56,30 @@ android {
 }
 
 
-
-
 dependencies {
 
     implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
 
     implementation project(':lib_ad_core')
 
-    api "by.gm_mediation.com:gromore-sdk:4.0.0.1"
-    api "by.gm_mediation.com:pangle-adapter:5.1.0.2.0"
-    api 'com.pangle.cn:ads-sdk-pro:5.1.0.2'
-
-    //mintegral
-    api("com.mbridge.msdk.support:videojs:16.3.27")
-    api("com.mbridge.msdk.support:mbjscommon:16.3.27")
-    api("com.mbridge.msdk.support:playercommon:16.3.27")
-    api("com.mbridge.msdk.support:reward:16.3.27")
-    api("com.mbridge.msdk.support:videocommon:16.3.27")
-    api("com.mbridge.msdk.support:chinasame:16.3.27")
-    api("com.mbridge.msdk.support:interstitialvideo:16.3.27")
-    api("com.mbridge.msdk.support:mbnative:16.3.27")
-    api("com.mbridge.msdk.support:nativeex:16.3.27")
-    api("com.mbridge.msdk.support:mbnativeadvanced:16.3.27")
-    api("com.mbridge.msdk.support:interstitial:16.3.27")
-    api("com.mbridge.msdk.support:mbbanner:16.3.27")
-    api("com.mbridge.msdk.support:mbsplash:16.3.27")
-    api("com.mbridge.msdk.support:mbbid:16.3.27")
-    api("com.mbridge.msdk.support:newinterstitial:16.3.27")
+    /*GroMore*/
+//    api "com.pangle.cn:mediation-sdk:5.1.6.1"
+
+    //融合SDK
+
+//    implementation "com.pangle.cn:mediation-ks-adapter:3.3.40.3"//ks adapter
+//
+//    implementation "com.pangle.cn:mediation-gdt-adapter:4.514.1384.2" //gdt adapter
+//
+//    implementation "com.pangle.cn:mediation-admob-adapter:17.2.0.42"//admob adapter
+//
+//    implementation "com.pangle.cn:mediation-baidu-adapter:9.271.1"//baidu adapter
+//
+//    implementation "com.pangle.cn:mediation-klevin-adapter:2.11.0.3.4"//游可赢 adapter
+//
+//    implementation "com.pangle.cn:mediation-mintegral-adapter:16.4.17.1"//mintegral adapter
+//
+//    api "com.pangle.cn:mediation-sigmob-adapter:4.9.0.4"//sigmob adapter
+//
+//    implementation "com.pangle.cn:mediation-unity-adapter:4.3.0.10"//unity adapter
 }

+ 10 - 26
lib_ad_gromore/src/main/AndroidManifest.xml

@@ -22,31 +22,15 @@
     <uses-permission android:name="android.permission.WAKE_LOCK" />
 
 
-    <application
-       >
-
-<!--        <activity-->
-<!--            android:name="com.baidu.mobads.sdk.api.AppActivity"-->
-<!--            android:configChanges="screenSize|keyboard|keyboardHidden|orientation"-->
-<!--            android:theme="@android:style/Theme.NoTitleBar"/>-->
-<!--        &lt;!&ndash; 声明打开显示激励视频/全屏视频的Activity&ndash;&gt;-->
-<!--        <activity-->
-<!--            android:name="com.baidu.mobads.sdk.api.MobRewardVideoActivity"-->
-<!--            android:configChanges="screenSize|orientation|keyboardHidden"-->
-<!--            android:launchMode="singleTask"-->
-<!--            android:theme="@android:style/Theme.Translucent.NoTitleBar" />-->
-
-<!--        &lt;!&ndash; 如果targetSdkVersion设置值>=24,则强烈建议添加以下provider,否则会影响app变现 &ndash;&gt;-->
-<!--        &lt;!&ndash; android:authorities="${packageName}.bd.provider" authorities中${packageName}部分必须替换成app自己的包名 &ndash;&gt;-->
-<!--        &lt;!&ndash; 原来的FileProvider在新版本中改为BdFileProvider,继承自v4的FileProvider,需要在应用内引用support-v4包 &ndash;&gt;-->
-<!--        <provider-->
-<!--            android:name="com.baidu.mobads.sdk.api.BdFileProvider"-->
-<!--            android:authorities="${applicationId}.bd.provider"-->
-<!--            android:exported="false"-->
-<!--            android:grantUriPermissions="true">-->
-<!--            <meta-data-->
-<!--                android:name="android.support.FILE_PROVIDER_PATHS"-->
-<!--                android:resource="@xml/bd_file_paths" />-->
-<!--        </provider>-->
+    <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>

+ 41 - 0
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/impl/CSJAppDownloadListener.kt

@@ -0,0 +1,41 @@
+package com.composition.android.ad.gromore.impl
+
+import android.content.Context
+import com.bytedance.sdk.openadsdk.TTAppDownloadListener
+import com.composition.android.ad.gromore.R
+import com.composition.android.lib.ad.basic.NativeAdViewHolder
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/10/25
+ * description:穿山甲广告下载监听
+ */
+class CSJAppDownloadListener(var context: Context, var nativeAdViewHolder: NativeAdViewHolder?) : TTAppDownloadListener {
+    override fun onIdle() {
+        nativeAdViewHolder?.callActionButtonView?.text = context.getString(R.string.start_download)
+    }
+
+    override fun onDownloadActive(p0: Long, p1: Long, p2: String?, p3: String?) {
+        nativeAdViewHolder?.callActionButtonView?.text = context.getString(R.string.downloading)
+    }
+
+    override fun onDownloadPaused(p0: Long, p1: Long, p2: String?, p3: String?) {
+        nativeAdViewHolder?.callActionButtonView?.text = context.getString(R.string.download_pause)
+    }
+
+    override fun onDownloadFailed(p0: Long, p1: Long, p2: String?, p3: String?) {
+        nativeAdViewHolder?.callActionButtonView?.text = context.getString(R.string.download_again)
+
+    }
+
+    override fun onDownloadFinished(p0: Long, p1: String?, p2: String?) {
+        nativeAdViewHolder?.callActionButtonView?.text = context.getString(R.string.click_to_open)
+
+    }
+
+    override fun onInstalled(p0: String?, p1: String?) {
+        nativeAdViewHolder?.callActionButtonView?.text = context.getString(R.string.click_to_install)
+
+    }
+}

+ 20 - 32
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/impl/GroMoreInitialize.kt

@@ -1,9 +1,11 @@
 package com.composition.android.ad.gromore.impl
 
 import android.content.Context
-import com.bytedance.msdk.api.v2.*
+import com.bytedance.sdk.openadsdk.TTAdConfig
+import com.bytedance.sdk.openadsdk.TTAdSdk
 import com.composition.android.lib.ad.AdManager
 import com.composition.android.lib.ad.interfaces.Initialize
+import com.composition.android.lib.ad.util.adLogE
 
 /**
  * @classname:
@@ -11,39 +13,25 @@ import com.composition.android.lib.ad.interfaces.Initialize
  * @date: 2022/9/15
  * description:GroMore SDK初始化
  */
-class GroMoreInitialize(var appId : String) : Initialize {
-
+class GroMoreInitialize(var appId: String) : Initialize {
 
     override fun init(context: Context) {
+        TTAdSdk.init(context, TTAdConfig.Builder()
+            .appId(appId)
+            .useTextureView(true)
+            .appName(context.packageName)
+            .supportMultiProcess(true)
+            .debug(AdManager.instance.isDebug)
+            .useMediation(true)
+            .build(), object : TTAdSdk.InitCallback {
+            override fun success() {
+                TTAdSdk.isInitSuccess()
+                adLogE(AdManager.TAG, "GroMoreSDK初始化完成 ---- 版本号:${TTAdSdk.getAdManager().sdkVersion}")
+            }
 
-        GMMediationAdSdk.initialize(context, GMAdConfig.Builder()
-            .setAppId(appId)
-            .setAppName(context.packageName)
-            .setDebug(AdManager.instance.isDebug)
-            .setOpenAdnTest(false)
-            .setPangleOption(GMPangleOption.Builder()
-                .setIsPaid(false)
-                .setTitleBarTheme(GMAdConstant.TITLE_BAR_THEME_DARK)
-                .setAllowShowNotify(true)
-                .setAllowShowPageWhenScreenLock(true)
-                .setDirectDownloadNetworkType(GMAdConstant.NETWORK_STATE_WIFI)
-                .setIsUseTextureView(true)
-                .setNeedClearTaskReset()
-                .setKeywords("")
-                .build())
-            .setPrivacyConfig(object : GMPrivacyConfig(){
-                override fun isCanUsePhoneState(): Boolean {
-                    return false
-                }
-
-                override fun getMacAddress(): String {
-                    return ""
-                }
-
-                override fun getAgeGroup(): GMAdConstant.ADULT_STATE {
-                    return GMAdConstant.ADULT_STATE.AGE_ADULT
-                }
-            })
-            .build())
+            override fun fail(p0: Int, p1: String?) {
+                adLogE(AdManager.TAG, "GroMoreSDK初始化失败")
+            }
+        })
     }
 }

+ 127 - 128
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/GroMoreAdLoader.kt

@@ -2,31 +2,37 @@ package com.composition.android.ad.gromore.load
 
 import android.app.Activity
 import android.content.Context
+import android.os.Bundle
 import android.view.View
 import android.view.ViewGroup
-import com.bytedance.msdk.api.AdError
-import com.bytedance.msdk.api.format.TTNativeAdView
-import com.bytedance.msdk.api.reward.RewardItem
-import com.bytedance.msdk.api.v2.ad.banner.GMBannerAd
-import com.bytedance.msdk.api.v2.ad.interstitialFull.GMInterstitialFullAd
-import com.bytedance.msdk.api.v2.ad.interstitialFull.GMInterstitialFullAdListener
-import com.bytedance.msdk.api.v2.ad.nativeAd.GMNativeAd
-import com.bytedance.msdk.api.v2.ad.nativeAd.GMUnifiedNativeAd
-import com.bytedance.msdk.api.v2.ad.reward.GMRewardAd
-import com.bytedance.msdk.api.v2.ad.reward.GMRewardedAdListener
-import com.bytedance.msdk.api.v2.ad.splash.GMSplashAd
-import com.bytedance.msdk.api.v2.ad.splash.GMSplashAdListener
-import com.composition.android.ad.gromore.load.request.*
+import com.bytedance.sdk.openadsdk.TTAdConstant
+import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd
+import com.bytedance.sdk.openadsdk.TTNativeAd
+import com.bytedance.sdk.openadsdk.TTNativeExpressAd
+import com.bytedance.sdk.openadsdk.TTRewardVideoAd
+import com.bytedance.sdk.openadsdk.TTSplashAd
+import com.composition.android.ad.gromore.load.request.GMAppOpenRequestImpl
+import com.composition.android.ad.gromore.load.request.GMBannerRequestImpl
+import com.composition.android.ad.gromore.load.request.GMInterstitialRequestImpl
+import com.composition.android.ad.gromore.load.request.GMNativeRequestImpl
+import com.composition.android.ad.gromore.load.request.GMNativeTemplateRequestImpl
+import com.composition.android.ad.gromore.load.request.GMRewardRequestImpl
+import com.composition.android.ad.gromore.load.view.CSJNativeAdView
 import com.composition.android.ad.gromore.load.view.GMBannerView
 import com.composition.android.ad.gromore.load.view.GMNativeTemplateAdView
 import com.composition.android.lib.ad.AdManager
-import com.composition.android.lib.ad.basic.*
+import com.composition.android.lib.ad.basic.AdResult
+import com.composition.android.lib.ad.basic.AdType
+import com.composition.android.lib.ad.basic.Advertisers
+import com.composition.android.lib.ad.basic.BannerAdViewHolder
+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
-import com.composition.android.lib.ad.util.adLog
 import com.composition.android.lib.ad.util.adLogE
 import com.composition.android.lib.ad.util.adLogWithFrame
+import com.composition.android.lib.ad.util.parentRemove
 
 /**
  * @classname:
@@ -46,6 +52,7 @@ class GroMoreAdLoader : AdLoader {
     override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
         val adRequest = when (adUnitBean.getAdType()) {
             AdType.BANNER -> GMBannerRequestImpl()
+            AdType.NATIVE -> GMNativeRequestImpl()
             AdType.NATIVE_TEMPLATE -> GMNativeTemplateRequestImpl()
             AdType.INTERSTITIAL, AdType.REWARDED_INTERSTITIAL -> GMInterstitialRequestImpl()
             AdType.REWARDED_VIDEO -> GMRewardRequestImpl()
@@ -71,190 +78,182 @@ class GroMoreAdLoader : AdLoader {
     }
 
     override fun getNativeAdView(context: Context, adResult: AdResult.Success, viewHolder: NativeAdViewHolder): View? {
-        return if (adResult.adObject != null){
-            when(adResult.adBean.getAdType()){
-                AdType.NATIVE_TEMPLATE ->{
+        return if (adResult.adObject != null) {
+            AdManager.instance.globalListener?.invoke(adResult.adBean)
+            when (adResult.adBean.getAdType()) {
+                AdType.NATIVE -> {
+                    CSJNativeAdView(context).apply {
+                        setViewHolder(viewHolder)
+                        render(adResult)
+                    }
+                }
+
+                AdType.NATIVE_TEMPLATE -> {
                     GMNativeTemplateAdView(context).apply {
                         setViewHolder(viewHolder)
                         render(adResult)
-                        AdManager.instance.globalListener?.invoke(adResult.adBean)
                     }
                 }
-                else->null
+
+                else -> {
+                    null
+                }
             }
-        }else{
+        } else {
             null
         }
     }
 
+    override fun populateNativeAdView(context: Context, adResult: AdResult.Success, viewHolder: NativeAdViewHolder, advertisersContainerView: ViewGroup) {
+        AdManager.instance.globalListener?.invoke(adResult.adBean)
+        when (adResult.adBean.getAdType()) {
+            AdType.NATIVE -> {
+                CSJNativeAdView.populateNativeAdView(context = context, adResult, viewHolder, advertisersContainerView)
+            }
 
+            AdType.NATIVE_TEMPLATE -> {
+                val ttNativeExpressAd = adResult.adObject as TTNativeExpressAd
+                advertisersContainerView.removeAllViews()
+                val expressAdView = ttNativeExpressAd.expressAdView
+                expressAdView.parentRemove()
+                advertisersContainerView.addView(expressAdView)
+                GMNativeTemplateAdView.populateNativeTemplateAdView(context, adResult, viewHolder)
+            }
 
-    override fun populateNativeAdView(context: Context, adResult: AdResult.Success, viewHolder: NativeAdViewHolder, advertisersContainerView: ViewGroup) {
-        if (advertisersContainerView is TTNativeAdView) {
-            val gmNativeAd = adResult?.adObject as? GMNativeAd
-            advertisersContainerView.removeAllViews()
-            advertisersContainerView.addView(gmNativeAd?.expressView)
-            GMNativeTemplateAdView.populateNativeAdView(context, adResult, viewHolder, advertisersContainerView)
-        } else {
-            adLogE(AdManager.TAG, "GroMore广告-原生模板-填充失败, adRootView错误,当前类型为${advertisersContainerView.javaClass.simpleName},需要为${TTNativeAdView::class.java.simpleName}")
+            else -> {
+                adLogE(tag = AdManager.TAG, msg = "GroMore-填充原生,adType类型错误,不支持")
+            }
         }
     }
 
     override fun showInterstitialAd(activity: Activity, adResult: AdResult.Success, adListener: AdListener) {
-        if (adResult.adObject is GMInterstitialFullAd) {
-            val mInterstitialFullAd = adResult.adObject as GMInterstitialFullAd
-            mInterstitialFullAd.setAdInterstitialFullListener(object : GMInterstitialFullAdListener {
-                override fun onInterstitialFullShow() {
-                    adLogWithFrame(msg = "GorMore广告-插屏-展示")
+        if (adResult.adObject is TTFullScreenVideoAd) {
+            val ttFullScreenVideoAd = adResult.adObject as TTFullScreenVideoAd
+            ttFullScreenVideoAd.setFullScreenVideoAdInteractionListener(object : TTFullScreenVideoAd.FullScreenVideoAdInteractionListener {
+                override fun onAdShow() {
+                    adLogWithFrame(msg = "GroMore-插屏-展示")
                     adListener.onAdShow(adResult.adBean)
                     AdManager.instance.globalListener?.invoke(adResult.adBean)
                 }
 
-                override fun onInterstitialFullShowFail(p0: AdError) {
-                    adLogWithFrame(msg = "GorMore广告-插屏-展示失败")
-                    adListener.onAdShowFail("GorMore广告-插屏-展示失败\n${p0.message}")
-                }
-
-                override fun onInterstitialFullClick() {
-                    adLogWithFrame(msg = "GorMore广告-插屏-点击")
+                override fun onAdVideoBarClick() {
+                    adLogWithFrame(msg = "GroMore-插屏-点击")
                     adListener.onAdClick()
                 }
 
-                override fun onInterstitialFullClosed() {
-                    adLogWithFrame(msg = "GorMore广告-插屏-关闭")
+                override fun onAdClose() {
+                    adLogWithFrame(msg = "GroMore-插屏-关闭")
                     adListener.onAdClose()
+                    destroyAd(adResult)
                 }
 
                 override fun onVideoComplete() {
-                }
 
-                override fun onVideoError() {
                 }
 
                 override fun onSkippedVideo() {
-                    adLogWithFrame(msg = "GorMore广告-插屏-跳过")
+                    adLogWithFrame(msg = "GroMore-插屏-视频跳过")
                     adListener.onAdSkip()
                 }
-
-                override fun onAdOpened() {
-                }
-
-                override fun onAdLeftApplication() {
-                }
-
-                override fun onRewardVerify(p0: RewardItem) {
-                    adLogWithFrame(msg = "GorMore广告-插屏-获取奖励")
-                    adListener.onAdRewarded()
-                }
-
             })
-            mInterstitialFullAd.showAd(activity)
-
+            ttFullScreenVideoAd.showFullScreenVideoAd(activity, TTAdConstant.RitScenes.CUSTOMIZE_SCENES, null)
         } else {
-            adLogWithFrame(msg = "GorMore广告-插屏-展示失败:类型错误,adObject类型错误或为空:${adResult.adObject?.javaClass?.simpleName}")
-            adListener.onAdShowFail("GorMore广告-插屏-加载失败:类型错误,adObject类型错误或为空:${adResult.adObject?.javaClass?.simpleName}")
+            adLogWithFrame(
+                msg = "GroMore-插屏-错误-类型错误,当前为:${adResult.adObject?.javaClass?.simpleName}, 应该为:TTNativeExpressAd"
+            )
+            adListener.onAdShowFail("类型错误,当前为:${adResult.adObject?.javaClass?.simpleName}, 应该为:TTNativeExpressAd")
         }
     }
 
     override fun showRewardedAd(activity: Activity, adResult: AdResult.Success, adListener: AdListener) {
-        if (adResult.adObject is GMRewardAd) {
-            val gmRewardAd = adResult.adObject as GMRewardAd
-            gmRewardAd.setRewardAdListener(object : GMRewardedAdListener {
-                override fun onRewardedAdShow() {
-                    adLogWithFrame(msg = "GroMore广告-激励视频-展示")
+        if (adResult.adObject is TTRewardVideoAd) {
+            val ttRewardVideoAd = adResult.adObject as TTRewardVideoAd
+            ttRewardVideoAd.setRewardAdInteractionListener(object : TTRewardVideoAd.RewardAdInteractionListener {
+                override fun onAdShow() {
+                    adLogWithFrame(msg = "GroMore-激励视频-展示")
                     adListener.onAdShow(adResult.adBean)
                     AdManager.instance.globalListener?.invoke(adResult.adBean)
                 }
 
-                override fun onRewardedAdShowFail(p0: AdError) {
-                    adLogWithFrame(msg = "GroMore广告-激励视频-展示失败\n${p0.message}")
-                    adListener.onAdShowFail("GroMore广告-激励视频-展示失败\n${p0.message}")
-                }
-
-                override fun onRewardClick() {
-                    adLogWithFrame(msg = "GroMore广告-激励视频-点击")
+                override fun onAdVideoBarClick() {
+                    adLogWithFrame(msg = "GroMore-激励视频-点击")
                     adListener.onAdClick()
                 }
 
-                override fun onRewardedAdClosed() {
-                    adLogWithFrame(msg = "GroMore广告-激励视频-关闭")
+                override fun onAdClose() {
+                    adLogWithFrame(msg = "GroMore-激励视频-关闭")
                     adListener.onAdClose()
+                    destroyAd(adResult)
                 }
 
                 override fun onVideoComplete() {
+
                 }
 
                 override fun onVideoError() {
+                    adLogWithFrame(msg = "GroMore-激励视频-视频异常")
                 }
 
-                override fun onRewardVerify(p0: RewardItem) {
-                    adLogWithFrame(msg = "GroMore广告-激励视频-获取奖励")
+                override fun onRewardVerify(p0: Boolean, p1: Int, p2: String?, p3: Int, p4: String?) {
+                    adLogWithFrame(msg = "GroMore-激励视频-获取奖励")
                     adListener.onAdRewarded()
                 }
 
+                override fun onRewardArrived(p0: Boolean, p1: Int, p2: Bundle?) {
+
+                }
+
                 override fun onSkippedVideo() {
-                    adLogWithFrame(msg = "GroMore广告-激励视频-跳过")
+                    adLogWithFrame(msg = "GroMore-激励视频-视频跳过")
                     adListener.onAdSkip()
                 }
             })
-
-            if (gmRewardAd.isReady) {
-                gmRewardAd.showRewardAd(activity)
-            } else {
-                adListener.onAdShowFail("GroMore广告-激励视频-实例还未准备完成,显示失败")
-            }
+            ttRewardVideoAd.showRewardVideoAd(activity)
         } else {
-            adLogWithFrame(msg = "GorMore广告-激励视频-展示失败:类型错误,adObject类型错误或为空:${adResult.adObject?.javaClass?.simpleName}")
-            adListener.onAdShowFail("GorMore广告-激励视频-加载失败:类型错误,adObject类型错误或为空:${adResult.adObject?.javaClass?.simpleName}")
+            adLogWithFrame(
+                msg = "穿山甲广告-激励视频-异常-类型错误,当前类型为:${adResult.adObject?.javaClass?.simpleName}, 应为:TTRewardVideoAd"
+            )
+            adListener.onAdShowFail("类型错误,当前类型为:${adResult.adObject?.javaClass?.simpleName}, 应为:TTRewardVideoAd")
         }
-
     }
 
     override fun showRewardedInterstitialAd(activity: Activity, adResult: AdResult.Success, adListener: AdListener) {
-        adLogWithFrame(msg = "GorMore广告-激励插屏-展示失败:不支持激励插屏广告")
-        adListener.onAdShowFail("GorMore广告-激励插屏-展示失败:不支持激励插屏广告")
+        adLogWithFrame(msg = "GroMore-激励插屏-不支持的广告类型")
+        adListener.onAdShowFail("GroMore广告不支持激励插屏广告,请使用激励视频广告")
     }
 
     override fun showSplashAd(activity: Activity, splashViewGroup: ViewGroup?, adResult: AdResult.Success, adListener: AdListener) {
-        if (adResult.adObject is GMSplashAd) {
-            val gmAppOpenAd = adResult.adObject as GMSplashAd
-            if (gmAppOpenAd.isReady) {
-                gmAppOpenAd.setAdSplashListener(object : GMSplashAdListener {
-                    override fun onAdClicked() {
-                        adLogWithFrame(msg = "GroMore广告-开屏-点击")
-                        adListener.onAdClick()
-                    }
+        if (adResult.adObject is TTSplashAd) {
+            val ttSplashAd = adResult.adObject as TTSplashAd
+            ttSplashAd.setSplashInteractionListener(object : TTSplashAd.AdInteractionListener {
+                override fun onAdClicked(p0: View?, p1: Int) {
+                    adLogWithFrame(msg = "GroMore-开屏-点击")
+                    adListener.onAdClick()
+                }
 
-                    override fun onAdShow() {
-                        adLogWithFrame(msg = "GroMore广告-开屏-展示")
-                        adListener.onAdShow(adResult.adBean)
-                        AdManager.instance.globalListener?.invoke(adResult.adBean)
-                    }
+                override fun onAdShow(p0: View?, p1: Int) {
+                    adLogWithFrame(msg = "GroMore-开屏-展示")
+                    adListener.onAdShow(adResult.adBean)
+                    AdManager.instance.globalListener?.invoke(adResult.adBean)
+                }
 
-                    override fun onAdShowFail(p0: AdError) {
-                        adLogWithFrame(msg = "GroMore广告-开屏-展示失败\n${p0.message}")
-                        adListener.onAdShowFail("GroMore广告-开屏-展示失败\n${p0.message}")
-                    }
+                override fun onAdSkip() {
+                    adLogWithFrame(msg = "GroMore-开屏-跳过")
+                    adListener.onAdSkip()
+                    destroyAd(adResult)
 
-                    override fun onAdSkip() {
-                        adLogWithFrame(msg = "GroMore广告-开屏-跳过")
-                        adListener.onAdSkip()
-                        gmAppOpenAd.destroy()
-                        adResult.adObject = null
-                    }
+                }
 
-                    override fun onAdDismiss() {
-                        adLogWithFrame(msg = "GroMore广告-开屏-关闭")
-                        adListener.onAdClose()
-                        gmAppOpenAd.destroy()
-                        adResult.adObject = null
-                    }
-                })
-                gmAppOpenAd.showAd(splashViewGroup)
-            }
+                override fun onAdTimeOver() {
+                    adLogWithFrame(msg = "GroMore-开屏-超时")
+                    adListener.onTimeOver()
+                }
+            })
+            splashViewGroup?.removeAllViews()
+            splashViewGroup?.addView(ttSplashAd.splashView)
         } else {
-            adLogWithFrame(msg = "GorMore广告-开屏-展示失败:类型错误,adObject类型错误或为空:${adResult.adObject?.javaClass?.simpleName}")
-            adListener.onAdShowFail("GorMore广告-激励视频-加载失败:类型错误,adObject类型错误或为空:${adResult.adObject?.javaClass?.simpleName}")
+            adLogWithFrame(msg = "GroMore-开屏-异常-类型错误,当前类型为:${adResult.adObject?.javaClass?.simpleName}, 应为:TTRewardVideoAd")
+            adListener.onAdShowFail("类型错误,当前类型为:${adResult.adObject?.javaClass?.simpleName}, 应为:TTRewardVideoAd")
         }
     }
 
@@ -273,15 +272,15 @@ class GroMoreAdLoader : AdLoader {
         try {
             if (adResult is AdResult.Success) {
                 when (val ad = adResult.adObject) {
-                    is GMBannerAd -> ad.destroy()
-                    is GMUnifiedNativeAd -> ad.destroy()
+                    is TTNativeExpressAd -> ad.destroy()
+                    is TTNativeAd -> ad.destroy()
                     else -> {}
                 }
                 adResult.adObject = null
             }
             adLogWithFrame(msg = "GroMore广告-销毁广告对象完成")
-        }catch (e : Exception){
-
+        } catch (e: Exception) {
+            e.printStackTrace()
         }
     }
 }

+ 22 - 32
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMAppOpenRequestImpl.kt

@@ -2,12 +2,7 @@ package com.composition.android.ad.gromore.load.request
 
 import android.app.Activity
 import android.content.Context
-import com.bytedance.msdk.api.AdError
-import com.bytedance.msdk.api.v2.ad.splash.GMSplashAd
-import com.bytedance.msdk.api.v2.ad.splash.GMSplashAdLoadCallback
-import com.bytedance.msdk.api.v2.slot.GMAdSlotSplash
-import com.composition.android.ad.gromore.util.GMSettingConfig
-import com.composition.android.lib.ad.AdManager
+import com.bytedance.sdk.openadsdk.*
 import com.composition.android.lib.ad.basic.AdResult
 import com.composition.android.lib.ad.bean.AdUnitBean
 import com.composition.android.lib.ad.interfaces.IAdFormatRequest
@@ -24,36 +19,31 @@ class GMAppOpenRequestImpl : IAdFormatRequest {
     override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
         return suspendCancellableCoroutine {
             if (context is Activity) {
-                GMSettingConfig.loadAdConfig {
-                    val mTTSplashAd = GMSplashAd(context, adUnitBean.adUnitId)
-                    mTTSplashAd.loadAd(
-                        GMAdSlotSplash.Builder()
-                            .setImageAdSize(getScreenWidth(context), getScreenHeight(context))
-                            .setVolume(1F)
-                            .setMuted(false)
-                            .setTimeOut(3000)
-                            .setSplashShakeButton(true)
-                            .build(),
-                        object : GMSplashAdLoadCallback {
-                            override fun onSplashAdLoadFail(p0: AdError) {
-                                printAdFailInfo(adUnitBean, p0.code, p0.message)
-                                it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore广告-开屏-加载失败"))
-                            }
+                val adSlot = AdSlot.Builder()
+                    .setCodeId(adUnitBean.adUnitId)
+                    .setImageAcceptedSize(getScreenWidth(context), getScreenHeight(context))
+                    .setAdLoadType(TTAdLoadType.PRELOAD)
+                    .build()
 
-                            override fun onSplashAdLoadSuccess() {
-                                printAdInfo(adUnitBean)
-                                it.isActiveResult(AdResult.Success(adBean = adUnitBean, adObject = mTTSplashAd, msg = "GroMore广告-开屏-加载成功"))
-                            }
+                TTAdSdk.getAdManager().createAdNative(context)
+                    .loadSplashAd(adSlot, object : TTAdNative.SplashAdListener {
+                        override fun onError(p0: Int, p1: String?) {
+                            printAdFailInfo(adUnitBean, p0, p1)
+                            it.isActiveResult(AdResult.Fail(adBean = adUnitBean, msg = p1 ?: "GroMore-开屏-加载失败"))
+                        }
 
-                            override fun onAdLoadTimeout() {
-                                printAdFailInfo(adUnitBean, 0, "GroMore广告-开屏-加载超时")
-                                it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore广告-开屏-加载超时"))
-                            }
-                        })
-                }
+                        override fun onTimeout() {
+                            printAdFailInfo(adUnitBean, 0, "加载超时")
+                            it.isActiveResult(AdResult.Fail(adBean = adUnitBean, msg = "GroMore-开屏-加载失败,请求超时"))
+                        }
 
+                        override fun onSplashAdLoad(p0: TTSplashAd?) {
+                            printAdInfo(adUnitBean)
+                            it.isActiveResult(AdResult.Success(adBean = adUnitBean, adObject = p0, msg = "GroMore-开屏-加载成功"))
+                        }
+                    })
             } else {
-                printAdFailInfo(adUnitBean, 0,  "GroMore广告-开屏-加载失败:context需要为Activity")
+                printAdFailInfo(adUnitBean, 0, "GroMore广告-开屏-加载失败:context需要为Activity")
                 it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore广告-开屏-加载失败:context需要为Activity"))
             }
         }

+ 23 - 49
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMBannerRequestImpl.kt

@@ -1,31 +1,15 @@
 package com.composition.android.ad.gromore.load.request
 
-import android.app.Activity
 import android.content.Context
-import android.view.LayoutInflater
-import android.view.View
-import com.bytedance.msdk.api.AdError
-import com.bytedance.msdk.api.v2.GMAdSize
-import com.bytedance.msdk.api.v2.ad.banner.GMBannerAd
-import com.bytedance.msdk.api.v2.ad.banner.GMBannerAdListener
-import com.bytedance.msdk.api.v2.ad.banner.GMBannerAdLoadCallback
-import com.bytedance.msdk.api.v2.ad.banner.GMNativeAdInfo
-import com.bytedance.msdk.api.v2.ad.banner.GMNativeToBannerListener
-import com.bytedance.msdk.api.v2.slot.GMAdOptionUtil
-import com.bytedance.msdk.api.v2.slot.GMAdSlotBanner
-import com.composition.android.ad.gromore.R
-
+import com.bytedance.sdk.openadsdk.*
 import com.composition.android.ad.gromore.impl.GMAdImageSize
-import com.composition.android.ad.gromore.util.GMSettingConfig
 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.adLogWithFrame
 import com.composition.android.lib.ad.util.isActiveResult
 import com.composition.android.lib.ad.util.printAdFailInfo
 import com.composition.android.lib.ad.util.printAdInfo
 import kotlinx.coroutines.suspendCancellableCoroutine
-import kotlin.coroutines.resume
 
 /**
  * @classname:
@@ -34,43 +18,33 @@ import kotlin.coroutines.resume
  * description: GroMore Banner广告加载类
  */
 class GMBannerRequestImpl : IAdFormatRequest {
-
     override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
         return suspendCancellableCoroutine {
+            val size = if (adUnitBean.adSize is GMAdImageSize) (adUnitBean.adSize as GMAdImageSize).gmAdSize else 600 to 90
+            val adSlot = AdSlot.Builder()
+                .setCodeId(adUnitBean.adUnitId)
+                .setAdCount(1)
+                .setExpressViewAcceptedSize(size.first.toFloat(), size.second.toFloat())
+                .setAdLoadType(TTAdLoadType.PRELOAD)
+                .build()
+
+            TTAdSdk.getAdManager().createAdNative(context)
+                .loadBannerExpressAd(adSlot, object : TTAdNative.NativeExpressAdListener {
+                    override fun onError(p0: Int, p1: String?) {
+                        printAdFailInfo(adUnitBean, p0, p1)
+                        it.isActiveResult(AdResult.Fail(adUnitBean, msg = p1 ?: "GroMore-横幅-加载失败"))
+                    }
 
-            GMSettingConfig.loadAdConfig {
-
-                if (context is Activity) {
-                    val mTTBannerViewAd = GMBannerAd(context, adUnitBean.adUnitId)
-                    val size = if (adUnitBean.adSize is GMAdImageSize) (adUnitBean.adSize as GMAdImageSize).gmAdSize else 600 to 90
-                    val slotBanner = GMAdSlotBanner.Builder()
-                        .setBannerSize(GMAdSize.BANNER_CUSTOME)
-                        .setAllowShowCloseBtn(true)
-                        .setGMAdSlotGDTOption(GMAdOptionUtil.getGMAdSlotGDTOption().build())
-                        .setGMAdSlotBaiduOption(GMAdOptionUtil.getGMAdSlotBaiduOption().build())
-                        .setImageAdSize(size.first, size.second)
-                        .setMuted(true)
-                        .build()
-
-                    mTTBannerViewAd.loadAd(slotBanner, object : GMBannerAdLoadCallback {
-                        override fun onAdFailedToLoad(p0: AdError) {
-                            printAdFailInfo(adUnitBean, p0.code, p0.message)
-                            it.isActiveResult(AdResult.Fail(adUnitBean, msg = p0.message))
-                        }
-
-                        override fun onAdLoaded() {
-                            printAdInfo(adUnitBean)
-                            it.isActiveResult(AdResult.Success(adBean = adUnitBean, adObject = mTTBannerViewAd, msg = "GroMore广告-横幅-加载成功"))
+                    override fun onNativeExpressAdLoad(p0: MutableList<TTNativeExpressAd>?) {
+                        printAdInfo(adUnitBean)
+                        if (p0.isNullOrEmpty().not()) {
+                            it.isActiveResult(AdResult.Success(adBean = adUnitBean, adObject = p0?.get(0), msg = "GroMore-横幅-加载成功"))
+                        } else {
+                            printAdFailInfo(adUnitBean, 0, "SDK返回的广告实例为空")
+                            it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore-横幅-加载失败, 返回的广告实例为空"))
                         }
-                    })
-
-                } else {
-                    if (it.isActive) {
-                        printAdFailInfo(adUnitBean, 0, "GroMore广告-横幅-加载失败:context需要为Activity")
-                        it.resume(AdResult.Fail(adUnitBean, msg = "GroMore广告-横幅-加载失败:context需要为Activity"))
                     }
-                }
-            }
+                })
         }
     }
 }

+ 31 - 41
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMInterstitialRequestImpl.kt

@@ -1,19 +1,13 @@
 package com.composition.android.ad.gromore.load.request
 
-import android.app.Activity
 import android.content.Context
-import com.bytedance.msdk.api.AdError
-import com.bytedance.msdk.api.v2.GMAdConstant
-import com.bytedance.msdk.api.v2.ad.interstitialFull.GMInterstitialFullAd
-import com.bytedance.msdk.api.v2.ad.interstitialFull.GMInterstitialFullAdLoadCallback
-import com.bytedance.msdk.api.v2.slot.GMAdOptionUtil
-import com.bytedance.msdk.api.v2.slot.GMAdSlotInterstitialFull
-import com.composition.android.ad.gromore.util.GMSettingConfig
-import com.composition.android.lib.ad.AdManager
+import com.bytedance.sdk.openadsdk.*
 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.*
+import com.composition.android.lib.ad.util.isActiveResult
+import com.composition.android.lib.ad.util.printAdFailInfo
+import com.composition.android.lib.ad.util.printAdInfo
 import kotlinx.coroutines.suspendCancellableCoroutine
 
 /**
@@ -25,42 +19,38 @@ import kotlinx.coroutines.suspendCancellableCoroutine
 class GMInterstitialRequestImpl : IAdFormatRequest {
     override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
         return suspendCancellableCoroutine {
-            GMSettingConfig.loadAdConfig {
-                if (context is Activity) {
-                    val mInterstitialFullAd = GMInterstitialFullAd(context, adUnitBean.adUnitId)
-                    val customData: MutableMap<String, String> = HashMap()
-                    customData[GMAdConstant.CUSTOM_DATA_KEY_GDT] = "gdt custom data"
-                    val adSlot = GMAdSlotInterstitialFull.Builder()
-                        .setCustomData(customData)
-                        .setGMAdSlotGDTOption(GMAdOptionUtil.getGMAdSlotGDTOption().build())
-                        .setGMAdSlotBaiduOption(GMAdOptionUtil.getGMAdSlotBaiduOption().build())
-                        .setOrientation(GMAdConstant.VERTICAL)
-                        .setUserID(adUnitBean.adUnitId)
-                        .setMuted(true)
-                        .build()
+            val adSlot = AdSlot.Builder()
+                .setCodeId(adUnitBean.adUnitId)
+                .setSupportDeepLink(true)
+                .setAdCount(1)
+                .setOrientation(TTAdConstant.VERTICAL)
+                .setAdLoadType(TTAdLoadType.PRELOAD)
+                .setExpressViewAcceptedSize(1080F, 1920F)
+                .build()
 
-                    mInterstitialFullAd.loadAd(adSlot, object : GMInterstitialFullAdLoadCallback {
-                        override fun onInterstitialFullLoadFail(p0: AdError) {
-                            printAdFailInfo(adUnitBean, p0.code, p0.message)
-                            it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore广告-插屏-加载失败"))
-                        }
+            TTAdSdk.getAdManager().createAdNative(context)
+                .loadFullScreenVideoAd(adSlot, object : TTAdNative.FullScreenVideoAdListener {
+                    override fun onError(p0: Int, p1: String?) {
+                        printAdFailInfo(adUnitBean, p0, p1)
+                        it.isActiveResult(AdResult.Fail(adUnitBean, msg = p1 ?: "GroMore-模板插屏-加载失败"))
+                    }
 
-                        override fun onInterstitialFullAdLoad() {
-                            //这里为广告加载成功,但还没缓存好
-                        }
+                    override fun onFullScreenVideoAdLoad(p0: TTFullScreenVideoAd?) {
+                    }
 
-                        override fun onInterstitialFullCached() {
+                    override fun onFullScreenVideoCached() {
+                    }
+
+                    override fun onFullScreenVideoCached(p0: TTFullScreenVideoAd?) {
+                        if (p0 != null) {
                             printAdInfo(adUnitBean)
-                            //这里为广告已经缓存好了,保证流畅播放,再次返回成功
-                            it.isActiveResult(AdResult.Success(adBean = adUnitBean, adObject = mInterstitialFullAd, msg = "GroMore广告-插屏-加载成功"))
+                            it.isActiveResult(AdResult.Success(adBean = adUnitBean, adObject = p0, msg = "GroMore-模板插屏-加载成功"))
+                        } else {
+                            printAdFailInfo(adUnitBean, 0, "SDK返回的广告实例为空")
+                            it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore-模板插屏-加载失败,SDK返回的广告实例为空"))
                         }
-                    })
-
-                } else {
-                    printAdFailInfo(adUnitBean, 0, "GroMore广告-插屏-加载失败:context需要为activity")
-                    it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore广告-插屏-加载失败:context需要为activity"))
-                }
-            }
+                    }
+                })
         }
     }
 }

+ 58 - 0
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMNativeRequestImpl.kt

@@ -0,0 +1,58 @@
+package com.composition.android.ad.gromore.load.request
+
+import android.content.Context
+import com.bytedance.sdk.openadsdk.AdSlot
+import com.bytedance.sdk.openadsdk.TTAdLoadType
+import com.bytedance.sdk.openadsdk.TTAdNative
+import com.bytedance.sdk.openadsdk.TTAdSdk
+import com.bytedance.sdk.openadsdk.TTNativeAd
+import com.composition.android.ad.gromore.impl.GMAdImageSize
+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.isActiveResult
+import com.composition.android.lib.ad.util.printAdFailInfo
+import com.composition.android.lib.ad.util.printAdInfo
+import kotlinx.coroutines.suspendCancellableCoroutine
+
+class GMNativeRequestImpl : IAdFormatRequest {
+
+    override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
+
+        return suspendCancellableCoroutine {
+
+            val adSize = if (adUnitBean.adSize != null && adUnitBean.adSize is GMAdImageSize) {
+                val size = adUnitBean.adSize as  GMAdImageSize
+                size.gmAdSize
+            } else {
+                640 to 320
+            }
+            val adSlot = AdSlot.Builder()
+                .setCodeId(adUnitBean.adUnitId)
+                .setSupportDeepLink(true)
+                .setAdCount(1)
+                .setImageAcceptedSize(adSize.first, adSize.second)
+                .setNativeAdType(AdSlot.TYPE_BANNER)
+                .setAdLoadType(TTAdLoadType.PRELOAD)
+                .build()
+
+            TTAdSdk.getAdManager().createAdNative(context)
+                .loadNativeAd(adSlot, object : TTAdNative.NativeAdListener {
+                    override fun onError(p0: Int, p1: String?) {
+                        printAdFailInfo(adUnitBean, p0, p1)
+                        it.isActiveResult(AdResult.Fail(adUnitBean, msg = p1 ?: "GroMore广告-原生-加载失败"))
+                    }
+
+                    override fun onNativeAdLoad(p0: MutableList<TTNativeAd>?) {
+                        if (p0.isNullOrEmpty().not()) {
+                            printAdInfo(adUnitBean)
+                            it.isActiveResult(AdResult.Success(adBean = adUnitBean, adObject = p0?.get(0), msg = "GroMore-原生-加载成功"))
+                        } else {
+                            printAdFailInfo(adUnitBean, 0, "SDK返回的广告实例为空")
+                            it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore广告原生-加载失败, SDK返回的广告实例为空"))
+                        }
+                    }
+                })
+        }
+    }
+}

+ 29 - 51
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMNativeTemplateRequestImpl.kt

@@ -1,17 +1,8 @@
 package com.composition.android.ad.gromore.load.request
 
-import android.app.Activity
 import android.content.Context
-import com.bytedance.msdk.api.AdError
-import com.bytedance.msdk.api.UIUtils.getScreenWidthDp
-import com.bytedance.msdk.api.v2.ad.nativeAd.GMNativeAd
-import com.bytedance.msdk.api.v2.ad.nativeAd.GMNativeAdLoadCallback
-import com.bytedance.msdk.api.v2.ad.nativeAd.GMUnifiedNativeAd
-import com.bytedance.msdk.api.v2.slot.GMAdOptionUtil
-import com.bytedance.msdk.api.v2.slot.GMAdSlotNative
-import com.bytedance.sdk.openadsdk.AdSlot
+import com.bytedance.sdk.openadsdk.*
 import com.composition.android.ad.gromore.impl.GMAdImageSize
-import com.composition.android.ad.gromore.util.GMSettingConfig
 import com.composition.android.lib.ad.AdManager
 import com.composition.android.lib.ad.basic.AdResult
 import com.composition.android.lib.ad.bean.AdUnitBean
@@ -26,52 +17,39 @@ import kotlinx.coroutines.suspendCancellableCoroutine
  * description: GroMore原生模板广告加载类
  */
 class GMNativeTemplateRequestImpl : IAdFormatRequest {
-
-
     override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
-
         return suspendCancellableCoroutine {
-            if (context is Activity) {
-                GMSettingConfig.loadAdConfig {
-
-                    val adImageSize = if (adUnitBean.adSize != null && adUnitBean.adSize is GMAdImageSize) {
-                        val size = adUnitBean.adSize as GMAdImageSize
-                        size.gmAdSize
-                    } else {
-                        getScreenWidthDp(context).toInt() to 340
+            val adImageSize = if (adUnitBean.adSize != null && adUnitBean.adSize is GMAdImageSize) {
+                val size = adUnitBean.adSize as GMAdImageSize
+                size.gmAdSize
+            } else {
+                getScreenWidthDp(context).toInt() to 340
+            }
+            adLogE(tag = AdManager.TAG, msg = "CSJNativeTemplateRequestImpl load")
+            val adSlot = AdSlot.Builder()
+                .setCodeId(adUnitBean.adUnitId)
+                .setAdCount(1)
+                .setImageAcceptedSize(adImageSize.first, adImageSize.second)
+                .setAdLoadType(TTAdLoadType.PRELOAD)
+                .build()
+
+            TTAdSdk.getAdManager().createAdNative(context)
+                .loadNativeExpressAd(adSlot, object : TTAdNative.NativeExpressAdListener {
+                    override fun onError(p0: Int, p1: String?) {
+                        printAdFailInfo(adUnitBean, p0, p1)
+                        it.isActiveResult(AdResult.Fail(adUnitBean, msg = p1 ?: "GroMore-原生模板-加载失败"))
                     }
-                    val gmNativeAd = GMUnifiedNativeAd(context, adUnitBean.adUnitId)
-                    gmNativeAd.loadAd(GMAdSlotNative.Builder()
-                        .setAdCount(1)
-                        .setGMAdSlotBaiduOption(GMAdOptionUtil.getGMAdSlotBaiduOption().build())
-                        .setGMAdSlotGDTOption(GMAdOptionUtil.getGMAdSlotGDTOption().build())
-                        .setAdStyleType(AdSlot.TYPE_FEED)
-                        .setImageAdSize(adImageSize.first, adImageSize.second)
-                        .build(),
 
-                        object : GMNativeAdLoadCallback {
-                            override fun onAdLoaded(p0: MutableList<GMNativeAd>) {
-                                if (p0.isNullOrEmpty().not()) {
-                                    printAdInfo(adUnitBean)
-                                    it.isActiveResult(AdResult.Success(adBean = adUnitBean, adObject = p0.get(0), msg = "GroMore广告-原生模板-加载成功"))
-                                } else {
-                                    printAdFailInfo(adUnitBean, 0, "SDK返回的广告实例集合为空")
-                                    it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore广告-原生模板-加载失败"))
-                                }
-                            }
-
-                            override fun onAdLoadedFail(p0: AdError) {
-                                printAdFailInfo(adUnitBean, p0.code, p0.message)
-                                it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore广告-原生模板-加载失败"))
-                            }
+                    override fun onNativeExpressAdLoad(p0: MutableList<TTNativeExpressAd>?) {
+                        if (p0.isNullOrEmpty().not()) {
+                            printAdInfo(adUnitBean)
+                            it.isActiveResult(AdResult.Success(adBean = adUnitBean, adObject = p0?.get(0), msg = "GroMore-原生模板-加载成功"))
+                        } else {
+                            printAdFailInfo(adUnitBean, 0, "SDK返回的广告实例为空")
+                            it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore原生模板-加载失败, SDK返回的广告实例为空"))
                         }
-                    )
-                }
-            } else {
-                printAdFailInfo(adUnitBean, 0, "GroMore广告-原生模板-context需要为Activity类型")
-                it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore广告-原生模板-context需要为Activity类型"))
-            }
+                    }
+                })
         }
     }
-
 }

+ 26 - 32
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/GMRewardRequestImpl.kt

@@ -1,13 +1,7 @@
 package com.composition.android.ad.gromore.load.request
 
-import android.app.Activity
 import android.content.Context
-import com.bytedance.msdk.api.AdError
-import com.bytedance.msdk.api.v2.GMAdConstant
-import com.bytedance.msdk.api.v2.ad.reward.GMRewardAd
-import com.bytedance.msdk.api.v2.ad.reward.GMRewardedAdLoadCallback
-import com.bytedance.msdk.api.v2.slot.GMAdSlotRewardVideo
-import com.composition.android.ad.gromore.util.GMSettingConfig
+import com.bytedance.sdk.openadsdk.*
 import com.composition.android.lib.ad.basic.AdResult
 import com.composition.android.lib.ad.bean.AdUnitBean
 import com.composition.android.lib.ad.interfaces.IAdFormatRequest
@@ -15,6 +9,7 @@ import com.composition.android.lib.ad.util.isActiveResult
 import com.composition.android.lib.ad.util.printAdFailInfo
 import com.composition.android.lib.ad.util.printAdInfo
 import kotlinx.coroutines.suspendCancellableCoroutine
+import kotlin.coroutines.resume
 
 /**
  * @classname:
@@ -24,34 +19,33 @@ import kotlinx.coroutines.suspendCancellableCoroutine
  */
 class GMRewardRequestImpl : IAdFormatRequest {
     override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
-
         return suspendCancellableCoroutine {
-            if (context is Activity) {
-                GMSettingConfig.loadAdConfig {
-                    val gmRewardAd = GMRewardAd(context, adUnitBean.adUnitId)
-                    gmRewardAd.loadAd(GMAdSlotRewardVideo.Builder()
-                        .setRewardAmount(1)
-                        .setMuted(true)
-                        .setOrientation(GMAdConstant.VERTICAL)
-                        .build(), object : GMRewardedAdLoadCallback {
-                        override fun onRewardVideoLoadFail(p0: AdError) {
-                            printAdFailInfo(adUnitBean, p0.code, p0.message)
-                            it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore广告-激励视频-加载失败"))
-                        }
+            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(adUnitBean, code, p1)
+                        it.isActiveResult(AdResult.Fail(adBean = adUnitBean, msg = p1 ?: "GroMore-激励视频-加载失败"))
+                    }
+
+                    override fun onRewardVideoAdLoad(p0: TTRewardVideoAd?) {
+                    }
+
+                    override fun onRewardVideoCached() {
 
-                        override fun onRewardVideoAdLoad() {
-                        }
+                    }
 
-                        override fun onRewardVideoCached() {
-                            printAdInfo(adUnitBean)
-                            it.isActiveResult(AdResult.Success(adBean = adUnitBean, adObject = gmRewardAd, msg = "GroMore广告-激励视频-加载成功"))
-                        }
-                    })
-                }
-            } else {
-                printAdFailInfo(adUnitBean, 0, "GroMore广告-激励视频-加载异常:context需要为Activity类型")
-                it.isActiveResult(AdResult.Fail(adUnitBean, msg = "GroMore广告-激励视频-加载异常:context需要为Activity类型"))
-            }
+                    override fun onRewardVideoCached(p0: TTRewardVideoAd?) {
+                        printAdInfo(adUnitBean)
+                        it.resume(AdResult.Success(adBean = adUnitBean, adObject = p0, msg = "GroMore-激励视频-缓存加载成功"))
+                    }
+                })
         }
     }
 }

+ 191 - 0
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/view/CSJNativeAdView.kt

@@ -0,0 +1,191 @@
+package com.composition.android.ad.gromore.load.view
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.appcompat.widget.AppCompatImageView
+import androidx.appcompat.widget.AppCompatTextView
+import androidx.core.view.isVisible
+import com.bytedance.sdk.openadsdk.TTAdConstant
+import com.bytedance.sdk.openadsdk.TTAdDislike
+import com.bytedance.sdk.openadsdk.TTNativeAd
+import com.composition.android.ad.gromore.R
+import com.composition.android.ad.gromore.impl.CSJAppDownloadListener
+import com.composition.android.lib.ad.AdManager
+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.util.adLog
+
+/**
+ * @classname:
+ * @author: LiuXiaoLong
+ * @date: 2022/9/13
+ * description: 穿山甲原生模板广告View
+ */
+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)
+        return viewHolder?.customLayoutRootView
+    }
+
+    override fun onResume() {
+
+    }
+
+    override fun onPause() {
+
+    }
+
+    override fun onDestroy() {
+        val ttNativeAd = adResult?.adObject as? TTNativeAd
+        ttNativeAd?.destroy()
+        adResult?.adObject = null
+    }
+
+    companion object {
+
+        fun populateNativeAdView(context: Context, adResult: AdResult.Success, viewHolder: NativeAdViewHolder, advertisersContainerView: ViewGroup?) {
+
+            val ttNativeAd = adResult.adObject as TTNativeAd
+            viewHolder.activity?.apply {
+                ttNativeAd.getDislikeDialog(this).apply {
+                    setDislikeInteractionCallback(object : TTAdDislike.DislikeInteractionCallback {
+                        override fun onShow() {
+
+                        }
+
+                        override fun onSelected(p0: Int, p1: String?, p2: Boolean) {
+                            adLog(msg = "穿山甲广告-原生-点击不喜欢按钮")
+                            viewHolder.adListener?.onAdDisLike()
+                        }
+
+                        override fun onCancel() {
+                        }
+                    })
+                    viewHolder.dislikeView?.setOnClickListener {
+                        this.showDislikeDialog()
+                    }
+                }
+
+
+            }
+
+            viewHolder.titleView?.text = ttNativeAd.title
+            (viewHolder.titleDescView as? AppCompatTextView)?.text = ttNativeAd.description
+
+
+            val mediaImageViews = LayoutInflater.from(context).inflate(R.layout.csj_native_ad_media_image_views, null)
+
+            val imageViewList = mutableListOf<View>()
+            imageViewList.add(mediaImageViews.findViewById(R.id.id_ad_media_iv_1))
+            imageViewList.add(mediaImageViews.findViewById(R.id.id_ad_media_iv_2))
+            imageViewList.add(mediaImageViews.findViewById(R.id.id_ad_media_iv_3))
+
+
+            viewHolder.contentMediaViewGroup?.apply {
+                removeAllViews()
+                addView(mediaImageViews)
+            }
+            if (ttNativeAd.imageList.isNullOrEmpty().not()) {
+
+                for (i in 0..2) {
+                    val imageItem = ttNativeAd.imageList.getOrNull(i)
+                    if (imageItem != null) {
+                        if (imageItem.isValid) {
+                            viewHolder.mediaImageLoader?.displayImage(context, imageItem.imageUrl, imageViewList[i] as AppCompatImageView)
+                        }
+                    } else {
+                        imageViewList.getOrNull(i)?.isVisible = false
+                    }
+                }
+            }
+            if (ttNativeAd.icon != null && ttNativeAd.icon.isValid && viewHolder.iconView != null) {
+                viewHolder.iconImageLoader?.displayImage(context, ttNativeAd.icon.imageUrl, viewHolder.iconView as AppCompatImageView)
+            }
+            when (ttNativeAd.interactionType) {
+                TTAdConstant.INTERACTION_TYPE_DOWNLOAD -> {
+                    ttNativeAd.setActivityForDownloadApp(viewHolder.activity)
+                    viewHolder.callActionButtonView?.isVisible = true
+                    ttNativeAd.setDownloadListener(CSJAppDownloadListener(context, viewHolder))
+                }
+                TTAdConstant.INTERACTION_TYPE_DIAL -> {
+                    viewHolder.callActionButtonView?.also {
+                        it.isVisible = true
+                        it.text = context.getString(R.string.call_now)
+                    }
+                }
+                TTAdConstant.INTERACTION_TYPE_LANDING_PAGE -> {
+                    viewHolder.callActionButtonView?.also {
+                        it.isVisible = true
+                        it.text = context.getString(R.string.check_the_details)
+                    }
+                }
+                else -> {
+                    viewHolder.callActionButtonView?.isVisible = false
+                }
+            }
+
+            (viewHolder.advertiserLogoImageView as? AppCompatImageView)?.setImageBitmap(ttNativeAd.adLogo)
+
+            val clickViewList = mutableListOf<View>()
+            viewHolder.customLayoutRootView?.let { clickViewList.add(it) }
+
+
+            val creativeViewList = mutableListOf<View>()
+            viewHolder.callActionButtonView?.let {
+                creativeViewList.add(it)
+            }
+
+            ttNativeAd.registerViewForInteraction(
+                viewHolder.customLayoutRootView as ViewGroup,
+                imageViewList,
+                clickViewList,
+                creativeViewList,
+                viewHolder.dislikeView,
+                object : TTNativeAd.AdInteractionListener {
+                    override fun onAdClicked(p0: View?, p1: TTNativeAd?) {
+                        adLog(msg = "穿山甲广告-原生-点击广告")
+                        viewHolder.adListener?.onAdClick()
+                    }
+
+                    override fun onAdCreativeClick(p0: View?, p1: TTNativeAd?) {
+                    }
+
+                    override fun onAdShow(p0: TTNativeAd?) {
+                        adLog(msg = "穿山甲广告-原生-广告展示")
+                    }
+
+                })
+
+            ttNativeAd.setExpressRenderListener { view, width, height, isExpress ->
+                adLog(AdManager.TAG, "穿山甲广告-原生-渲染成功 width:${width},height:${height}")
+                viewHolder.adListener?.onAdShow(adResult.adBean)
+//                (viewHolder.customLayoutRootView as? ViewGroup)?.let {
+//                    val sWidth = context.getScreenWidth()
+//                    val sHeight = (sWidth * height / width).toInt()
+//                    it.removeAllViews()
+//                    it.addView(ttNativeAd., sWidth, sHeight)
+//                }
+            }
+            ttNativeAd.render()
+        }
+    }
+
+    override fun onDetachedFromWindow() {
+        super.onDetachedFromWindow()
+        adResult?.adObject = null
+    }
+}

+ 43 - 33
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/view/GMBannerView.kt

@@ -2,13 +2,13 @@ package com.composition.android.ad.gromore.load.view
 
 import android.content.Context
 import android.view.View
-import com.bytedance.msdk.api.AdError
-import com.bytedance.msdk.api.v2.ad.banner.GMBannerAd
-import com.bytedance.msdk.api.v2.ad.banner.GMBannerAdListener
+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
-import com.composition.android.lib.ad.util.adLogWithFrame
 
 /**
  * @classname:
@@ -18,59 +18,69 @@ import com.composition.android.lib.ad.util.adLogWithFrame
  */
 class GMBannerView(context: Context?) : BasicAdView<View>(context) {
 
-    private var viewHolder : BannerAdViewHolder? = null
+    private var viewHolder: BannerAdViewHolder? = null
 
-    fun setBannerViewHolder(viewHolder: BannerAdViewHolder){
+    fun setBannerViewHolder(viewHolder: BannerAdViewHolder) {
         this.viewHolder = viewHolder
     }
 
     override fun adContentView(): View? {
-        val gmBannerAd = getGmBannerAd()
-        gmBannerAd?.setAdBannerListener(object : GMBannerAdListener{
-            override fun onAdOpened() {
+        val adObj = adResult?.adObject as TTNativeExpressAd
+        adObj.setExpressInteractionListener(object : TTNativeExpressAd.ExpressAdInteractionListener {
+            override fun onAdClicked(p0: View?, p1: Int) {
+                viewHolder?.adListener?.onAdClick()
+                adLog(AdManager.TAG, "GroMore-横幅-点击")
             }
 
-            override fun onAdLeftApplication() {
+            override fun onAdShow(p0: View?, p1: Int) {
+                adResult?.adBean?.let { viewHolder?.adListener?.onAdShow(it) }
+                adLog(AdManager.TAG, "GroMore-横幅-展示")
 
             }
 
-            override fun onAdClosed() {
-                adLogWithFrame(msg = "GroMore广告-横幅-关闭")
-                viewHolder?.adListener?.onAdClose()
+            override fun onRenderFail(p0: View?, p1: String?, p2: Int) {
+                viewHolder?.adListener?.onAdShowFail("GroMore渲染失败")
+                adLog(AdManager.TAG, "GroMore-横幅-渲染失败")
             }
 
-            override fun onAdClicked() {
-                adLogWithFrame(msg = "GroMore广告-横幅-点击")
-                viewHolder?.adListener?.onAdClick()
+            override fun onRenderSuccess(p0: View?, p1: Float, p2: Float) {
+                adLog(AdManager.TAG, "GroMore-横幅-渲染成功 width:${p1}, height:${p2}")
             }
+        })
+        viewHolder?.activity?.let {
+            adObj.setDislikeCallback(it, object : TTAdDislike.DislikeInteractionCallback {
+                override fun onShow() {
 
-            override fun onAdShow() {
-                adLogWithFrame(msg = "GroMore广告-横幅-展示")
-                adResult?.adBean?.let { viewHolder?.adListener?.onAdShow(it) }
-            }
+                }
 
-            override fun onAdShowFail(p0: AdError) {
-                adLogWithFrame(msg = "GroMore广告-横幅-展示失败")
-                viewHolder?.adListener?.onAdShowFail(p0.message)
-            }
-        })
-        return gmBannerAd?.bannerView
-    }
+                override fun onSelected(p0: Int, p1: String?, p2: Boolean) {
+                    viewHolder?.adListener?.onAdDisLike()
+                    this@GMBannerView.isVisible = false
+                    adLog(AdManager.TAG, "GroMore-横幅-点击不喜欢按钮")
+
+                }
+
+                override fun onCancel() {
+                }
+
+            })
+        }
+
+        adObj.render()
 
-    private fun getGmBannerAd() : GMBannerAd?{
-        return adResult?.adObject as? GMBannerAd
+        return adObj.expressAdView
     }
 
     override fun onResume() {
-        getGmBannerAd()?.onResume()
     }
 
     override fun onPause() {
-        getGmBannerAd()?.onPause()
     }
 
     override fun onDestroy() {
-        getGmBannerAd()?.destroy()
-        adResult?.adObject = null
+        if (adResult?.adObject != null) {
+            (adResult?.adObject as? TTNativeExpressAd)?.destroy()
+            adResult?.adObject = null
+        }
     }
 }

+ 43 - 65
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/view/GMNativeTemplateAdView.kt

@@ -1,18 +1,14 @@
 package com.composition.android.ad.gromore.load.view
 
 import android.content.Context
-import android.view.LayoutInflater
 import android.view.View
-import com.bytedance.msdk.api.format.TTNativeAdView
-import com.bytedance.msdk.api.v2.GMDislikeCallback
-import com.bytedance.msdk.api.v2.ad.nativeAd.GMNativeAd
-import com.bytedance.msdk.api.v2.ad.nativeAd.GMNativeExpressAdListener
-import com.composition.android.ad.gromore.R
+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.AdResult
 import com.composition.android.lib.ad.basic.BasicAdView
 import com.composition.android.lib.ad.basic.NativeAdViewHolder
 import com.composition.android.lib.ad.util.adLog
-import com.composition.android.lib.ad.util.adLogWithFrame
 
 /**
  * @classname:
@@ -22,107 +18,89 @@ import com.composition.android.lib.ad.util.adLogWithFrame
  */
 class GMNativeTemplateAdView(context: Context?) : BasicAdView<View>(context) {
 
-
     private var viewHolder: NativeAdViewHolder? = null
 
     fun setViewHolder(viewHolder: NativeAdViewHolder) {
         this.viewHolder = viewHolder
     }
 
-    private fun getGmNativeAd() : GMNativeAd?{
-        return adResult?.adObject as? GMNativeAd
-    }
-
     override fun adContentView(): View? {
         if (adResult == null || viewHolder == null) {
             return null
         }
-        val ttNativeAdView = LayoutInflater.from(context).inflate(R.layout.layout_gro_more_native_template_ad_view_root, null) as TTNativeAdView
-        populateNativeAdView(context, adResult!!, viewHolder!!, ttNativeAdView)
-        getGmNativeAd()?.expressView?.let {
-            ttNativeAdView.addView(it)
-        }
-        return ttNativeAdView
+        populateNativeTemplateAdView(context, adResult = adResult!!, viewHolder = viewHolder!!)
+        val ttNativeExpressAd = adResult?.adObject as TTNativeExpressAd
+        return ttNativeExpressAd.expressAdView
     }
 
     override fun onResume() {
-        getGmNativeAd()?.resume()
     }
 
     override fun onPause() {
-        getGmNativeAd()?.onPause()
+
     }
 
     override fun onDestroy() {
-        getGmNativeAd()?.destroy()
+        val ttNativeExpressAd = adResult?.adObject as? TTNativeExpressAd
+        ttNativeExpressAd?.destroy()
         adResult?.adObject = null
     }
 
     companion object {
 
-        fun populateNativeAdView(context: Context, success: AdResult.Success, nativeAdViewHolder: NativeAdViewHolder, ttNativeAdView: TTNativeAdView) {
+        fun populateNativeTemplateAdView(context: Context, adResult: AdResult.Success, viewHolder: NativeAdViewHolder) {
 
-            val gmNativeAd = success.adObject as GMNativeAd
-            if (gmNativeAd.hasDislike() && nativeAdViewHolder.activity != null) {
-                gmNativeAd.setDislikeCallback(nativeAdViewHolder.activity, object : GMDislikeCallback {
-                    override fun onSelected(p0: Int, p1: String?) {
-                        adLog(msg = "GroMore广告-原生模板-点击了不喜欢")
-                        nativeAdViewHolder.adListener?.onAdDisLike()
-                    }
+            val ttNativeExpressAd = adResult.adObject as TTNativeExpressAd
+            ttNativeExpressAd.render()
+            viewHolder.activity?.let {
+                ttNativeExpressAd.setDislikeCallback(it, object : TTAdDislike.DislikeInteractionCallback {
+                    override fun onShow() {
 
-                    override fun onCancel() {
                     }
 
-                    override fun onRefuse() {
+                    override fun onSelected(p0: Int, p1: String?, p2: Boolean) {
+                        adLog(msg = "GroMore广告-原生模板-点击不喜欢按钮")
+                        viewHolder.adListener?.onAdDisLike()
                     }
 
-                    override fun onShow() {
+                    override fun onCancel() {
                     }
 
                 })
             }
-            gmNativeAd.setNativeAdListener(object : GMNativeExpressAdListener {
-                override fun onAdClick() {
-                    adLogWithFrame(msg = "GroMore广告-原生模板-点击")
-                    nativeAdViewHolder.adListener?.onAdClick()
+
+            ttNativeExpressAd.setExpressInteractionListener(object : TTNativeExpressAd.AdInteractionListener {
+                override fun onAdClicked(p0: View?, p1: Int) {
+                    adLog(msg = "GroMore-原生模板-点击广告")
+                    viewHolder.adListener?.onAdClick()
                 }
 
-                override fun onAdShow() {
-                    adLogWithFrame(msg = "GroMore广告-原生模板-展示")
-                    nativeAdViewHolder.adListener?.onAdShow(adUnitBean = success.adBean)
+                override fun onAdShow(p0: View?, p1: Int) {
+                    adLog(msg = "GroMore-原生模板-广告展示")
+                    viewHolder.adListener?.onAdShow(adResult.adBean)
+
                 }
 
                 override fun onRenderFail(p0: View?, p1: String?, p2: Int) {
-                    adLogWithFrame(msg = "GroMore广告-原生模板-展示失败")
-                    nativeAdViewHolder.adListener?.onAdShowFail(p1?:"GroMore原生模板广告渲染失败")
+                    adLog(AdManager.TAG, "GroMore-原生模板-渲染失败")
+                    viewHolder.adListener?.onAdShowFail("GroMore原生模板广告渲染失败")
+                }
+
+                override fun onRenderSuccess(p0: View?, width: Float, height: Float) {
+                    adLog(AdManager.TAG, "GroMore-原生模板-渲染成功 width:${width},height:${height}")
                 }
 
-                override fun onRenderSuccess(width: Float, height: Float) {
-
-                    nativeAdViewHolder.adListener?.onAdShow(success.adBean)
-//                    //获取视频播放view,该view SDK内部渲染,在媒体平台可配置视频是否自动播放等设置。
-//                    val sWidth: Int
-//                    val sHeight: Int
-//                    val video: View? = gmNativeAd.expressView // 获取广告view  如果存在父布局,需要先从父布局中移除
-//                    if (width == GMAdSize.FULL_WIDTH.toFloat() && height == GMAdSize.AUTO_HEIGHT.toFloat()) {
-//                        sWidth = FrameLayout.LayoutParams.MATCH_PARENT
-//                        sHeight = FrameLayout.LayoutParams.WRAP_CONTENT
-//                    } else {
-//                        sWidth = context.getScreenWidth()
-//                        sHeight = (sWidth * height / width).toInt()
-//                    }
-//
-//                    if (video != null){
-//                        //如果存在父布局,需要先从父布局中移除
-//                        video.removeParentView()
-//                        ttNativeAdView.removeAllViews()
-//                        val layoutParams = FrameLayout.LayoutParams(sWidth, sHeight)
-//                        ttNativeAdView.addView(gmNativeAd.expressView, layoutParams)
-//                    }
+                override fun onAdDismiss() {
+                    adLog(msg = "GroMore-原生模板-广告关闭")
+                    viewHolder.adListener?.onAdClose()
                 }
             })
-            //进行广告渲染
-            gmNativeAd.render()
+
         }
     }
+
+    override fun onDetachedFromWindow() {
+        super.onDetachedFromWindow()
+        adResult?.adObject = null
+    }
 }

+ 29 - 29
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/util/GMSettingConfig.kt

@@ -1,29 +1,29 @@
-package com.composition.android.ad.gromore.util
-
-import com.bytedance.msdk.api.v2.GMMediationAdSdk
-
-/**
- * @classname:
- * @author: LiuXiaoLong
- * @date: 2022/9/15
- * description:
- */
-object GMSettingConfig {
-
-
-    /**
-     * 加载广告配置
-     * 在加载GroMore广告前需要先调用此方法获取GroMore广告位的中介配置
-     */
-    fun loadAdConfig(callBack: () -> Unit) {
-        if (GMMediationAdSdk.configLoadSuccess()) {
-            callBack.invoke()
-        } else {
-            GMMediationAdSdk.registerConfigCallback {
-                callBack.invoke()
-            }
-        }
-    }
-
-
-}
+//package com.composition.android.ad.gromore.util
+//
+//import com.bytedance.msdk.api.v2.GMMediationAdSdk
+//
+///**
+// * @classname:
+// * @author: LiuXiaoLong
+// * @date: 2022/9/15
+// * description:
+// */
+//object GMSettingConfig {
+//
+//
+//    /**
+//     * 加载广告配置
+//     * 在加载GroMore广告前需要先调用此方法获取GroMore广告位的中介配置
+//     */
+//    fun loadAdConfig(callBack: () -> Unit) {
+//        if (GMMediationAdSdk.configLoadSuccess()) {
+//            callBack.invoke()
+//        } else {
+//            GMMediationAdSdk.registerConfigCallback {
+//                callBack.invoke()
+//            }
+//        }
+//    }
+//
+//
+//}

+ 38 - 0
lib_ad_gromore/src/main/res/layout/csj_native_ad_media_image_views.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal">
+
+
+    <androidx.appcompat.widget.AppCompatImageView
+        android:id="@+id/id_ad_media_iv_1"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        app:layout_goneMarginEnd="0dp"
+        tools:layout_height="100dp"
+        tools:src="@tools:sample/backgrounds/scenic" />
+
+    <androidx.appcompat.widget.AppCompatImageView
+        android:id="@+id/id_ad_media_iv_2"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginHorizontal="4dp"
+        android:layout_weight="1"
+        android:visibility="gone"
+        tools:layout_height="100dp" />
+
+    <androidx.appcompat.widget.AppCompatImageView
+        android:id="@+id/id_ad_media_iv_3"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="4dp"
+        android:visibility="gone"
+        android:layout_weight="1"
+        tools:layout_height="100dp" />
+
+
+</LinearLayout>

+ 0 - 3
lib_ad_gromore/src/main/res/layout/layout_gro_more_native_template_ad_view_root.xml

@@ -2,7 +2,4 @@
 <com.bytedance.msdk.api.format.TTNativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content">
-
-
-
 </com.bytedance.msdk.api.format.TTNativeAdView>

+ 13 - 0
lib_ad_gromore/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_gromore/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_gromore/src/main/res/xml/ttad_file_paths.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<paths>
+    <!--为了适配所有路径可以设置 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>

+ 4 - 7
lib_ad_gromore/src/test/java/com/composition/android/ad/gromore/ExampleUnitTest.kt

@@ -1,16 +1,13 @@
 package com.composition.android.ad.gromore
 
-import org.junit.Assert.assertEquals
-import org.junit.Test
-
 /**
  * Example local unit test, which will execute on the development machine (host).
  *
  * See [testing documentation](http://d.android.com/tools/testing).
  */
 class ExampleUnitTest {
-    @Test
-    fun addition_isCorrect() {
-        assertEquals(4, 2 + 2)
-    }
+//    @Test
+//    fun addition_isCorrect() {
+//        assertEquals(4, 2 + 2)
+//    }
 }

+ 2 - 2
lib_common/build.gradle

@@ -45,8 +45,8 @@ dependencies {
     androidTestImplementation 'androidx.test.ext:junit:1.1.5'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
 
-    def kotlin_version = '1.8.10'
-    def lifecycle_version = '2.5.1'
+    def kotlin_version = '1.7.0'
+    def lifecycle_version = '2.6.1'
     api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
 
     // ViewModel