├── .gitignore ├── README.md ├── app-gromore ├── .gitignore ├── app │ └── release │ │ ├── app-gromore-1.1.6.apk │ │ └── output-metadata.json ├── build.gradle ├── libs-adn │ ├── GDTSDK.unionNormal.4.514.1384.aar │ ├── gdt_adapter_4.514.1384.2.aar │ ├── ks_adapter_3.3.40.3.aar │ ├── kssdk-ad-3.3.40.aar │ ├── open_ad_sdk_5.1.0.2.aar │ └── pangle_adapter_5.1.0.2.3.aar ├── libs │ └── oaid_sdk_1.0.25.aar ├── libs_gromore │ └── mediation_ad_sdk_4.1.0.4.aar ├── never_thumb.keystore ├── proguard-rules.pro ├── sdk │ └── gromore_sdk_1.1.2.aar └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── platform │ │ └── simple │ │ └── ExampleInstrumentedTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── supplierconfig.json │ ├── java │ └── com │ │ └── platform │ │ └── simple │ │ ├── AdConfig.java │ │ ├── AdvertApplication.java │ │ ├── BoldTextView.java │ │ ├── CoustomNativeRender.java │ │ ├── LayoutProvider.java │ │ ├── MainActivity.java │ │ ├── SplashActivity.java │ │ ├── TTNumberUtil.java │ │ ├── ThreadUtils.java │ │ └── adn │ │ ├── gdt │ │ ├── GdtCustomerBanner.java │ │ ├── GdtCustomerConfig.java │ │ ├── GdtCustomerFullVideo.java │ │ ├── GdtCustomerInterstitial.java │ │ ├── GdtCustomerNative.java │ │ ├── GdtCustomerReward.java │ │ ├── GdtCustomerSplash.java │ │ ├── GdtNativeAd.java │ │ └── GdtNativeExpressAd.java │ │ └── pangle │ │ ├── PangleCustomerConfig.java │ │ ├── PangleCustomerDraw.java │ │ ├── PangleCustomerFullVideo.java │ │ ├── PangleCustomerInterstitial.java │ │ ├── PangleCustomerNative.java │ │ ├── PangleCustomerReward.java │ │ ├── PangleCustomerSplash.java │ │ ├── PangleDrawAd.java │ │ ├── PangleDrawExpressAd.java │ │ ├── PangleNativeAd.java │ │ └── PangleNativeExpressAd.java │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ ├── bg_ad_item.xml │ ├── bg_tool_bar.xml │ ├── coustom_native_bg_btn.xml │ └── ic_launcher_background.xml │ ├── layout │ ├── activity_main.xml │ ├── activity_splash.xml │ └── coustom_native_render.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-xxhdpi │ └── ic_ad_menu.png │ ├── raw │ └── keep.xml │ ├── values │ ├── attrs.xml │ ├── colors.xml │ ├── strings.xml │ └── themes.xml │ └── xml │ ├── network_security_config.xml │ └── pangle_file_paths.xml ├── app-topon ├── .gitignore ├── app │ └── release │ │ ├── app-topon-1.1.6.apk │ │ └── output-metadata.json ├── build.gradle ├── libs-adn │ ├── GDTSDK.unionNormal.4.511.1381.aar │ ├── anythink_network_gdt.aar │ ├── anythink_network_kuaishou.aar │ ├── anythink_network_pangle_china.aar │ ├── kssdk-ad-3.3.42-publishRelease-fe31265b3d.aar │ └── open_ad_sdk_5.2.0.5.aar ├── libs │ └── oaid_sdk_1.0.25.aar ├── libs_topon │ ├── anythink_banner.aar │ ├── anythink_china_core.aar │ ├── anythink_core.aar │ ├── anythink_interstitial.aar │ ├── anythink_native.aar │ ├── anythink_rewardvideo.aar │ ├── anythink_splash.aar │ ├── gson-2.8.4.jar │ └── tramini_sdk.aar ├── proguard-rules.pro ├── sdk │ └── topon_sdk_1.1.2.aar ├── src │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── platform │ │ │ └── simple │ │ │ └── ExampleInstrumentedTest.java │ └── main │ │ ├── AndroidManifest.xml │ │ ├── assets │ │ └── supplierconfig.json │ │ ├── java │ │ └── com │ │ │ └── platform │ │ │ └── simple │ │ │ ├── AdConfig.java │ │ │ ├── AdvertApplication.java │ │ │ ├── BoldTextView.java │ │ │ ├── CoustomNativeRender.java │ │ │ ├── LayoutProvider.java │ │ │ ├── MainActivity.java │ │ │ └── SplashActivity.java │ │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── bg_ad_item.xml │ │ ├── bg_tool_bar.xml │ │ ├── coustom_native_bg_btn.xml │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_splash.xml │ │ └── coustom_native_render.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-xxhdpi │ │ └── ic_ad_menu.png │ │ ├── raw │ │ └── keep.xml │ │ ├── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ ├── anythink_bk_gdt_file_path.xml │ │ ├── anythink_bk_tt_file_path.xml │ │ └── network_security_config.xml └── topon.keystore ├── build.gradle ├── config.gradle ├── doc ├── GroMore统一SDK.md ├── GroMore统一SDK接入文档.md ├── TopOn统一SDK.md ├── TopOn统一SDK接入文档.md └── 版本更新.md ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── gromore ├── .gitignore ├── build.gradle ├── libs_gromore │ └── mediation_ad_sdk_4.1.0.4.aar ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── platform │ │ └── lib │ │ ├── bean │ │ └── Result.java │ │ ├── constants │ │ └── AdConstance.java │ │ ├── listener │ │ ├── BaseListener.java │ │ ├── NativeRenderControl.java │ │ ├── OnEventListener.java │ │ ├── OnExpressAdListener.java │ │ ├── OnExpressListener.java │ │ ├── OnInitListener.java │ │ ├── OnPlayListener.java │ │ ├── OnRewardVideoListener.java │ │ ├── OnSplashListener.java │ │ ├── OnSplashStatusListener.java │ │ └── OnTabScreenListener.java │ │ ├── manager │ │ ├── PlatformManager.java │ │ ├── PlayManager.java │ │ └── TableScreenManager.java │ │ ├── utils │ │ ├── ImageLoader.java │ │ ├── InitHelper.java │ │ ├── Logger.java │ │ ├── PlatformPreferences.java │ │ └── PlatformUtils.java │ │ └── widget │ │ ├── ExpressView.java │ │ ├── LayoutProvider.java │ │ ├── LoadingView.java │ │ ├── NativeRender.java │ │ ├── RewardActivity.java │ │ └── SplashView.java │ └── res │ ├── drawable │ ├── lib_bg_close.xml │ ├── lib_native_bg_btn.xml │ └── lib_native_bg_from.xml │ ├── layout │ ├── lib_activity_reward.xml │ ├── lib_native_render.xml │ ├── lib_view_express_layout.xml │ └── lib_view_loading.xml │ ├── mipmap-xxhdpi │ └── lib_close.png │ ├── values-v19 │ └── styles.xml │ └── values │ ├── colors.xml │ └── styles.xml ├── settings.gradle └── topon ├── .gitignore ├── build.gradle ├── libs_topon ├── anythink_banner.aar ├── anythink_china_core.aar ├── anythink_core.aar ├── anythink_interstitial.aar ├── anythink_native.aar ├── anythink_rewardvideo.aar ├── anythink_splash.aar ├── gson-2.8.4.jar └── tramini_sdk.aar ├── proguard-rules.pro └── src └── main ├── AndroidManifest.xml ├── java └── com │ └── platform │ └── lib │ ├── bean │ └── Result.java │ ├── constants │ └── AdConstance.java │ ├── listener │ ├── BaseListener.java │ ├── NativeRenderControl.java │ ├── OnEventListener.java │ ├── OnExpressAdListener.java │ ├── OnExpressListener.java │ ├── OnInitListener.java │ ├── OnPlayListener.java │ ├── OnRewardVideoListener.java │ ├── OnSplashListener.java │ ├── OnSplashStatusListener.java │ └── OnTabScreenListener.java │ ├── manager │ ├── PlatformManager.java │ ├── PlayManager.java │ └── TableScreenManager.java │ ├── utils │ ├── InitHelper.java │ ├── Logger.java │ ├── PlatformPreferences.java │ └── PlatformUtils.java │ └── widget │ ├── ExpressView.java │ ├── LayoutProvider.java │ ├── LoadingView.java │ ├── NativeRender.java │ ├── RewardActivity.java │ └── SplashView.java └── res ├── drawable ├── lib_bg_close.xml ├── lib_native_bg_btn.xml └── lib_native_bg_from.xml ├── layout ├── lib_activity_reward.xml ├── lib_native_render.xml ├── lib_view_express_layout.xml └── lib_view_loading.xml ├── mipmap-xxhdpi └── lib_close.png ├── values-v19 └── styles.xml └── values ├── colors.xml └── styles.xml /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | /.idea 3 | .gradle 4 | /local.properties 5 | /.idea/caches 6 | /.idea/libraries 7 | /.idea/modules.xml 8 | /.idea/workspace.xml 9 | /.idea/navEditor.xml 10 | /.idea/assetWizardSettings.xml 11 | .DS_Store 12 | /build 13 | /captures 14 | .externalNativeBuild 15 | .cxx 16 | local.properties 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 统一SDK 2 | * 针对第三方聚合SDK封装的统一API标准的SDK 3 | 4 | ### 一、名词释义 5 | * 统一SDK:此项目面向开发者(你)提供的API功能SDK;分别为:GroMore统一SDK和TopOn统一SDK 6 | * 聚合SDK:第三方聚合平台,比如:TonOn、GroMore 7 | * 广告SDK:第三方广告商,比如:穿山甲、优量汇、快手等 8 | 9 | ### 二、项目介绍 10 | * 此项目对第三方聚合平台GroMore和TopOn进行了统一API标准的二次封装
11 | * 适用于Android客户端,极大的方便首次集成上述聚合SDK或聚合SDK切换。
12 | * 项目下两个SDK分别为GroMore统一SDK和TopOn统一SDK,已分别基于穿山甲、快手、优量汇等第三方广告调试通过,其它厂家广告请按照各聚合平台官方文档添加受支持的广告SDK及聚合平台提供的adapter进行自测!第三方广告支持列表可见各统一SDK接入文档内的聚合平台官方下载地址。 13 | ### 三、功能特性 14 | * 开屏广告(xml或动态new对象填充) 15 | * 激励视频广告(一句话快速展示广告) 16 | * 插屏广告(一句话快速展示广告) 17 | * 信息流广告(xml或动态new对象填充) 18 | * banner广告(xml或动态new对象填充) 19 | 20 | ### 四、[历史版本及第三方SDK对照表][1] 21 | [1]:https://github.com/hty527/advert/wiki/版本更新 "历史版本及第三方SDK对照表" 22 | 23 | ### 五、Apk下载 24 | #### [GroMore统一SDK apk下载][2] 25 | [2]:https://github.com/hty527/advert/releases "GroMore统一SDK apk下载" 26 | 27 | #### [TopOn统一SDK apk下载][3] 28 | [3]:https://github.com/hty527/advert/releases "TopOn统一SDK apk下载" 29 | 30 | ### 六、SDK接入 31 | #### [GroMore统一SDK接入][4] 32 | [4]:https://github.com/hty527/advert/wiki/GroMore统一SDK "GroMore统一SDK接入" 33 | 34 | #### [TopOn统一SDK接入][5] 35 | [5]:https://github.com/hty527/advert/wiki/TopOn统一SDK "TopOn统一SDK接入" 36 | 37 | ### 七、日志过滤 38 | * 在控制台过滤"PlatformSDK"查看SDK日志输出(不需要"") -------------------------------------------------------------------------------- /app-gromore/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.txt -------------------------------------------------------------------------------- /app-gromore/app/release/app-gromore-1.1.6.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/app/release/app-gromore-1.1.6.apk -------------------------------------------------------------------------------- /app-gromore/app/release/output-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "artifactType": { 4 | "type": "APK", 5 | "kind": "Directory" 6 | }, 7 | "applicationId": "com.distributor.never.thumb", 8 | "variantName": "appRelease", 9 | "elements": [ 10 | { 11 | "type": "SINGLE", 12 | "filters": [], 13 | "properties": [], 14 | "versionCode": 6, 15 | "versionName": "1.1.6", 16 | "enabled": true, 17 | "outputFile": "app-gromore-app-release.apk" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /app-gromore/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.3" 6 | 7 | defaultConfig { 8 | applicationId rootProject.ext.gromore.applicationId 9 | minSdkVersion 21 10 | targetSdkVersion 29 11 | versionCode rootProject.ext.gromore.versionCode 12 | versionName rootProject.ext.gromore.versionName 13 | 14 | multiDexEnabled true 15 | ndk { 16 | //穿山甲:arm64-v8a、armeabi-v7a 17 | //快手广告:arm64-v8a、armeabi-v7a、armeabi、x86_64、x86 18 | abiFilters 'armeabi-v7a','arm64-v8a' 19 | } 20 | 21 | packagingOptions { 22 | doNotStrip "*/armeabi-v7a/*.so" 23 | doNotStrip "*/arm64-v8a/*.so" 24 | } 25 | } 26 | 27 | buildTypes { 28 | release { 29 | minifyEnabled false 30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 31 | } 32 | } 33 | compileOptions { 34 | sourceCompatibility JavaVersion.VERSION_1_8 35 | targetCompatibility JavaVersion.VERSION_1_8 36 | } 37 | 38 | signingConfigs { 39 | debug { 40 | storeFile file('never_thumb.keystore') 41 | storePassword "123456" 42 | keyAlias "never_thumb" 43 | keyPassword "123456" 44 | v1SigningEnabled true 45 | v2SigningEnabled false 46 | } 47 | release { 48 | storeFile file('never_thumb.keystore') 49 | storePassword "123456" 50 | keyAlias "never_thumb" 51 | keyPassword "123456" 52 | v1SigningEnabled true 53 | v2SigningEnabled false 54 | } 55 | } 56 | 57 | buildTypes { 58 | debug { 59 | debuggable true 60 | signingConfig signingConfigs.release 61 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 62 | } 63 | release { 64 | debuggable false 65 | zipAlignEnabled true 66 | shrinkResources true 67 | minifyEnabled true 68 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 69 | signingConfig signingConfigs.release 70 | } 71 | } 72 | 73 | flavorDimensions "app" 74 | productFlavors { 75 | app { 76 | applicationId rootProject.ext.gromore.applicationId 77 | versionCode rootProject.ext.gromore.versionCode 78 | versionName rootProject.ext.gromore.versionName 79 | dimension "app" 80 | signingConfig signingConfigs.release 81 | } 82 | } 83 | } 84 | 85 | dependencies { 86 | implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') 87 | implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs_gromore') 88 | implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs-adn') 89 | 90 | //广告功能逻辑SDK 91 | implementation project(':gromore') 92 | // implementation 'com.github.hty527.advert:gromore:1.1.6.1' 93 | 94 | // //GroMore_sdk 95 | // compileOnly "com.gromore.cn:gromore-sdk:3.8.0.1" //groMore sdk 96 | // //GroMore_sdk adapter 97 | // compileOnly "com.gromore.cn:gdt-adapter:4.491.1361.2" //gdt adapter 98 | // compileOnly "com.gromore.cn:ks-adapter:3.3.31.2" //ks adapter 99 | // compileOnly "com.gromore.cn:pangle-adapter:4.8.0.8.4" //穿山甲 adapter 100 | 101 | /** 102 | * 如果是Support环境 103 | */ 104 | //implementation "com.android.support:appcompat-v7:28.0.0" 105 | //implementation 'com.android.support:localbroadcastmanager:28.0.0' 106 | //集成包含快手广告需要添加下列1个依赖库 107 | //implementation "com.android.support:design:28.0.0" 108 | //dex 分包,当minSdkVersion>=21时会出现找不到androidx.multidex.MultiDexApplication 解决办法 109 | //implementation 'com.android.support:multidex:1.0.3' 110 | 111 | /** 112 | * 如果是androidx环境 113 | * 需在工程的gradle.properties文件增加下列配置: 114 | * android.useAndroidX=true 115 | * android.enableJetifier=true 116 | */ 117 | implementation 'androidx.appcompat:appcompat:1.0.2' 118 | implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0' 119 | //dex 分包,当minSdkVersion>=21时会出现找不到androidx.multidex.MultiDexApplication 解决办法 120 | implementation 'androidx.multidex:multidex:2.0.1' 121 | //集成包含快手广告需要添加下列2个依赖库 122 | implementation "androidx.recyclerview:recyclerview:1.2.0" 123 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 124 | } -------------------------------------------------------------------------------- /app-gromore/libs-adn/GDTSDK.unionNormal.4.514.1384.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/libs-adn/GDTSDK.unionNormal.4.514.1384.aar -------------------------------------------------------------------------------- /app-gromore/libs-adn/gdt_adapter_4.514.1384.2.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/libs-adn/gdt_adapter_4.514.1384.2.aar -------------------------------------------------------------------------------- /app-gromore/libs-adn/ks_adapter_3.3.40.3.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/libs-adn/ks_adapter_3.3.40.3.aar -------------------------------------------------------------------------------- /app-gromore/libs-adn/kssdk-ad-3.3.40.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/libs-adn/kssdk-ad-3.3.40.aar -------------------------------------------------------------------------------- /app-gromore/libs-adn/open_ad_sdk_5.1.0.2.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/libs-adn/open_ad_sdk_5.1.0.2.aar -------------------------------------------------------------------------------- /app-gromore/libs-adn/pangle_adapter_5.1.0.2.3.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/libs-adn/pangle_adapter_5.1.0.2.3.aar -------------------------------------------------------------------------------- /app-gromore/libs/oaid_sdk_1.0.25.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/libs/oaid_sdk_1.0.25.aar -------------------------------------------------------------------------------- /app-gromore/libs_gromore/mediation_ad_sdk_4.1.0.4.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/libs_gromore/mediation_ad_sdk_4.1.0.4.aar -------------------------------------------------------------------------------- /app-gromore/never_thumb.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/never_thumb.keystore -------------------------------------------------------------------------------- /app-gromore/sdk/gromore_sdk_1.1.2.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/sdk/gromore_sdk_1.1.2.aar -------------------------------------------------------------------------------- /app-gromore/src/androidTest/java/com/platform/simple/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.advert.topon", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /app-gromore/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | 35 | 36 | 45 | 48 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 58 | 59 | 60 | 61 | 66 | 69 | 70 | 74 | 75 | 80 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /app-gromore/src/main/assets/supplierconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "supplier": { 3 | "vivo": { 4 | "appid": "100215079" 5 | }, 6 | "xiaomi": { 7 | }, 8 | "huawei": { 9 | }, 10 | "oppo": { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/AdConfig.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | /** 4 | * created by hty 5 | * 2022/6/17 6 | * Desc:广告位物料 7 | */ 8 | public interface AdConfig { 9 | 10 | String TO_APP_ID = "5332440";//测试app_id 11 | String APP_NAME = "趣计步";//测试app_id 12 | 13 | /** 14 | * 激励视频位id 15 | */ 16 | String AD_CODE_REWARD_ID ="102185566"; 17 | 18 | /** 19 | * 开屏广告位id 20 | */ 21 | String AD_CODE_SPLASH_ID ="102185086"; 22 | 23 | /** 24 | * 插屏广告位id 25 | */ 26 | String AD_CODE_INSERT_ID ="102185564"; 27 | 28 | /** 29 | * 信息流(模板渲染)广告位id 30 | */ 31 | String AD_CODE_STREAM_ID ="102185565"; 32 | 33 | /** 34 | * 信息流(自渲染)广告位id 35 | */ 36 | String AD_CODE_STREAM_NATIVE_ID ="102185565"; 37 | 38 | /** 39 | * banner广告位id 40 | */ 41 | String AD_CODE_BANNER_ID ="102185374"; 42 | } -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/BoldTextView.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.text.TextPaint; 8 | import android.util.AttributeSet; 9 | import androidx.annotation.Nullable; 10 | import androidx.appcompat.widget.AppCompatTextView; 11 | 12 | /** 13 | * created by hty 14 | * 2022/7/10 15 | * Desc:字体加粗 16 | */ 17 | public class BoldTextView extends AppCompatTextView { 18 | 19 | private boolean mTextMarquee; 20 | private float mStrokeWidth=0.6f; 21 | 22 | public BoldTextView(Context context) { 23 | this(context,null); 24 | } 25 | 26 | public BoldTextView(Context context, @Nullable AttributeSet attrs) { 27 | this(context, attrs,0); 28 | } 29 | 30 | public BoldTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 31 | super(context, attrs, defStyleAttr); 32 | if(null!=attrs){ 33 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.BoldTextView); 34 | mStrokeWidth = typedArray.getFloat(R.styleable.BoldTextView_boldStorkeWidth,mStrokeWidth); 35 | mTextMarquee = typedArray.getBoolean(R.styleable.BoldTextView_boldMarquee,false); 36 | typedArray.recycle(); 37 | } 38 | } 39 | 40 | @Override 41 | protected void onDraw(Canvas canvas) { 42 | //获取当前控件的画笔 43 | TextPaint paint = getPaint(); 44 | //设置画笔的描边宽度值 45 | paint.setStrokeWidth(mStrokeWidth); 46 | paint.setStyle(Paint.Style.FILL_AND_STROKE); 47 | super.onDraw(canvas); 48 | } 49 | 50 | /** 51 | * 设置描边宽度 52 | * @param strokeWidth 从0.0起 53 | */ 54 | public void setStrokeWidth(float strokeWidth){ 55 | this.mStrokeWidth=strokeWidth; 56 | invalidate(); 57 | } 58 | 59 | @Override 60 | public boolean isFocused() { 61 | return mTextMarquee; 62 | } 63 | } -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/CoustomNativeRender.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import com.platform.lib.listener.NativeRenderControl; 6 | 7 | /** 8 | * created by hty 9 | * 2022/10/12 10 | * Desc:实现NativeRenderControl接口开始自定义渲染原生信息流广告 11 | */ 12 | public class CoustomNativeRender implements NativeRenderControl { 13 | 14 | /** 15 | * 返自定义UI View 16 | * @param context 创建自定义UI组件,广告ExpressView上下文 17 | * @return 18 | */ 19 | @Override 20 | public View getRenderView(Context context) { 21 | return View.inflate(context,R.layout.coustom_native_render,null); 22 | } 23 | 24 | @Override 25 | public void onRenderNativeView(View selfRenderView, com.bytedance.msdk.api.v2.ad.nativeAd.GMNativeAd nativeAd, float adWidth) { 26 | 27 | } 28 | 29 | /** 30 | * 将px转换成dp 31 | * @param context 32 | * @param pxValue 33 | * @return 34 | */ 35 | public static int pxToDpInt(Context context,float pxValue) { 36 | final float scale = context.getResources().getDisplayMetrics().density; 37 | return (int) (pxValue / (scale <= 0 ? 1 : scale) + 0.5f); 38 | } 39 | 40 | /** 41 | * 将dp转换成px 42 | * @param context 43 | * @param dipValue 44 | * @return 45 | */ 46 | public static int dpToPxInt(Context context,float dipValue) { 47 | final float scale = context.getResources().getDisplayMetrics().density; 48 | return (int) (dipValue * scale + 0.5f); 49 | } 50 | } -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/LayoutProvider.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | import android.graphics.Outline; 4 | import android.os.Build; 5 | import android.view.View; 6 | import android.view.ViewOutlineProvider; 7 | 8 | import androidx.annotation.RequiresApi; 9 | 10 | /** 11 | * Created by TinyHung@outlook.com 12 | * 2022/10/11 13 | */ 14 | 15 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) 16 | public class LayoutProvider extends ViewOutlineProvider { 17 | 18 | private float mRadius; 19 | 20 | public LayoutProvider(float radius){ 21 | this.mRadius = radius; 22 | } 23 | 24 | @Override 25 | public void getOutline(View view, Outline outline) { 26 | outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mRadius); 27 | view.setClipToOutline(true); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | import android.os.Bundle; 4 | import android.widget.TextView; 5 | import androidx.appcompat.app.AppCompatActivity; 6 | import com.platform.lib.listener.OnSplashStatusListener; 7 | import com.platform.lib.widget.SplashView; 8 | 9 | /** 10 | * created by hty 11 | * 2022/10/8 12 | * Desc:开屏广告演示 13 | */ 14 | public class SplashActivity extends AppCompatActivity implements OnSplashStatusListener { 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_splash); 20 | //拉取开屏广告 21 | SplashView splashAdView = (SplashView) findViewById(R.id.ad_splash); 22 | splashAdView.loadSplashAd(AdConfig.AD_CODE_SPLASH_ID, this); 23 | } 24 | 25 | @Override 26 | public void onShow() { 27 | 28 | } 29 | 30 | @Override 31 | public void onClose() { 32 | close(); 33 | } 34 | 35 | @Override 36 | public void onClick() { 37 | 38 | } 39 | 40 | 41 | @Override 42 | public void onError(int code, String message, String adCode) { 43 | ((TextView) findViewById(R.id.tv_status)).setText(String.format("广告加载失败,code:%s,adCode:%s\nmessage:%s",code,adCode,message)); 44 | } 45 | 46 | /** 47 | * 跳转至首页 48 | */ 49 | private void close() { 50 | finish(); 51 | } 52 | } -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/TTNumberUtil.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | public class TTNumberUtil { 4 | 5 | /** 6 | * object转double 7 | * 8 | * @param price 9 | * @return 10 | */ 11 | public static double getValue(Object price) { 12 | if (price instanceof Integer) { 13 | int result = (int) price; 14 | return (double) result; 15 | } 16 | 17 | if (price instanceof Float) { 18 | return (double) price; 19 | } 20 | 21 | if (price instanceof Double) { 22 | return (double) price; 23 | } 24 | 25 | try { 26 | if (price instanceof String) { 27 | return Double.valueOf((String) price); 28 | } 29 | } catch (Exception e) { 30 | 31 | } 32 | 33 | return 0; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/ThreadUtils.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | import java.util.concurrent.Callable; 6 | import java.util.concurrent.Future; 7 | import java.util.concurrent.LinkedBlockingQueue; 8 | import java.util.concurrent.ThreadPoolExecutor; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | public class ThreadUtils { 12 | private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors(); 13 | private static final int CORE_POOL_SIZE = Math.max(CPU_COUNT, 5); // 至少允许5个线程 14 | private static final int THREAD_KEEP_LIVE_TIME = 30; // 线程如果30秒不用,允许超时 15 | private static final int TASK_QUEUE_MAX_COUNT = 128; 16 | 17 | private static ThreadPoolExecutor mThreadPoolExecutor = new ThreadPoolExecutor(CORE_POOL_SIZE, 18 | CORE_POOL_SIZE, 19 | THREAD_KEEP_LIVE_TIME, 20 | TimeUnit.SECONDS, 21 | new LinkedBlockingQueue(TASK_QUEUE_MAX_COUNT)); 22 | 23 | public static Handler mMainHandler = new Handler(Looper.getMainLooper()); 24 | 25 | 26 | /** 27 | * 在子线程中运行任务 28 | * 29 | * @param runnable 30 | */ 31 | public static void runOnThreadPool(Runnable runnable) { 32 | mThreadPoolExecutor.execute(runnable); 33 | } 34 | 35 | /** 36 | * 在主线程中运行任务 37 | * 38 | * @param runnable 39 | */ 40 | public static void runOnUIThread(Runnable runnable) { 41 | if (Thread.currentThread() == Looper.getMainLooper().getThread()) { 42 | runnable.run(); 43 | } else { 44 | mMainHandler.post(runnable); 45 | } 46 | } 47 | 48 | /** 49 | * 在子线程中切主线程运行任务(切两次线程,先切子线程,再在子线程中切主线程) 50 | * 51 | * @param runnable 52 | */ 53 | public static void runOnUIThreadByThreadPool(Runnable runnable) { 54 | mThreadPoolExecutor.execute(new Runnable() { 55 | @Override 56 | public void run() { 57 | mMainHandler.post(runnable); 58 | } 59 | }); 60 | } 61 | 62 | /** 63 | * 在子线程中运行任务 64 | * 65 | * @param callable 66 | * @return 67 | */ 68 | public static Future runOnThreadPool(Callable callable) { 69 | return mThreadPoolExecutor.submit(callable); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/adn/gdt/GdtCustomerConfig.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple.adn.gdt; 2 | 3 | import android.content.Context; 4 | import com.bytedance.msdk.api.v2.ad.custom.bean.GMCustomInitConfig; 5 | import com.bytedance.msdk.api.v2.ad.custom.init.GMCustomAdapterConfiguration; 6 | import com.platform.simple.ThreadUtils; 7 | import com.qq.e.comm.managers.GDTAdSdk; 8 | import com.qq.e.comm.managers.setting.GlobalSetting; 9 | import com.qq.e.comm.managers.status.SDKStatus; 10 | import java.util.Map; 11 | 12 | /** 13 | * YLH 自定义初始化类 14 | */ 15 | public class GdtCustomerConfig extends GMCustomAdapterConfiguration { 16 | 17 | private static final String TAG = GdtCustomerConfig.class.getSimpleName(); 18 | 19 | @Override 20 | public void initializeADN(Context context, GMCustomInitConfig gmCustomConfig, Map localExtra) { 21 | 22 | /** 23 | * 在子线程中进行初始化 24 | */ 25 | ThreadUtils.runOnThreadPool(new Runnable() { 26 | @Override 27 | public void run() { 28 | GDTAdSdk.init(context, gmCustomConfig.getAppId()); 29 | GlobalSetting.setPersonalizedState(1);//优量汇个性化推荐广告开关,0为开启个性化推荐广告,1为屏蔽个性化推荐广告 30 | //初始化成功回调 31 | callInitSuccess(); 32 | } 33 | }); 34 | } 35 | 36 | @Override 37 | public String getNetworkSdkVersion() { 38 | return SDKStatus.getIntegrationSDKVersion(); 39 | } 40 | 41 | @Override 42 | public String getAdapterSdkVersion() { 43 | return "1.0.0"; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/adn/pangle/PangleCustomerConfig.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple.adn.pangle; 2 | 3 | import android.content.Context; 4 | import com.bytedance.msdk.api.v2.ad.custom.bean.GMCustomInitConfig; 5 | import com.bytedance.msdk.api.v2.ad.custom.init.GMCustomAdapterConfiguration; 6 | import com.bytedance.sdk.openadsdk.TTAdConfig; 7 | import com.bytedance.sdk.openadsdk.TTAdSdk; 8 | import java.util.Map; 9 | 10 | public class PangleCustomerConfig extends GMCustomAdapterConfiguration { 11 | 12 | @Override 13 | public void initializeADN(Context context, GMCustomInitConfig gmCustomConfig, Map localExtra) { 14 | TTAdConfig ttAdConfig = new TTAdConfig.Builder() 15 | .appId(gmCustomConfig.getAppId()) 16 | .appName("") 17 | .debug(true) //测试阶段打开,可以通过日志排查问题,上线时去除该调用 18 | .build(); 19 | TTAdSdk.init(context, ttAdConfig, new TTAdSdk.InitCallback() { 20 | @Override 21 | public void success() { 22 | } 23 | 24 | @Override 25 | public void fail(int i, String s) { 26 | } 27 | }); 28 | callInitSuccess(); 29 | } 30 | 31 | @Override 32 | public String getNetworkSdkVersion() { 33 | return "4.0.0.0"; 34 | } 35 | 36 | @Override 37 | public String getAdapterSdkVersion() { 38 | return "1.0.0"; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/adn/pangle/PangleCustomerDraw.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple.adn.pangle; 2 | 3 | import android.content.Context; 4 | import com.bytedance.msdk.api.v2.GMAdConstant; 5 | import com.bytedance.msdk.api.v2.ad.custom.GMCustomAdError; 6 | import com.bytedance.msdk.api.v2.ad.custom.bean.GMCustomServiceConfig; 7 | import com.bytedance.msdk.api.v2.ad.custom.draw.GMCustomDrawAdapter; 8 | import com.bytedance.msdk.api.v2.slot.GMAdSlotDraw; 9 | import com.bytedance.sdk.openadsdk.TTAdNative; 10 | import com.bytedance.sdk.openadsdk.TTAdSdk; 11 | import com.bytedance.sdk.openadsdk.TTDrawFeedAd; 12 | import com.bytedance.sdk.openadsdk.TTFeedAd; 13 | import com.bytedance.sdk.openadsdk.TTNativeExpressAd; 14 | import com.platform.simple.TTNumberUtil; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | public class PangleCustomerDraw extends GMCustomDrawAdapter { 20 | 21 | @Override 22 | public void load(Context context, GMAdSlotDraw adSlot, GMCustomServiceConfig serviceConfig) { 23 | int width = adSlot.getWidth(); 24 | int height = adSlot.getHeight(); 25 | TTAdNative adNativeLoader = TTAdSdk.getAdManager().createAdNative(context); 26 | com.bytedance.sdk.openadsdk.AdSlot.Builder adSlotBuilder = new com.bytedance.sdk.openadsdk.AdSlot.Builder() 27 | .setCodeId(serviceConfig.getADNNetworkSlotId()) //广告位id 28 | .setSupportDeepLink(true) 29 | .setExpressViewAcceptedSize(width, height) 30 | .setAdCount(1); //请求广告数量为1到3条 31 | if (isNativeAd()) { 32 | //自渲染 33 | adNativeLoader.loadDrawFeedAd(adSlotBuilder.build(), new TTAdNative.DrawFeedAdListener() { 34 | @Override 35 | public void onError(int i, String s) { 36 | callLoadFail(new GMCustomAdError(i, s)); 37 | } 38 | 39 | @Override 40 | public void onDrawFeedAdLoad(List list) { 41 | List tempList = new ArrayList<>(); 42 | for (TTFeedAd feedAd : list) { 43 | PangleDrawAd pangleNativeAd = new PangleDrawAd(feedAd); 44 | if (isClientBidding()) {//bidding广告类型 45 | Map extraInfo = feedAd.getMediaExtraInfo(); 46 | //设置cpm 47 | if (extraInfo != null) { 48 | double cpm = TTNumberUtil.getValue(extraInfo.get("price")); 49 | pangleNativeAd.setBiddingPrice(cpm > 0 ? cpm : 0); //回传竞价广告价格 50 | } 51 | } 52 | pangleNativeAd.setDislikeDialog(); //自渲染dialog弹窗 53 | tempList.add(pangleNativeAd); 54 | } 55 | callLoadSuccess(tempList); 56 | } 57 | }); 58 | } else { 59 | //模板 60 | adNativeLoader.loadExpressDrawFeedAd(adSlotBuilder.build(), new TTAdNative.NativeExpressAdListener() { 61 | @Override 62 | public void onError(int i, String s) { 63 | callLoadFail(new GMCustomAdError(i, s)); 64 | } 65 | 66 | @Override 67 | public void onNativeExpressAdLoad(List list) { 68 | List tempList = new ArrayList<>(); 69 | for (TTNativeExpressAd feedAd : list) { 70 | PangleDrawExpressAd pangleNativeExpressAd = new PangleDrawExpressAd(context, feedAd); 71 | if (isClientBidding()) {//bidding广告类型 72 | Map extraInfo = feedAd.getMediaExtraInfo(); 73 | //设置cpm 74 | if (extraInfo != null) { 75 | double cpm = TTNumberUtil.getValue(extraInfo.get("price")); 76 | pangleNativeExpressAd.setBiddingPrice(cpm > 0 ? cpm : 0);//回传竞价广告价格 77 | } 78 | } 79 | tempList.add(pangleNativeExpressAd); 80 | } 81 | callLoadSuccess(tempList); 82 | } 83 | }); 84 | } 85 | } 86 | 87 | /** 88 | * 是否clientBidding广告 89 | * 90 | * @return 91 | */ 92 | public boolean isClientBidding() { 93 | return getBiddingType() == GMAdConstant.AD_TYPE_CLIENT_BIDING; 94 | } 95 | 96 | @Override 97 | public void receiveBidResult(boolean win, double winnerPrice, int loseReason, Map extra) { 98 | super.receiveBidResult(win, winnerPrice, loseReason, extra); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/adn/pangle/PangleCustomerInterstitial.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple.adn.pangle; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.view.View; 6 | 7 | import com.bytedance.msdk.adapter.pangle.PangleAdapterUtils; 8 | import com.bytedance.msdk.api.v2.GMAdConstant; 9 | import com.bytedance.msdk.api.v2.ad.custom.GMCustomAdError; 10 | import com.bytedance.msdk.api.v2.ad.custom.bean.GMCustomServiceConfig; 11 | import com.bytedance.msdk.api.v2.ad.custom.interstitial.GMCustomInterstitialAdapter; 12 | import com.bytedance.msdk.api.v2.slot.GMAdSlotInterstitial; 13 | import com.bytedance.sdk.openadsdk.TTAdNative; 14 | import com.bytedance.sdk.openadsdk.TTAdSdk; 15 | import com.bytedance.sdk.openadsdk.TTNativeExpressAd; 16 | 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | public class PangleCustomerInterstitial extends GMCustomInterstitialAdapter { 21 | 22 | private TTNativeExpressAd mTTNativeExpressAd; 23 | private boolean isLoadSuccess; 24 | private PangleAdapterUtils TTNumberUtil; 25 | 26 | @Override 27 | public void load(Context context, GMAdSlotInterstitial adSlot, GMCustomServiceConfig serviceConfig) { 28 | TTAdNative adNativeLoader = TTAdSdk.getAdManager().createAdNative(context); 29 | com.bytedance.sdk.openadsdk.AdSlot.Builder adSlotBuilder = new com.bytedance.sdk.openadsdk.AdSlot.Builder() 30 | .setCodeId(serviceConfig.getADNNetworkSlotId()) //广告位id 31 | .setSupportDeepLink(true) 32 | .setAdCount(1); //请求广告数量为1到3条 33 | adNativeLoader.loadInteractionExpressAd(adSlotBuilder.build(), new TTAdNative.NativeExpressAdListener() { 34 | @Override 35 | public void onError(int code, String message) { 36 | callLoadFail(new GMCustomAdError(code, message)); 37 | } 38 | 39 | @Override 40 | public void onNativeExpressAdLoad(List ads) { 41 | mTTNativeExpressAd = ads.get(0); 42 | mTTNativeExpressAd.setExpressInteractionListener(new TTNativeExpressAd.AdInteractionListener() { 43 | @Override 44 | public void onAdDismiss() { 45 | callInterstitialClosed(); 46 | } 47 | 48 | @Override 49 | public void onAdClicked(View view, int i) { 50 | callInterstitialAdClick(); 51 | } 52 | 53 | @Override 54 | public void onAdShow(View view, int i) { 55 | callInterstitialShow(); 56 | } 57 | 58 | @Override 59 | public void onRenderFail(View view, String s, int i) { 60 | } 61 | 62 | @Override 63 | public void onRenderSuccess(View view, float v, float v1) { 64 | isLoadSuccess = true; 65 | } 66 | }); 67 | mTTNativeExpressAd.render(); 68 | 69 | // 获取adn的extra信息(可选),注意需要在callLoadSuccess之前设置 70 | setMediaExtraInfo(mTTNativeExpressAd.getMediaExtraInfo()); 71 | 72 | if (isClientBidding()) {//bidding广告类型 73 | Map extraInfo = mTTNativeExpressAd.getMediaExtraInfo(); 74 | double cpm = 0; 75 | //设置cpm 76 | if (extraInfo != null) { 77 | cpm = TTNumberUtil.getValue(extraInfo.get("price")); 78 | } 79 | callLoadSuccess(cpm);//bidding广告成功回调,回传竞价广告价格 80 | } else { 81 | callLoadSuccess();//普通广告成功回调 82 | } 83 | } 84 | }); 85 | } 86 | 87 | @Override 88 | public void showAd(Activity activity) { 89 | if (mTTNativeExpressAd != null) { 90 | mTTNativeExpressAd.showInteractionExpressAd(activity); 91 | } 92 | } 93 | 94 | /** 95 | * 是否clientBidding广告 96 | * 97 | * @return 98 | */ 99 | public boolean isClientBidding() { 100 | return getBiddingType() == GMAdConstant.AD_TYPE_CLIENT_BIDING; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/adn/pangle/PangleCustomerNative.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple.adn.pangle; 2 | 3 | import android.content.Context; 4 | 5 | import com.bytedance.msdk.api.v2.GMAdConstant; 6 | import com.bytedance.msdk.api.v2.ad.custom.GMCustomAdError; 7 | import com.bytedance.msdk.api.v2.ad.custom.bean.GMCustomServiceConfig; 8 | import com.bytedance.msdk.api.v2.ad.custom.nativeAd.GMCustomNativeAdapter; 9 | import com.bytedance.msdk.api.v2.slot.GMAdSlotNative; 10 | import com.bytedance.sdk.openadsdk.TTAdNative; 11 | import com.bytedance.sdk.openadsdk.TTAdSdk; 12 | import com.bytedance.sdk.openadsdk.TTFeedAd; 13 | import com.bytedance.sdk.openadsdk.TTNativeExpressAd; 14 | import com.platform.simple.TTNumberUtil; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | public class PangleCustomerNative extends GMCustomNativeAdapter { 21 | 22 | @Override 23 | public void load(Context context, GMAdSlotNative adSlot, GMCustomServiceConfig serviceConfig) { 24 | TTAdNative adNativeLoader = TTAdSdk.getAdManager().createAdNative(context); 25 | com.bytedance.sdk.openadsdk.AdSlot.Builder adSlotBuilder = new com.bytedance.sdk.openadsdk.AdSlot.Builder() 26 | .setCodeId(serviceConfig.getADNNetworkSlotId()) //广告位id 27 | .setSupportDeepLink(true) 28 | .setAdCount(1); //请求广告数量为1到3条 29 | if (isNativeAd()) { 30 | //自渲染 31 | adNativeLoader.loadFeedAd(adSlotBuilder.build(), new TTAdNative.FeedAdListener() { 32 | 33 | @Override 34 | public void onError(int i, String s) { 35 | callLoadFail(new GMCustomAdError(i, s)); 36 | } 37 | 38 | @Override 39 | public void onFeedAdLoad(List list) { 40 | List tempList = new ArrayList<>(); 41 | for (TTFeedAd feedAd : list) { 42 | PangleNativeAd pangleNativeAd = new PangleNativeAd(feedAd); 43 | if (isClientBidding()) {//bidding广告类型 44 | Map extraInfo = feedAd.getMediaExtraInfo(); 45 | //设置cpm 46 | if (extraInfo != null) { 47 | double cpm = TTNumberUtil.getValue(extraInfo.get("price")); 48 | pangleNativeAd.setBiddingPrice(cpm > 0 ? cpm : 0); //回传竞价广告价格 49 | } 50 | } 51 | pangleNativeAd.setDislikeDialog(); //自渲染dialog弹窗 52 | tempList.add(pangleNativeAd); 53 | } 54 | callLoadSuccess(tempList); 55 | } 56 | }); 57 | } else { 58 | //模板 59 | adNativeLoader.loadNativeExpressAd(adSlotBuilder.build(), new TTAdNative.NativeExpressAdListener() { 60 | @Override 61 | public void onError(int i, String s) { 62 | callLoadFail(new GMCustomAdError(i, s)); 63 | } 64 | 65 | @Override 66 | public void onNativeExpressAdLoad(List list) { 67 | List tempList = new ArrayList<>(); 68 | for (TTNativeExpressAd feedAd : list) { 69 | PangleNativeExpressAd pangleNativeExpressAd = new PangleNativeExpressAd(context, feedAd); 70 | if (isClientBidding()) {//bidding广告类型 71 | Map extraInfo = feedAd.getMediaExtraInfo(); 72 | //设置cpm 73 | if (extraInfo != null) { 74 | double cpm = TTNumberUtil.getValue(extraInfo.get("price")); 75 | pangleNativeExpressAd.setBiddingPrice(cpm > 0 ? cpm : 0);//回传竞价广告价格 76 | } 77 | } 78 | tempList.add(pangleNativeExpressAd); 79 | } 80 | callLoadSuccess(tempList); 81 | } 82 | }); 83 | } 84 | } 85 | 86 | /** 87 | * 是否clientBidding广告 88 | * 89 | * @return 90 | */ 91 | public boolean isClientBidding() { 92 | return getBiddingType() == GMAdConstant.AD_TYPE_CLIENT_BIDING; 93 | } 94 | 95 | @Override 96 | public void receiveBidResult(boolean win, double winnerPrice, int loseReason, Map extra) { 97 | super.receiveBidResult(win, winnerPrice, loseReason, extra); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/adn/pangle/PangleCustomerSplash.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple.adn.pangle; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.view.ViewParent; 7 | import com.bytedance.msdk.api.v2.GMAdConstant; 8 | import com.bytedance.msdk.api.v2.ad.custom.GMCustomAdError; 9 | import com.bytedance.msdk.api.v2.ad.custom.bean.GMCustomServiceConfig; 10 | import com.bytedance.msdk.api.v2.ad.custom.splash.GMCustomSplashAdapter; 11 | import com.bytedance.msdk.api.v2.slot.GMAdSlotSplash; 12 | import com.bytedance.sdk.openadsdk.TTAdNative; 13 | import com.bytedance.sdk.openadsdk.TTAdSdk; 14 | import com.bytedance.sdk.openadsdk.TTSplashAd; 15 | import com.platform.simple.TTNumberUtil; 16 | import java.util.Map; 17 | 18 | public class PangleCustomerSplash extends GMCustomSplashAdapter { 19 | 20 | private TTSplashAd mTTSplashAd; 21 | 22 | @Override 23 | public void load(Context context, GMAdSlotSplash adSlot, GMCustomServiceConfig serviceConfig) { 24 | TTAdNative adNativeLoader = TTAdSdk.getAdManager().createAdNative(context); 25 | com.bytedance.sdk.openadsdk.AdSlot.Builder adSlotBuilder = new com.bytedance.sdk.openadsdk.AdSlot.Builder() 26 | .setCodeId(serviceConfig.getADNNetworkSlotId()) //广告位id 27 | .setSupportDeepLink(true) 28 | .setExpressViewAcceptedSize(1080,1920) 29 | .setAdCount(1); //请求广告数量为1到3条 30 | adNativeLoader.loadSplashAd(adSlotBuilder.build(), new TTAdNative.SplashAdListener() { 31 | @Override 32 | public void onError(int i, String s) { 33 | callLoadFail(new GMCustomAdError(i, s)); 34 | } 35 | 36 | @Override 37 | public void onTimeout() { 38 | } 39 | 40 | @Override 41 | public void onSplashAdLoad(TTSplashAd ttSplashAd) { 42 | mTTSplashAd = ttSplashAd; 43 | mTTSplashAd.setSplashInteractionListener(new TTSplashAd.AdInteractionListener() { 44 | @Override 45 | public void onAdClicked(View view, int i) { 46 | callSplashAdClicked(); 47 | } 48 | 49 | @Override 50 | public void onAdShow(View view, int i) { 51 | callSplashAdShow(); 52 | } 53 | 54 | @Override 55 | public void onAdSkip() { 56 | callSplashAdSkip(); 57 | } 58 | 59 | @Override 60 | public void onAdTimeOver() { 61 | callSplashAdDismiss(); 62 | } 63 | }); 64 | 65 | // 获取adn的extra信息(可选),注意需要在callLoadSuccess之前设置 66 | setMediaExtraInfo(mTTSplashAd.getMediaExtraInfo()); 67 | 68 | if (isClientBidding()) {//bidding广告类型 69 | Map extraInfo = mTTSplashAd.getMediaExtraInfo(); 70 | double cpm = 0; 71 | //设置cpm 72 | if (extraInfo != null) { 73 | cpm = TTNumberUtil.getValue(extraInfo.get("price")); 74 | } 75 | callLoadSuccess(cpm);//bidding广告成功回调,回传竞价广告价格 76 | } else { 77 | callLoadSuccess();//普通广告成功回调 78 | } 79 | } 80 | }, adSlot.getTimeOut()); 81 | 82 | } 83 | 84 | @Override 85 | public void showAd(ViewGroup container) { 86 | if (mTTSplashAd != null) { 87 | View view = mTTSplashAd.getSplashView(); 88 | if (view != null) { 89 | ViewParent parent = view.getParent(); 90 | if (parent instanceof ViewGroup) { 91 | ((ViewGroup) parent).removeView(view); 92 | } 93 | container.removeAllViews(); 94 | container.addView(view); 95 | } 96 | } 97 | } 98 | 99 | /** 100 | * 是否clientBidding广告 101 | * 102 | * @return 103 | */ 104 | public boolean isClientBidding() { 105 | return getBiddingType() == GMAdConstant.AD_TYPE_CLIENT_BIDING; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/adn/pangle/PangleDrawExpressAd.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple.adn.pangle; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.view.View; 6 | import com.bytedance.msdk.api.TTAdConstant; 7 | import com.bytedance.msdk.api.v2.ad.custom.GMCustomAdError; 8 | import com.bytedance.msdk.api.v2.ad.custom.draw.GMCustomDrawAd; 9 | import com.bytedance.sdk.openadsdk.TTAdDislike; 10 | import com.bytedance.sdk.openadsdk.TTNativeExpressAd; 11 | 12 | public class PangleDrawExpressAd extends GMCustomDrawAd { 13 | 14 | private TTNativeExpressAd mTTFeedAd; 15 | private Context mContext; 16 | 17 | public PangleDrawExpressAd(Context context, TTNativeExpressAd feedAd) { 18 | this.mTTFeedAd = feedAd; 19 | this.mContext = context; 20 | this.setAdImageMode(feedAd.getImageMode()); 21 | this.setInteractionType(feedAd.getInteractionType()); 22 | this.setMediaExtraInfo(feedAd.getMediaExtraInfo()); 23 | feedAd.setExpressInteractionListener(new TTNativeExpressAd.AdInteractionListener() { 24 | @Override 25 | public void onAdDismiss() { 26 | } 27 | 28 | @Override 29 | public void onAdClicked(View view, int i) { 30 | callDrawAdClick(); 31 | } 32 | 33 | @Override 34 | public void onAdShow(View view, int i) { 35 | callDrawAdShow(); 36 | } 37 | 38 | @Override 39 | public void onRenderFail(View view, String s, int i) { 40 | callDrawRenderFail(view, s, i); 41 | } 42 | 43 | @Override 44 | public void onRenderSuccess(View view, float v, float v1) { 45 | callDrawRenderSuccess(v, v1); 46 | } 47 | }); 48 | if (feedAd.getImageMode() == TTAdConstant.IMAGE_MODE_VIDEO) { 49 | feedAd.setVideoAdListener(new TTNativeExpressAd.ExpressVideoAdListener() { 50 | @Override 51 | public void onVideoLoad() { 52 | } 53 | 54 | @Override 55 | public void onVideoError(int i, int i1) { 56 | callDrawVideoError(new GMCustomAdError(i, i1 + "")); 57 | } 58 | 59 | @Override 60 | public void onVideoAdStartPlay() { 61 | callDrawVideoStart(); 62 | } 63 | 64 | @Override 65 | public void onVideoAdPaused() { 66 | callDrawVideoPause(); 67 | } 68 | 69 | @Override 70 | public void onVideoAdContinuePlay() { 71 | callDrawVideoResume(); 72 | } 73 | 74 | @Override 75 | public void onProgressUpdate(long current, long duration) { 76 | callDrawVideoProgressUpdate(current, duration); 77 | } 78 | 79 | @Override 80 | public void onVideoAdComplete() { 81 | callDrawVideoCompleted(); 82 | } 83 | 84 | @Override 85 | public void onClickRetry() { 86 | 87 | } 88 | }); 89 | } 90 | if(mContext instanceof Activity){ 91 | mTTFeedAd.setDislikeCallback((Activity) mContext, new TTAdDislike.DislikeInteractionCallback() { 92 | @Override 93 | public void onShow() { 94 | callDrawDislikeShow(); 95 | } 96 | 97 | @Override 98 | public void onSelected(int i, String s, boolean b) { 99 | callDrawDislikeSelected(i,s); 100 | } 101 | 102 | @Override 103 | public void onCancel() { 104 | callDrawDislikeCancel(); 105 | } 106 | }); 107 | } 108 | } 109 | 110 | /** 111 | * 如果Adn 有dislike接口需要返回true 112 | */ 113 | @Override 114 | public boolean hasDislike() { 115 | return true; 116 | } 117 | 118 | @Override 119 | public void render() { 120 | if (mTTFeedAd != null) { 121 | mTTFeedAd.render(); 122 | } 123 | } 124 | 125 | @Override 126 | public View getExpressView() { 127 | if (mTTFeedAd != null) { 128 | return mTTFeedAd.getExpressAdView(); 129 | } 130 | return null; 131 | } 132 | 133 | @Override 134 | public void onPause() { 135 | super.onPause(); 136 | } 137 | 138 | @Override 139 | public void onResume() { 140 | super.onResume(); 141 | } 142 | 143 | @Override 144 | public void onDestroy() { 145 | super.onDestroy(); 146 | } 147 | } -------------------------------------------------------------------------------- /app-gromore/src/main/java/com/platform/simple/adn/pangle/PangleNativeExpressAd.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple.adn.pangle; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.view.View; 6 | import com.bytedance.msdk.api.TTAdConstant; 7 | import com.bytedance.msdk.api.v2.ad.custom.GMCustomAdError; 8 | import com.bytedance.msdk.api.v2.ad.custom.nativeAd.GMCustomNativeAd; 9 | import com.bytedance.sdk.openadsdk.TTAdDislike; 10 | import com.bytedance.sdk.openadsdk.TTNativeExpressAd; 11 | 12 | public class PangleNativeExpressAd extends GMCustomNativeAd { 13 | 14 | private TTNativeExpressAd mTTFeedAd; 15 | private Context mContext; 16 | 17 | public PangleNativeExpressAd(Context context,TTNativeExpressAd feedAd) { 18 | this.mTTFeedAd = feedAd; 19 | this.mContext = context; 20 | this.setAdImageMode(feedAd.getImageMode()); 21 | this.setInteractionType(feedAd.getInteractionType()); 22 | this.setMediaExtraInfo(feedAd.getMediaExtraInfo()); 23 | feedAd.setExpressInteractionListener(new TTNativeExpressAd.AdInteractionListener() { 24 | @Override 25 | public void onAdDismiss() { 26 | } 27 | 28 | @Override 29 | public void onAdClicked(View view, int i) { 30 | callNativeAdClick(); 31 | } 32 | 33 | @Override 34 | public void onAdShow(View view, int i) { 35 | callNativeAdShow(); 36 | } 37 | 38 | @Override 39 | public void onRenderFail(View view, String s, int i) { 40 | callNativeRenderFail(view, s, i); 41 | } 42 | 43 | @Override 44 | public void onRenderSuccess(View view, float v, float v1) { 45 | callNativeRenderSuccess(v, v1); 46 | } 47 | }); 48 | if (feedAd.getImageMode() == TTAdConstant.IMAGE_MODE_VIDEO) { 49 | feedAd.setVideoAdListener(new TTNativeExpressAd.ExpressVideoAdListener() { 50 | @Override 51 | public void onVideoLoad() { 52 | } 53 | 54 | @Override 55 | public void onVideoError(int i, int i1) { 56 | callNativeVideoError(new GMCustomAdError(i, i1 + "")); 57 | } 58 | 59 | @Override 60 | public void onVideoAdStartPlay() { 61 | callNativeVideoStart(); 62 | } 63 | 64 | @Override 65 | public void onVideoAdPaused() { 66 | callNativeVideoPause(); 67 | } 68 | 69 | @Override 70 | public void onVideoAdContinuePlay() { 71 | callNativeVideoResume(); 72 | } 73 | 74 | @Override 75 | public void onProgressUpdate(long current, long duration) { 76 | callNativeVideoProgressUpdate(current, duration); 77 | } 78 | 79 | @Override 80 | public void onVideoAdComplete() { 81 | callNativeVideoCompleted(); 82 | } 83 | 84 | @Override 85 | public void onClickRetry() { 86 | 87 | } 88 | }); 89 | } 90 | if(mContext instanceof Activity){ 91 | mTTFeedAd.setDislikeCallback((Activity) mContext, new TTAdDislike.DislikeInteractionCallback() { 92 | @Override 93 | public void onShow() { 94 | callNativeDislikeShow(); 95 | } 96 | 97 | @Override 98 | public void onSelected(int i, String s, boolean b) { 99 | callNativeDislikeSelected(i,s); 100 | } 101 | 102 | @Override 103 | public void onCancel() { 104 | callNativeDislikeCancel(); 105 | } 106 | }); 107 | } 108 | } 109 | 110 | /** 111 | * 如果Adn 有dislike接口需要返回true 112 | */ 113 | @Override 114 | public boolean hasDislike() { 115 | return true; 116 | } 117 | 118 | @Override 119 | public void render() { 120 | if (mTTFeedAd != null) { 121 | mTTFeedAd.render(); 122 | } 123 | } 124 | 125 | @Override 126 | public View getExpressView() { 127 | if (mTTFeedAd != null) { 128 | return mTTFeedAd.getExpressAdView(); 129 | } 130 | return null; 131 | } 132 | 133 | @Override 134 | public void onPause() { 135 | super.onPause(); 136 | } 137 | 138 | @Override 139 | public void onResume() { 140 | super.onResume(); 141 | } 142 | 143 | @Override 144 | public void onDestroy() { 145 | super.onDestroy(); 146 | } 147 | } -------------------------------------------------------------------------------- /app-gromore/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/drawable/bg_ad_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/drawable/bg_tool_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/drawable/coustom_native_bg_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 12 | 16 | 17 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/layout/coustom_native_render.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 24 | 28 | 29 | 36 | 37 | 43 | 44 | 51 | 52 | 53 | 60 | 61 | 70 | 81 | 82 | 90 | 101 | 102 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/mipmap-xxhdpi/ic_ad_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-gromore/src/main/res/mipmap-xxhdpi/ic_ad_menu.png -------------------------------------------------------------------------------- /app-gromore/src/main/res/raw/keep.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | GromoreSDK 3 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app-gromore/src/main/res/xml/pangle_file_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app-topon/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.txt -------------------------------------------------------------------------------- /app-topon/app/release/app-topon-1.1.6.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/app/release/app-topon-1.1.6.apk -------------------------------------------------------------------------------- /app-topon/app/release/output-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "artifactType": { 4 | "type": "APK", 5 | "kind": "Directory" 6 | }, 7 | "applicationId": "com.anythink.sdk.demo", 8 | "variantName": "appRelease", 9 | "elements": [ 10 | { 11 | "type": "SINGLE", 12 | "filters": [], 13 | "properties": [], 14 | "versionCode": 6, 15 | "versionName": "1.1.6", 16 | "enabled": true, 17 | "outputFile": "app-topon-app-release.apk" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /app-topon/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.3" 6 | 7 | defaultConfig { 8 | applicationId rootProject.ext.topon.applicationId 9 | minSdkVersion 21 10 | targetSdkVersion 29 11 | versionCode rootProject.ext.topon.versionCode 12 | versionName rootProject.ext.topon.versionName 13 | 14 | multiDexEnabled true 15 | ndk { 16 | //穿山甲:arm64-v8a、armeabi-v7a 17 | //快手广告:arm64-v8a、armeabi-v7a、armeabi、x86_64、x86 18 | abiFilters 'armeabi-v7a','arm64-v8a' 19 | } 20 | } 21 | 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | compileOptions { 29 | sourceCompatibility JavaVersion.VERSION_1_8 30 | targetCompatibility JavaVersion.VERSION_1_8 31 | } 32 | 33 | signingConfigs { 34 | debug { 35 | storeFile file('topon.keystore') 36 | storePassword "123456" 37 | keyAlias "topon" 38 | keyPassword "123456" 39 | v1SigningEnabled true 40 | v2SigningEnabled false 41 | } 42 | release { 43 | storeFile file('topon.keystore') 44 | storePassword "123456" 45 | keyAlias "topon" 46 | keyPassword "123456" 47 | v1SigningEnabled true 48 | v2SigningEnabled false 49 | } 50 | } 51 | 52 | buildTypes { 53 | debug { 54 | debuggable true 55 | signingConfig signingConfigs.release 56 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 57 | } 58 | release { 59 | debuggable false 60 | zipAlignEnabled true 61 | shrinkResources true 62 | minifyEnabled true 63 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 64 | signingConfig signingConfigs.release 65 | } 66 | } 67 | 68 | flavorDimensions "app" 69 | productFlavors { 70 | app { 71 | applicationId rootProject.ext.topon.applicationId 72 | versionCode rootProject.ext.topon.versionCode 73 | versionName rootProject.ext.topon.versionName 74 | dimension "app" 75 | signingConfig signingConfigs.release 76 | } 77 | } 78 | } 79 | 80 | dependencies { 81 | implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') 82 | implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs_topon') 83 | implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs-adn') 84 | implementation 'androidx.multidex:multidex:2.0.1'//当minSdkVersion>=21时会出现找不到androidx.multidex.MultiDexApplication 85 | 86 | //广告功能逻辑SDK 87 | implementation project(':topon') 88 | // implementation 'com.github.hty527.advert:topon:1.1.6.1' 89 | 90 | /** 91 | * 如果是Support环境 92 | */ 93 | //implementation "com.android.support:appcompat-v7:28.0.0" 94 | //implementation 'com.android.support:localbroadcastmanager:28.0.0' 95 | //集成包含快手广告需要添加下列1个依赖库 96 | //implementation "com.android.support:design:28.0.0" 97 | //dex 分包,当minSdkVersion>=21时会出现找不到androidx.multidex.MultiDexApplication 解决办法 98 | //implementation 'com.android.support:multidex:1.0.3' 99 | 100 | /** 101 | * 如果是androidx环境 102 | * 需在工程的gradle.properties文件增加下列配置: 103 | * android.useAndroidX=true 104 | * android.enableJetifier=true 105 | */ 106 | implementation 'androidx.appcompat:appcompat:1.0.2' 107 | implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0' 108 | //dex 分包,当minSdkVersion>=21时会出现找不到androidx.multidex.MultiDexApplication 解决办法 109 | implementation 'androidx.multidex:multidex:2.0.1' 110 | //集成包含快手广告需要添加下列2个依赖库 111 | implementation "androidx.recyclerview:recyclerview:1.2.0" 112 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 113 | } -------------------------------------------------------------------------------- /app-topon/libs-adn/GDTSDK.unionNormal.4.511.1381.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs-adn/GDTSDK.unionNormal.4.511.1381.aar -------------------------------------------------------------------------------- /app-topon/libs-adn/anythink_network_gdt.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs-adn/anythink_network_gdt.aar -------------------------------------------------------------------------------- /app-topon/libs-adn/anythink_network_kuaishou.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs-adn/anythink_network_kuaishou.aar -------------------------------------------------------------------------------- /app-topon/libs-adn/anythink_network_pangle_china.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs-adn/anythink_network_pangle_china.aar -------------------------------------------------------------------------------- /app-topon/libs-adn/kssdk-ad-3.3.42-publishRelease-fe31265b3d.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs-adn/kssdk-ad-3.3.42-publishRelease-fe31265b3d.aar -------------------------------------------------------------------------------- /app-topon/libs-adn/open_ad_sdk_5.2.0.5.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs-adn/open_ad_sdk_5.2.0.5.aar -------------------------------------------------------------------------------- /app-topon/libs/oaid_sdk_1.0.25.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs/oaid_sdk_1.0.25.aar -------------------------------------------------------------------------------- /app-topon/libs_topon/anythink_banner.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs_topon/anythink_banner.aar -------------------------------------------------------------------------------- /app-topon/libs_topon/anythink_china_core.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs_topon/anythink_china_core.aar -------------------------------------------------------------------------------- /app-topon/libs_topon/anythink_core.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs_topon/anythink_core.aar -------------------------------------------------------------------------------- /app-topon/libs_topon/anythink_interstitial.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs_topon/anythink_interstitial.aar -------------------------------------------------------------------------------- /app-topon/libs_topon/anythink_native.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs_topon/anythink_native.aar -------------------------------------------------------------------------------- /app-topon/libs_topon/anythink_rewardvideo.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs_topon/anythink_rewardvideo.aar -------------------------------------------------------------------------------- /app-topon/libs_topon/anythink_splash.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs_topon/anythink_splash.aar -------------------------------------------------------------------------------- /app-topon/libs_topon/gson-2.8.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs_topon/gson-2.8.4.jar -------------------------------------------------------------------------------- /app-topon/libs_topon/tramini_sdk.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/libs_topon/tramini_sdk.aar -------------------------------------------------------------------------------- /app-topon/sdk/topon_sdk_1.1.2.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/sdk/topon_sdk_1.1.2.aar -------------------------------------------------------------------------------- /app-topon/src/androidTest/java/com/platform/simple/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.advert.topon", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /app-topon/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 37 | 40 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 50 | 51 | 52 | 53 | 57 | 62 | 65 | 66 | 67 | 72 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /app-topon/src/main/assets/supplierconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "supplier": { 3 | "vivo": { 4 | "appid": "100215079" 5 | }, 6 | "xiaomi": { 7 | }, 8 | "huawei": { 9 | }, 10 | "oppo": { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app-topon/src/main/java/com/platform/simple/AdConfig.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | /** 4 | * created by hty 5 | * 2022/6/17 6 | * Desc:广告位物料,更多测试代码位请参考:https://docs.toponad.com/#/zh-cn/android/android_doc/android_test 7 | */ 8 | public interface AdConfig { 9 | 10 | String TO_APP_ID = "a62b013be01931";//测试app_id 11 | String TO_APP_KAY = "c3d0d2a9a9d451b07e62b509659f7c97";//测试key 12 | 13 | /** 14 | * 激励视频位id 15 | */ 16 | String AD_CODE_REWARD_ID ="b62b03c000844f"; //穿山甲:b62b03c000844f,快手:b62b032b44e3e2,优量汇:b62b0355867507 17 | 18 | /** 19 | * 开屏广告位id 20 | */ 21 | String AD_CODE_SPLASH_ID ="b62b035f70b2ac"; //穿山甲:b62b035f70b2ac,快手:b62b02dd64934e,优量汇:b62b03605066c1 22 | 23 | /** 24 | * 插屏广告位id 25 | */ 26 | String AD_CODE_INSERT_ID ="b62b0397ba87a8"; //穿山甲:b62b0397ba87a8,快手:b62b032a9446be,优量汇:b62b03987b081c 27 | 28 | /** 29 | * 信息流(模板渲染)广告位id 30 | */ 31 | String AD_CODE_STREAM_ID ="b62ea2e1248bfa"; //穿山甲:b62ea2e1248bfa,快手:b62ea2a0843eb9,优量汇:b62ea546e02034 32 | 33 | /** 34 | * 信息流(自渲染)广告位id 35 | */ 36 | String AD_CODE_STREAM_NATIVE_ID ="b62ea2e2ae729e"; //穿山甲:b62ea2e2ae729e,快手:b62ea2a1ff0a02,优量汇:b62ea5487275ef 37 | 38 | /** 39 | * banner广告位id 40 | */ 41 | String AD_CODE_BANNER_ID ="b62b03bacdcf28"; //穿山甲:b62b03bacdcf28,快手:不支持,优量汇:b62b03bbdd6cf5 42 | } -------------------------------------------------------------------------------- /app-topon/src/main/java/com/platform/simple/BoldTextView.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.text.TextPaint; 8 | import android.util.AttributeSet; 9 | import androidx.annotation.Nullable; 10 | import androidx.appcompat.widget.AppCompatTextView; 11 | 12 | /** 13 | * created by hty 14 | * 2022/7/10 15 | * Desc:字体加粗 16 | */ 17 | public class BoldTextView extends AppCompatTextView { 18 | 19 | private boolean mTextMarquee; 20 | private float mStrokeWidth=0.6f; 21 | 22 | public BoldTextView(Context context) { 23 | this(context,null); 24 | } 25 | 26 | public BoldTextView(Context context, @Nullable AttributeSet attrs) { 27 | this(context, attrs,0); 28 | } 29 | 30 | public BoldTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 31 | super(context, attrs, defStyleAttr); 32 | if(null!=attrs){ 33 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.BoldTextView); 34 | mStrokeWidth = typedArray.getFloat(R.styleable.BoldTextView_boldStorkeWidth,mStrokeWidth); 35 | mTextMarquee = typedArray.getBoolean(R.styleable.BoldTextView_boldMarquee,false); 36 | typedArray.recycle(); 37 | } 38 | } 39 | 40 | @Override 41 | protected void onDraw(Canvas canvas) { 42 | //获取当前控件的画笔 43 | TextPaint paint = getPaint(); 44 | //设置画笔的描边宽度值 45 | paint.setStrokeWidth(mStrokeWidth); 46 | paint.setStyle(Paint.Style.FILL_AND_STROKE); 47 | super.onDraw(canvas); 48 | } 49 | 50 | /** 51 | * 设置描边宽度 52 | * @param strokeWidth 从0.0起 53 | */ 54 | public void setStrokeWidth(float strokeWidth){ 55 | this.mStrokeWidth=strokeWidth; 56 | invalidate(); 57 | } 58 | 59 | @Override 60 | public boolean isFocused() { 61 | return mTextMarquee; 62 | } 63 | } -------------------------------------------------------------------------------- /app-topon/src/main/java/com/platform/simple/LayoutProvider.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | import android.graphics.Outline; 4 | import android.os.Build; 5 | import android.view.View; 6 | import android.view.ViewOutlineProvider; 7 | 8 | import androidx.annotation.RequiresApi; 9 | 10 | /** 11 | * Created by TinyHung@outlook.com 12 | * 2022/10/11 13 | */ 14 | 15 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) 16 | public class LayoutProvider extends ViewOutlineProvider { 17 | 18 | private float mRadius; 19 | 20 | public LayoutProvider(float radius){ 21 | this.mRadius = radius; 22 | } 23 | 24 | @Override 25 | public void getOutline(View view, Outline outline) { 26 | outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mRadius); 27 | view.setClipToOutline(true); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app-topon/src/main/java/com/platform/simple/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.platform.simple; 2 | 3 | import android.os.Bundle; 4 | import android.widget.TextView; 5 | import androidx.appcompat.app.AppCompatActivity; 6 | import com.platform.lib.listener.OnSplashStatusListener; 7 | import com.platform.lib.widget.SplashView; 8 | 9 | /** 10 | * created by hty 11 | * 2022/10/8 12 | * Desc:开屏广告演示 13 | */ 14 | public class SplashActivity extends AppCompatActivity implements OnSplashStatusListener { 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_splash); 20 | //拉取开屏广告 21 | SplashView splashAdView = (SplashView) findViewById(R.id.ad_splash); 22 | splashAdView.loadSplashAd(AdConfig.AD_CODE_SPLASH_ID, this); 23 | } 24 | 25 | @Override 26 | public void onShow() { 27 | 28 | } 29 | 30 | @Override 31 | public void onClose() { 32 | close(); 33 | } 34 | 35 | @Override 36 | public void onClick() { 37 | 38 | } 39 | 40 | @Override 41 | public void onError(int code, String message, String adCode) { 42 | ((TextView) findViewById(R.id.tv_status)).setText(String.format("广告加载失败,code:%s,adCode:%s\nmessage:%s",code,adCode,message)); 43 | } 44 | 45 | /** 46 | * 跳转至首页 47 | */ 48 | private void close() { 49 | finish(); 50 | } 51 | } -------------------------------------------------------------------------------- /app-topon/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app-topon/src/main/res/drawable/bg_ad_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-topon/src/main/res/drawable/bg_tool_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-topon/src/main/res/drawable/coustom_native_bg_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-topon/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 12 | 16 | 17 | -------------------------------------------------------------------------------- /app-topon/src/main/res/layout/coustom_native_render.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 24 | 28 | 29 | 36 | 37 | 43 | 44 | 51 | 52 | 53 | 60 | 61 | 70 | 81 | 82 | 90 | 101 | 102 | -------------------------------------------------------------------------------- /app-topon/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-topon/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-topon/src/main/res/mipmap-xxhdpi/ic_ad_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/src/main/res/mipmap-xxhdpi/ic_ad_menu.png -------------------------------------------------------------------------------- /app-topon/src/main/res/raw/keep.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app-topon/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app-topon/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app-topon/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ToponSDK 3 | -------------------------------------------------------------------------------- /app-topon/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app-topon/src/main/res/xml/anythink_bk_gdt_file_path.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 14 | 17 | -------------------------------------------------------------------------------- /app-topon/src/main/res/xml/anythink_bk_tt_file_path.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app-topon/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app-topon/topon.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/app-topon/topon.keystore -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | apply from: "config.gradle" 3 | 4 | buildscript { 5 | repositories { 6 | google() 7 | mavenCentral() 8 | } 9 | dependencies { 10 | classpath "com.android.tools.build:gradle:4.0.1" 11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | mavenCentral() 21 | jcenter() // Warning: this repository is going to shut down soon 22 | maven { url 'https://jitpack.io' } 23 | 24 | //火山引擎maven仓库地址 25 | maven{url 'https://artifact.bytedance.com/repository/Volcengine/'} 26 | //穿山甲maven仓库地址 27 | maven{url 'https://artifact.bytedance.com/repository/pangle'} 28 | } 29 | } 30 | 31 | task clean(type: Delete) { 32 | delete rootProject.buildDir 33 | } -------------------------------------------------------------------------------- /config.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | android = [ 3 | compileSdkVersion: 28, 4 | buildToolsVersion: "28.0.3", 5 | minSdkVersion : 21, 6 | targetSdkVersion : 26, 7 | devMinSdk : 21, 8 | ] 9 | topon = [ 10 | applicationId: "com.anythink.sdk.demo", 11 | versionCode : 6, 12 | versionName : "1.1.6.1" 13 | ] 14 | gromore = [ 15 | applicationId: "com.distributor.never.thumb", 16 | versionCode : 6, 17 | versionName : "1.1.6.1" 18 | ] 19 | } -------------------------------------------------------------------------------- /doc/TopOn统一SDK.md: -------------------------------------------------------------------------------- 1 | ### 一、接入前的准备工作 2 | * 1、开发者须具备Android开发基础及AndroidStudio编辑器的使用基础能力 3 | * 2、到[TopOn后台][6]申请APP ID和广告位ID
4 | * 3、遇到问题请阅读[TopOn官方文档][1]
5 | * 4、更多原始广告平台支持请到[第三方广告SDK][2]下载
6 | * 5、配置、混淆、资源、权限等请参阅[官方文档][3]
7 | 8 | ### 二、AndroidStudio接入 9 | 10 | #### 一、环境配置 11 | ##### 1、项目根build.gradle配置 12 | ``` 13 | allprojects { 14 | repositories { 15 | maven { url 'https://jitpack.io' } 16 | } 17 | } 18 | ``` 19 | ##### 2、模块build.gradle配置 20 | ``` 21 | dependencies { 22 | 23 | //TopOn统一SDK 24 | implementation 'com.github.hty527.advert:topon:1.1.6.1' 25 | 26 | /** 27 | * 如果是Support环境 28 | */ 29 | //implementation "com.android.support:appcompat-v7:28.0.0" 30 | //implementation 'com.android.support:localbroadcastmanager:28.0.0' 31 | //dex 分包,当minSdkVersion>=21时会出现找不到androidx.multidex.MultiDexApplication 解决办法 32 | //implementation 'com.android.support:multidex:1.0.3' 33 | 34 | /** 35 | * 如果是androidx环境 36 | * 需在工程的gradle.properties文件增加下列配置: 37 | * android.useAndroidX=true 38 | * android.enableJetifier=true 39 | */ 40 | implementation 'androidx.appcompat:appcompat:1.0.2' 41 | implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0' 42 | //dex 分包,当minSdkVersion>=21时会出现找不到androidx.multidex.MultiDexApplication 解决办法 43 | implementation 'androidx.multidex:multidex:2.0.1' 44 | } 45 | ``` 46 | ##### 3、第三方聚合SDK及第三方广告SDK配置 47 | * 3.1、复制模块app-topon下libs_topon到你的项目模块根目录下
48 | * 3.2、复制模块app-topon下libs-adn到你的项目模块根目录下,可根据需要保留第三方聚合adapter和第三方广告SDK,更多广告SDK,请前往[官方下载][4]
49 | * 3.3、兼容Android10及以上设备建议集成模块app-topon下libs目录中的oaid_sdk_1.0.25.aar
50 | * 3.4、完成文件拷贝后在模块build.gradle配置中添加下列配置
51 | * 下列配置示例仅适配了穿山甲、快手、优量汇三家广告,其它广告配置请参阅[TopOn官方文档][1] 52 | ``` 53 | dependencies { 54 | //引入libs、libs_gromore、libs-adn目录下的所有.aar文件和.jar文件 55 | implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') 56 | implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs_topon') 57 | implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs-adn') 58 | 59 | /** 60 | * 如果集成了快手: 61 | */ 62 | //Support: 63 | //implementation "com.android.support:design:28.0.0" 64 | //AndroidX: 65 | implementation "androidx.recyclerview:recyclerview:1.2.0" 66 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 67 | } 68 | ``` 69 | 70 | ##### 4、权限 71 | * 请尽可能的申明下列权限,以免影响ECPM 72 | ``` 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | ``` 94 | #### 二、广告展示、拉取、缓存、混淆等请阅读[接入文档][5] 95 | 96 | [1]:https://docs.toponad.com/#/zh-cn/android/GetStarted/TopOn_Get_Started "TopOn官方文档" 97 | [2]:https://docs.toponad.com/#/zh-cn/android/download/package?_t=HcOmafjKlbJSNUyNLQu069135i0758v3 "第三方广告SDK" 98 | [3]:https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_config_cn_access "官方文档" 99 | [4]:https://docs.toponad.com/#/zh-cn/android/download/package?_t=HcOmafjKlbJSNUyNLQu069135i0758v3 "官方下载" 100 | [5]:https://github.com/hty527/advert/wiki/TopOn统一SDK接入文档 "接入文档" 101 | [6]:https://app.toponad.com/m/dashboard "TopOn后台" 102 | -------------------------------------------------------------------------------- /doc/版本更新.md: -------------------------------------------------------------------------------- 1 | #### 历史版本及第三方SDK对照表(请开发者严格按照SDK版本对接,避免不必要的问题出现!) 2 | 3 | ## 版本:1.1.6.1 4 | #### 更新内容 5 | * 更新日期: 2023-05-19
6 | * 描述信息:
7 | >1. 激励视频、插屏新增加载中回调
8 | >2. 优化TopOn常规激励视频插屏,支持内部自动缓存
9 | >3. 统一SDK新增状态控制
10 | #### SDK版本对照表 11 | | SDK及大小 | GroMore | TonOn | 12 | | --- | --- | --- | 13 | | 统一SDK | 1.1.6 | 1.1.6 | 14 | | 聚合SDK | 4.1.0.4 | 6.1.74 | 15 | | 穿山甲 | 5.1.0.2 | 5.2.0.5 | 16 | | 快手 | 3.3.40 | 3.3.42 | 17 | | 优量汇 | 4.514.1384 | 4.511.1381 | 18 | ___ 19 | ## 版本:1.1.5.4 20 | #### 更新内容 21 | * 更新日期: 2023-05-12
22 | * 描述信息:
23 | >1. 进一步统一API,支持自定义参数透传及回调
24 | >2. 更新并适配各平台广告SDK至最新版本
25 | >3. 激励视频播放结束新增是否有效验证
26 | >4. 修复激励视频手动加载自定义参数设定
27 | >5. 删除无用代码
28 | #### SDK版本对照表 29 | | SDK及大小 | GroMore | TonOn | 30 | | --- | --- | --- | 31 | | 统一SDK | 1.1.5.4 | 1.1.5.4 | 32 | | 聚合SDK | 4.1.0.4 | 6.1.74 | 33 | | 穿山甲 | 5.1.0.2 | 5.2.0.5 | 34 | | 快手 | 3.3.40 | 3.3.42 | 35 | | 优量汇 | 4.514.1384 | 4.511.1381 | 36 | ___ 37 | ## 版本:1.1.4.1 38 | #### 更新内容 39 | * 更新日期: 2023-02-20
40 | * 描述信息:
41 | >1. 更新并适配各平台广告SDK至最新版本
42 | >2. 取消激励视频广告平台Activity回调,1.1.4版本起由开发者自行处理
43 | #### SDK版本对照表 44 | | SDK及大小 | GroMore | TonOn | 45 | | --- | --- | --- | 46 | | 统一SDK | 1.1.4.1 | 1.1.4.1 | 47 | | 聚合SDK | 4.0.0.1 | 6.1.55 | 48 | | 穿山甲 | 5.1.0.2 | 5.0.0.4 | 49 | | 快手 | 3.3.38 | 3.3.38 | 50 | | 优量汇 | 4.510.1380 | 4.510.1380 | 51 | ___ 52 | 53 | ## 版本:1.1.3.1 54 | #### 更新内容 55 | * 更新日期: 2023-02-07
56 | * 描述信息:
57 | >1. 新增激励视频广告平台获取getAdnPlatformId(在show之后调用)和播放激励视频结束后广告平台回调
58 | #### SDK版本对照表 59 | | SDK及大小 | GroMore | TonOn | 60 | | --- | --- | --- | 61 | | 统一SDK | 1.1.3.1 | 1.1.3.1 | 62 | | 聚合SDK | 3.8.0.1 | 6.1.31 | 63 | | 穿山甲 | 4.8.0.8 | 4.8.0.8 | 64 | | 快手 | 3.3.31 | 3.3.32 | 65 | | 优量汇 | 4.491.1361 | 4.492.1362 | 66 | ___ 67 | 68 | ## 版本:1.1.3 69 | #### 更新内容 70 | * 更新日期: 2023-02-01
71 | * 描述信息:
72 | >1. 修复topon信息流回调BUG
73 | #### SDK版本对照表 74 | | SDK及大小 | GroMore | TonOn | 75 | | --- | --- | --- | 76 | | 统一SDK | 1.1.3 | 1.1.3 | 77 | | 聚合SDK | 3.8.0.1 | 6.1.31 | 78 | | 穿山甲 | 4.8.0.8 | 4.8.0.8 | 79 | | 快手 | 3.3.31 | 3.3.32 | 80 | | 优量汇 | 4.491.1361 | 4.492.1362 | 81 | ___ 82 | 83 | ## 版本:1.1.2 84 | #### 更新内容 85 | * 更新日期: 2022-11-17
86 | * 描述信息:
87 | >1. 更新GroMore SDK至最新版2022-11-16:v3.8.0.1,
88 | >2. 更新TopOn SDK至最新版2022-10-14:v6.1.31,
89 | >3. TopOn SDK初始化新增广告平台初始化配置
90 | #### SDK版本对照表 91 | | SDK及大小 | GroMore | TonOn | 92 | | --- | --- | --- | 93 | | 统一SDK | 1.1.2 | 1.1.2 | 94 | | 聚合SDK | 3.8.0.1 | 6.1.31 | 95 | | 穿山甲 | 4.8.0.8 | 4.8.0.8 | 96 | | 快手 | 3.3.31 | 3.3.32 | 97 | | 优量汇 | 4.491.1361 | 4.492.1362 | 98 | ___ 99 | 100 | ## 版本:1.1.0 101 | #### 更新内容 102 | * 更新日期: 2022-11-9
103 | * 描述信息:
104 | >1. 优化部分api
105 | #### SDK版本对照表 106 | | SDK及大小 | GroMore | TonOn | 107 | | --- | --- | --- | 108 | | 统一SDK | 1.1.1 | 1.1.1 | 109 | | 穿山甲 | 4.8.0.8 | 4.7.1.2 | 110 | | 快手 | 3.3.31 | 3.3.28 | 111 | | 优量汇 | 4.491.1361 | 4.482.1352 | 112 | ___ 113 | 114 | ### 1.0.6 115 | **更新日期:** 2022-11-2
116 | **更新内容:**
117 | >1. 去除平台限制
118 | ___ 119 | ### 1.0.5 120 | **更新日期:** 2022-10-20
121 | **更新内容:**
122 | >1. 插屏、激励视频全自动模式BUG
123 | ___- 124 | ### 1.0.4 125 | **更新日期:** 2022-10-19
126 | **更新内容:**
127 | >1. 新增开发者跳过广告(激励视频、插屏)模式设置
128 | ___ 129 | ### 1.0.3 130 | **更新日期:** 2022-10-13
131 | **更新内容:**
132 | >1. Demo新增自定义信息流渲染UI
133 | >2. 优化SDK部分接口
134 | ___ 135 | ### 1.0.2 136 | **更新日期:** 2022-10-12
137 | **更新内容:**
138 | >1. 重新对接topon最新文档,版本:5.9.98
139 | >2. 自渲染信息流广告支持自定义UI
140 | ___ 141 | ### 1.0.1 142 | **更新日期:** 2022-10-11
143 | **更新内容:**
144 | >1. 新增原生信息流自渲染
145 | ___ 146 | ### 1.0.0 147 | **更新日期:** 2022-10-10
148 | **更新内容:**
149 | >1. 纪念辛亥革命111周年,向革命先驱们致以崇高的敬意!
150 | >2. 基于Topon平台二次封装的广告播放能力SDK重磅发布
151 | >3. topon版本:5.9.98,穿山甲版本:4.7.1.2,快手版本:3.3.28,优量汇版本:4.482.1352
152 | ___ -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | android.enableJetifier=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Sep 16 15:07:58 CST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /gromore/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /gromore/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group='com.github.hty527'//xxx:代表你的github用户名 5 | 6 | android { 7 | compileSdkVersion 29 8 | buildToolsVersion '29.0.3' 9 | 10 | defaultConfig { 11 | minSdkVersion 17 12 | targetSdkVersion 29 13 | versionCode rootProject.ext.gromore.versionCode 14 | versionName rootProject.ext.gromore.versionName 15 | } 16 | 17 | buildTypes { 18 | debug { 19 | debuggable true 20 | zipAlignEnabled false 21 | minifyEnabled false 22 | signingConfig signingConfigs.debug 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | } 25 | release { 26 | debuggable false 27 | zipAlignEnabled true 28 | minifyEnabled true 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | signingConfig signingConfigs.debug 31 | } 32 | } 33 | 34 | lintOptions { 35 | abortOnError false 36 | } 37 | 38 | compileOptions { 39 | sourceCompatibility JavaVersion.VERSION_1_8 40 | targetCompatibility JavaVersion.VERSION_1_8 41 | } 42 | } 43 | 44 | dependencies { 45 | //当library和主模块同时引用第三方aar文件时,library模块需要使用compileOnly关键字来引用aar 46 | compileOnly fileTree(include: ['*.jar', '*.aar'], dir: 'libs_gromore') 47 | } -------------------------------------------------------------------------------- /gromore/libs_gromore/mediation_ad_sdk_4.1.0.4.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/gromore/libs_gromore/mediation_ad_sdk_4.1.0.4.aar -------------------------------------------------------------------------------- /gromore/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | 2 | -optimizationpasses 5 3 | -useuniqueclassmembernames 4 | #优化时允许访问并修改有修饰符的类和类的成员 5 | -allowaccessmodification 6 | #混淆时是否记录日志 7 | -verbose 8 | #忽略警告 9 | -ignorewarnings 10 | # 混淆时所采用的算法 11 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 12 | #-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*,!code/allocation/variable 13 | -keepattributes EnclosingMethod 14 | -dontoptimize 15 | # 混淆时不使用大小写混合,混淆后的类名为小写 16 | # windows下的同学还是加入这个选项吧(windows大小写不敏感) 17 | -dontusemixedcaseclassnames 18 | # 指定不去忽略非公共的库的类 19 | # 默认跳过,有些情况下编写的代码与类库中的类在同一个包下,并且持有包中内容的引用,此时就需要加入此条声明 20 | -dontskipnonpubliclibraryclasses 21 | # 指定不去忽略非公共的库的类的成员 22 | -dontskipnonpubliclibraryclassmembers 23 | # 不做预检验,preverify是proguard的四个步骤之一 24 | # Android不需要preverify,去掉这一步可以加快混淆速度 25 | -dontpreverify 26 | # 有了verbose这句话,混淆后就会生成映射文件 27 | # 包含有类名->混淆后类名的映射关系 28 | # 然后使用printmapping指定映射文件的名称 29 | #-verbose 30 | 31 | #保持自定义控件类不被混淆 32 | -keepclasseswithmembers class * { 33 | public (android.content.Context, android.util.AttributeSet); 34 | } 35 | #保持自定义控件类不被混淆 36 | -keepclasseswithmembers class * { 37 | public (android.content.Context); 38 | public (android.content.Context, android.util.AttributeSet); 39 | public (android.content.Context, android.util.AttributeSet, int); 40 | } 41 | -keep public class * extends android.app.Activity{ 42 | public ; 43 | public ; 44 | } 45 | -keep public class * extends android.app.Application{ 46 | public ; 47 | public ; 48 | } 49 | 50 | #SDK所有R文件不参与混淆 51 | -keep public class com.platform.lib.R$*{ 52 | public static final int *; 53 | } 54 | 55 | #保留出口及出口内的部分方法不被混淆 56 | #保留AdvertManager类的所有公开方法这个 57 | #-keep class com.topon.advert.manager.AdvertManager {*;} 58 | -keep class com.platform.lib.manager.PlatformManager { 59 | public *; 60 | } 61 | -keep class com.platform.lib.manager.TableScreenManager { 62 | public *; 63 | } 64 | -keep class com.platform.lib.manager.PlayManager { 65 | public *; 66 | } 67 | -keep class com.platform.lib.constants.AdConstance {*;} 68 | -keep class com.platform.lib.bean.Result { 69 | public *; 70 | } 71 | #-keep class com.platform.lib.utils.Logger { 72 | # public *; 73 | #} 74 | -keep class com.platform.lib.listener.** {*;} 75 | #GroMore保持竞价逻辑不被混淆 76 | -keep class com.platform.simple.adn.** {*;} 77 | #保留ExpressView类的requst及destroy方法 78 | -keep class com.platform.lib.widget.ExpressView { 79 | public void requst(); 80 | public void onResume(); 81 | public void onPause(); 82 | public void destroy(); 83 | public void addErrorView(int, java.lang.String, java.lang.String); 84 | } 85 | -keep class com.platform.lib.widget.SplashView { 86 | public *; 87 | } 88 | #将所有混淆的类放到指定目录下 89 | -repackageclasses com.platform.core 90 | -------------------------------------------------------------------------------- /gromore/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/bean/Result.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.bean; 2 | 3 | import android.text.TextUtils; 4 | 5 | /** 6 | * created by hty 7 | * 2022/10/8 8 | * Desc:广告播放完成的状态及信息 9 | */ 10 | public class Result { 11 | 12 | private String adCode;//广告位ID 13 | private String isClick;//是否点击了广告,1:点击了广告,0:未点击广告 14 | private boolean rewardVerify;//是否是一个有效的播放 15 | private String cpmInfo;//广告的ecpm 16 | private int platformId;//广告的实际平台标识,详见GMNetworkPlatformConst类 17 | private String customData;//启用服务端验证下发奖励时的用户自定义数据 18 | 19 | public String getAdCode() { 20 | return adCode; 21 | } 22 | 23 | public void setAdCode(String adCode) { 24 | this.adCode = adCode; 25 | } 26 | 27 | public String getIsClick() { 28 | return isClick; 29 | } 30 | 31 | public void setIsClick(String isClick) { 32 | this.isClick = isClick; 33 | } 34 | 35 | public boolean isRewardVerify() { 36 | return rewardVerify; 37 | } 38 | 39 | public void setRewardVerify(boolean rewardVerify) { 40 | this.rewardVerify = rewardVerify; 41 | } 42 | 43 | public String getCpmInfo() { 44 | if(TextUtils.isEmpty(cpmInfo)) cpmInfo ="0"; 45 | return cpmInfo; 46 | } 47 | 48 | public void setCpmInfo(String cpmInfo) { 49 | this.cpmInfo = cpmInfo; 50 | } 51 | 52 | public int getPlatformId() { 53 | return platformId; 54 | } 55 | 56 | public void setPlatformId(int platformId) { 57 | this.platformId = platformId; 58 | } 59 | 60 | public String getCustomData() { 61 | return customData; 62 | } 63 | 64 | public void setCustomData(String customData) { 65 | this.customData = customData; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return "Result{" + 71 | "adCode='" + adCode + '\'' + 72 | ", isClick='" + isClick + '\'' + 73 | ", rewardVerify='" + rewardVerify + '\'' + 74 | ", cpmInfo='" + cpmInfo + '\'' + 75 | ", platformId=" + platformId + 76 | ", customData='" + customData + '\'' + 77 | '}'; 78 | } 79 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/constants/AdConstance.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.constants; 2 | 3 | /** 4 | * created by hty 5 | * 2022/3/24 * 2022/11/8 * Desc: 6 | */ 7 | public interface AdConstance { 8 | 9 | /** 10 | * 广告平台 11 | */ 12 | 13 | String SOURCE_TT = "1";//穿山甲 14 | String SOURCE_TX = "3";//优量汇 15 | String SOURCE_KS = "5";//快手 16 | String SOURCE_TO = "8";//GroMore聚合平台 17 | 18 | /** 19 | * 广告位类型 20 | */ 21 | String TYPE_STREAM = "1";//信息流 22 | String TYPE_INSERT = "2";//插屏广告 23 | String TYPE_BANNER = "3";//Banner 24 | String TYPE_REWARD_VIDEO = "4";//激励视频 25 | String TYPE_FULL_VIDEO = "5";//全屏视频 26 | String TYPE_SPLASH = "6";//开屏广告 27 | 28 | /** 29 | * 广告状态 30 | */ 31 | String STATUS_LOADED_SUCCESS = "1";//加载成功 32 | String STATUS_LOADED_ERROR = "2";//加载失败 33 | String STATUS_SHOW_SUCCESS = "3";//显示成功 34 | String STATUS_SHOW_ERROR = "4";//显示失败 35 | 36 | /** 37 | * 错误码 38 | */ 39 | int CODE_CONTEXT_INVALID = 1; //上下文无效 40 | int CODE_ACTIVITY_INVALID = 2; //Activity无效或已被关闭 41 | int CODE_VIEWGROUP_INVALID = 3; //ViewGroup容器无效 42 | int CODE_APPID_INVALID = 4; //app_id无效 43 | int CODE_APPSECRECY_INVALID = 5; //app_secrecy无效 44 | int CODE_ID_UNKNOWN = 6;//未知的广告位 45 | int CODE_ID_INVALID = 7;//无效的广告位ID 46 | int CODE_TYPE_INVALID = 8;//无效的广告位类型 47 | int CODE_TIMOUT = 9;//超时 48 | int CODE_ADINFO_INVALID = 10;//广告对象无效 49 | int CODE_REPEATED = 11;//正在显示中 50 | int CODE_AD_EMPTY = 12;//暂无广告填充 51 | int CODE_AD_LOADING = 13;//广告正在请求中 52 | int CODE_EXIST_CACHE = 14;//存在缓存广告 53 | int CODE_APPLY_FAIL = 15;//广告应用到布局失败 54 | int CODE_DEVELOP = 16;//开发者模式,跳过广告 55 | int CODE_CONFIG_LOADING = 17;//广告配置正在加载中 56 | int CODE_AD_DISABLED = 18;//广告不可用 57 | 58 | /** 59 | * 错误描述信息 60 | */ 61 | String ERROR_CONTEXT_INVALID = "context invalid"; //上下文无效 62 | String ERROR_ACTIVITY_INVALID = "activity invalid"; //Activity无效或已被关闭 63 | String ERROR_VIEWGROUP_INVALID = "viewgroup invalid";//ViewGroup容器无效 64 | String ERROR_APPID_INVALID = "app_id invalid"; //app_id无效 65 | String ERROR_APPSECRECY_INVALID = "app_secrecy invalid"; //app_secrecy无效 66 | String ERROR_ID_UNKNOWN = "id unknown";//未知的广告位 67 | String ERROR_ID_INVALID = "id is invalid";//无效的广告位ID 68 | String ERROR_TYPE_INVALID = "type is invalid";//无效的广告位类型 69 | String ERROR_TIMOUT = "timeout";//超时 70 | String ERROR_ADINFO_INVALID = "ad invalid";//广告对象无效 71 | String ERROR_REPEATED = "is showing";//正在显示中 72 | String ERROR_AD_EMPTY = "ad is empty";//暂无广告填充 73 | String ERROR_AD_LOADING = "please wait...";//广告正在请求中 74 | String ERROR_EXIST_CACHE = "exist_cache";//存在缓存广告 75 | String ERROR_APPLY_FAIL = "express apply fail";//广告应用到布局失败 76 | String ERROR_DEVELOP = "develop mode,skip";//开发者模式,跳过广告 77 | String ERROR_CONFIG_LOADING = "config loading";//广告配置正在加载中 78 | String ERROR_AD_DISABLED = "ad disabled";//广告不可用 79 | 80 | int LOAD_ERROR = 40000; 81 | int AD_ERROR = 40001; 82 | int VIDEO_ERROR = 40002; 83 | int RENDER_FAIL = 40003; 84 | 85 | /** 86 | * 加载广告场景 87 | */ 88 | String SCENE_CACHE = "-1";//默认是缓存广告 89 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/listener/BaseListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | /** 4 | * created by hty 5 | * 2022/11/8 6 | * Desc:监听器基类 7 | */ 8 | public interface BaseListener { 9 | 10 | /** 11 | * 广告被显示了 12 | */ 13 | void onShow(); 14 | 15 | /** 16 | * 广告被点击了 17 | */ 18 | void onClick(); 19 | 20 | /** 21 | * 广告被关闭了 22 | */ 23 | void onClose(); 24 | 25 | /** 26 | * 广告拉取/播放错误 27 | * @param code 错误码,参考:AdConstance 和 https://www.csjplatform.com/union/media/union/download/detail?id=106&docId=62e23367a0556d002fd3caa6&osType=android 28 | * @param message 错误信息 29 | * @param adCode 广告位ID 30 | */ 31 | void onError(int code, String message, String adCode); 32 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/listener/NativeRenderControl.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import com.bytedance.msdk.api.v2.ad.nativeAd.GMNativeAd; 6 | 7 | /** 8 | * created by hty 9 | * 2022/11/8 10 | * Desc:原生自渲染信息流广告填充器 11 | */ 12 | public interface NativeRenderControl { 13 | 14 | /** 15 | * 创建自定义UI组件 16 | * @param context 广告ExpressView上下文。返回一个有效的自定义ViewGroup,SDK内部会添加到容器中 17 | * @return 18 | */ 19 | V getRenderView(Context context); 20 | 21 | /** 22 | * 将广告信息绑定到自定义UI组件上,并且将各子自定义ViewGroup(比如点击按钮、icon组件)绑定到native广告上 23 | * @param selfRenderView 将广告信息绑定到自定义UI组件上,并且将各子自定义ViewGroup(比如点击按钮、icon组件)绑定到native广告上,selfRenderView:自定义渲染UI组件 24 | * @param nativeAd 原生广告信息 25 | * @param adWidth 期望渲染的广告宽度,高度SDK自适应,会通过OnExpressAdListener回调通知实际渲染的高度 26 | */ 27 | void onRenderNativeView(V selfRenderView, GMNativeAd nativeAd,float adWidth); 28 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/listener/OnEventListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * created by hty 7 | * 2022/11/8 8 | * Desc:广告各状态全局状态监听 9 | */ 10 | public interface OnEventListener { 11 | 12 | /** 13 | * 广告的缓存、展示功能是否可用 14 | * @return 广告的缓存、展示功能是否可用,true:可用,false:被禁用 15 | */ 16 | boolean isAvailable(); 17 | 18 | /** 19 | * 根据错误码返回文字文案 20 | * @param code 错误码参考AdConstance定义的"错误码" 21 | * @return 如果返回的文字为空,则使用SDK内部默认文案 22 | */ 23 | String getText(int code); 24 | 25 | /** 26 | * 自定义透传的数据 27 | * @return 自定义透传的数据,开启服务端验证的激励视频代码位传入。SDK将回传给给代码位指定的回调地址 28 | * 参考:https://www.csjplatform.com/supportcenter/26240 29 | */ 30 | Map localExtra(); 31 | 32 | /** 33 | * 广告事件回调 34 | * @param scene 播放广告的场景 35 | * @param ad_type 广告类型,Constance申明 36 | * @param ad_code 广告位ID 37 | * @param ad_status 广告状态:1:加载成功 2:加载失败 3:显示成功 4:显示失败 38 | * @param error_code 错误码 39 | * @param error_msg 全量的错误信息 40 | */ 41 | void onEvent(String scene, String ad_type, String ad_code, String ad_status, int error_code, String error_msg); 42 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/listener/OnExpressAdListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | /** 4 | * created by hty 5 | * 2022/11/8 6 | * Desc:信息流\Banner渲染状态监听 7 | */ 8 | public interface OnExpressAdListener { 9 | 10 | /** 11 | * 广告加载成功了 12 | */ 13 | void onSuccess(); 14 | 15 | /** 16 | * 广告被显示了 17 | */ 18 | void onShow(); 19 | 20 | /** 21 | * 广告被点击了 22 | */ 23 | void onClick(); 24 | 25 | /** 26 | * 广告成功渲染后的高度,单位:像素。仅Banner和信息流回调 27 | * @param adViewHeight 28 | */ 29 | void onAdViewHeight(int adViewWidth,int adViewHeight); 30 | 31 | /** 32 | * 广告被移除了 33 | */ 34 | void onClose(); 35 | 36 | /** 37 | * 播放失败 38 | * @param code 错误码 39 | * @param message 描述信息 40 | * @param adCode 广告位ID 41 | */ 42 | void onError(int code, String message, String adCode); 43 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/listener/OnExpressListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import com.bytedance.msdk.api.v2.ad.banner.GMBannerAd; 4 | import com.bytedance.msdk.api.v2.ad.nativeAd.GMNativeAd; 5 | 6 | /** 7 | * created by hty 8 | * 2022/11/8 9 | * Desc:信息流、Banner 10 | */ 11 | public interface OnExpressListener extends BaseListener { 12 | 13 | /** 14 | * 信息流广告加载成功 15 | * @param gmNativeAd 16 | */ 17 | void onSuccessExpressed(GMNativeAd gmNativeAd); 18 | 19 | /** 20 | * banner广告加载成功 21 | * @param gmBannerAd 22 | */ 23 | void onSuccessBanner(GMBannerAd gmBannerAd); 24 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/listener/OnInitListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import com.bytedance.msdk.api.v2.GMAdConfig; 4 | import com.platform.lib.manager.PlatformManager; 5 | 6 | /** 7 | * created by hty 8 | * 2022/11/8 9 | * Desc:初始化状态 10 | */ 11 | public abstract class OnInitListener { 12 | 13 | /** 14 | * 构建初始化配置,开发者可重写此配置,自定义自己的配置 15 | * @param appId 应用ID,在gromore后台获取 16 | * @param appName 应用名称 17 | * @param channel 渠道名称 18 | * @param debug 是否开启调试模式,true:开启调试模式,false:关闭调试模式 19 | * @return 20 | */ 21 | public GMAdConfig getSdkConfig(String appId, String appName, String channel, boolean debug) { 22 | return PlatformManager.getInstance().buildGroMoreConfig(appId,appName,channel,debug); 23 | } 24 | 25 | /** 26 | * 初始化成功 27 | * @param appId 应用ID,在gromore后台获取 28 | */ 29 | public void onSuccess(String appId){} 30 | 31 | /** 32 | * 初始化失败 33 | * @param code 错误码,参考Constance类 34 | * @param message 描述信息 35 | */ 36 | public void onError(int code,String message){} 37 | 38 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/listener/OnPlayListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import android.app.Activity; 4 | import com.bytedance.msdk.api.v2.ad.reward.GMRewardAd; 5 | import com.platform.lib.bean.Result; 6 | 7 | /** 8 | * created by hty 9 | * 2022/11/8 10 | * Desc:激励视频\开屏播放监听器 11 | */ 12 | public abstract class OnPlayListener { 13 | 14 | /** 15 | * 广告加载成功了(播放激励视频时回调) 16 | * @param gmRewardAd 仅激励视频并且非全自动时此对象可能不为空 17 | */ 18 | public void onSuccess(GMRewardAd gmRewardAd){} 19 | 20 | /** 21 | * 第三方广告Activity被创建了 22 | * @param activity 23 | */ 24 | public void onAdvertActivityCreated(Activity activity){} 25 | 26 | /** 27 | * 广告被显示了 28 | */ 29 | public void onShow(){} 30 | 31 | /** 32 | * 广告被点击了(播放开屏广告时回调) 33 | */ 34 | public void onClick(){} 35 | 36 | 37 | /** 38 | * 广告被点击了(播放激励视频时回调) 39 | * @param rewardAd 广告信息 40 | */ 41 | public void onClick(GMRewardAd rewardAd){} 42 | 43 | /** 44 | * 广告播放合法有效 45 | */ 46 | public void onRewardVerify(){} 47 | 48 | /** 49 | * 播放失败 50 | * @param code 错误码 51 | * @param message 描述信息 52 | * @param adCode 广告位ID 53 | */ 54 | public void onError(int code, String message, String adCode){} 55 | 56 | /** 57 | * 当播放激励视频时,无论何种原因,广告播放关闭了,此方法会回调。其它广告类型仅在广告正常关闭时回调 58 | * @param result 播放状态,当有效播放或开发者模式时不为空,其他状态为null,请注意! 59 | */ 60 | public abstract void onClose(Result result); 61 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/listener/OnRewardVideoListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import com.bytedance.msdk.api.v2.ad.reward.GMRewardAd; 4 | 5 | /** 6 | * created by hty 7 | * 2022/11/8 8 | * Desc:激励视频 9 | */ 10 | public interface OnRewardVideoListener { 11 | 12 | /** 13 | * 广告正在加载中 14 | */ 15 | void onLoading(); 16 | 17 | /** 18 | * 加载视频广告成功 19 | * @param gmRewardAd 20 | */ 21 | void onSuccess(GMRewardAd gmRewardAd); 22 | /** 23 | * 广告被显示了 24 | */ 25 | void onShow(); 26 | 27 | /** 28 | * 广告被点击了 29 | */ 30 | void onClick(GMRewardAd rewardAd); 31 | 32 | /** 33 | * 该视频广告的有效性校验 34 | */ 35 | void onRewardVerify(); 36 | 37 | 38 | /** 39 | * 广告被关闭了 40 | * @param cpmInfo cpm/cpm精度/展示单价等json字段,例如格式:{"price":"20.28470431","precision":"exact","pre_price":"0.02028470431"} 41 | * @param customData 自定义透传参数 42 | */ 43 | void onClose(String cpmInfo,String customData); 44 | 45 | /** 46 | * 广告拉取/播放错误 47 | * @param code 错误码,参考:AdConstance 和 https://www.csjplatform.com/union/media/union/download/detail?id=106&docId=62e23367a0556d002fd3caa6&osType=android 48 | * @param message 错误信息 49 | * @param adCode 广告位ID 50 | */ 51 | void onError(int code, String message, String adCode); 52 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/listener/OnSplashListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import com.bytedance.msdk.api.v2.ad.splash.GMSplashAd; 4 | 5 | /** 6 | * created by hty 7 | * 2022/11/8 8 | * Desc:开屏 9 | */ 10 | public interface OnSplashListener extends BaseListener { 11 | 12 | /** 13 | * 加载开屏广告成功了 14 | * @param gmSplashAd 15 | */ 16 | void onSuccess(GMSplashAd gmSplashAd); 17 | 18 | /** 19 | * 广告加载超时了 20 | */ 21 | void onTimeOut(); 22 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/listener/OnSplashStatusListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | /** 4 | * created by hty 5 | * 2022/11/8 6 | * Desc:开屏 7 | */ 8 | public interface OnSplashStatusListener extends BaseListener {} -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/listener/OnTabScreenListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import com.bytedance.msdk.api.v2.ad.interstitialFull.GMInterstitialFullAd; 4 | 5 | /** 6 | * created by hty 7 | * 2022/11/8 8 | * Desc:插屏 9 | */ 10 | public interface OnTabScreenListener extends BaseListener { 11 | 12 | /** 13 | * 插屏广告加载中 14 | */ 15 | void onLoading(); 16 | 17 | /** 18 | * 加载插屏广告成功了 19 | * @param interactionAd 20 | */ 21 | void onSuccess(GMInterstitialFullAd interactionAd); 22 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/manager/PlayManager.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.manager; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import com.bytedance.msdk.api.v2.ad.reward.GMRewardAd; 7 | import com.platform.lib.bean.Result; 8 | import com.platform.lib.constants.AdConstance; 9 | import com.platform.lib.listener.OnPlayListener; 10 | import com.platform.lib.utils.PlatformUtils; 11 | import com.platform.lib.widget.RewardActivity; 12 | 13 | /** 14 | * created by hty 15 | * 2022/3/25 16 | * Desc:激励视频广告播放管理者容器 17 | * 18 | * 1、显示激励视频:{@link #startVideo(String ad_code, OnPlayListener listener)} 19 | */ 20 | public final class PlayManager extends OnPlayListener { 21 | 22 | private volatile static PlayManager mInstance; 23 | private OnPlayListener mListener; 24 | private boolean isShowing;//是否正在播放中 25 | 26 | public static PlayManager getInstance() { 27 | if(null==mInstance){ 28 | synchronized (PlayManager.class) { 29 | if (null == mInstance) { 30 | mInstance = new PlayManager(); 31 | } 32 | } 33 | } 34 | return mInstance; 35 | } 36 | 37 | public boolean isShowing() { 38 | return isShowing; 39 | } 40 | 41 | public void setShowing(boolean showing) { 42 | isShowing = showing; 43 | } 44 | 45 | public void setAdPlayerListener(OnPlayListener listener) { 46 | mListener = listener; 47 | } 48 | 49 | /** 50 | * 开始播放激励视屏 51 | * @param ad_code 广告位ID 52 | */ 53 | public void startVideo(String ad_code){ 54 | startVideo(ad_code, AdConstance.SCENE_CACHE); 55 | } 56 | 57 | /** 58 | * 开始播放激励视屏 59 | * @param ad_code 广告位ID 60 | * @param scene 播放场景 61 | */ 62 | public void startVideo(String ad_code, String scene){ 63 | startVideo(ad_code,scene,null); 64 | } 65 | 66 | /** 67 | * 开始播放激励视屏 68 | * @param ad_code 广告位ID 69 | * @param listener 状态监听器 70 | */ 71 | public void startVideo(String ad_code, OnPlayListener listener){ 72 | startVideo(ad_code,AdConstance.SCENE_CACHE,listener); 73 | } 74 | 75 | /** 76 | * 开始播放激励视屏 77 | * @param ad_code 广告位ID 78 | * @param scene 播放场景 79 | * @param listener 状态监听器 80 | */ 81 | public void startVideo(String ad_code, String scene,OnPlayListener listener){ 82 | this.mListener=listener; 83 | Context context = PlatformUtils.getInstance().getContext(); 84 | Intent intent=new Intent(context, RewardActivity.class); 85 | intent.putExtra("id",ad_code); 86 | intent.putExtra("scene",scene); 87 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 88 | context.startActivity(intent); 89 | } 90 | 91 | @Override 92 | public void onSuccess(GMRewardAd atRewardVideoAd) { 93 | if(null!=mListener) mListener.onSuccess(atRewardVideoAd); 94 | } 95 | 96 | @Override 97 | public void onAdvertActivityCreated(Activity activity) { 98 | if(null!=mListener) mListener.onAdvertActivityCreated(activity); 99 | } 100 | 101 | @Override 102 | public void onShow() { 103 | if(null!=mListener) mListener.onShow(); 104 | } 105 | 106 | @Override 107 | public void onClick() { 108 | if(null!=mListener) mListener.onClick();//为满足不同需求的开发者 109 | } 110 | 111 | @Override 112 | public void onClick(GMRewardAd rewardAd) { 113 | onClick(); 114 | if(null!=mListener) mListener.onClick(rewardAd); 115 | } 116 | 117 | @Override 118 | public void onRewardVerify() { 119 | if(null!=mListener) mListener.onRewardVerify(); 120 | } 121 | 122 | @Override 123 | public void onError(int code, String message, String adCode) { 124 | if(null!=mListener) mListener.onError(code,message,adCode); 125 | } 126 | 127 | @Override 128 | public void onClose(Result result) { 129 | OnPlayListener playerListener=mListener; 130 | mListener=null; 131 | if(null!=playerListener) playerListener.onClose(result); 132 | } 133 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/utils/ImageLoader.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.utils; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.BitmapFactory; 5 | import android.graphics.drawable.Drawable; 6 | import android.os.AsyncTask; 7 | import android.text.TextUtils; 8 | import android.widget.ImageView; 9 | import java.io.InputStream; 10 | import java.net.HttpURLConnection; 11 | import java.net.URL; 12 | 13 | /** 14 | * created by hty 15 | * 2022/11/9 16 | * Desc:图片下载+渲染 17 | */ 18 | public class ImageLoader extends AsyncTask { 19 | 20 | private String mUrl; 21 | private ImageView mTargetImage; 22 | private int loadPlaceholder,errorPlaceholder; 23 | 24 | public void setLoadPlaceholder(int loadPlaceholder) { 25 | this.loadPlaceholder = loadPlaceholder; 26 | } 27 | 28 | public void setErrorPlaceholder(int errorPlaceholder) { 29 | this.errorPlaceholder = errorPlaceholder; 30 | } 31 | 32 | public void displayImage(ImageView imageView, Object url) { 33 | if(null==imageView) return; 34 | if(null==url) return; 35 | if(url instanceof Integer){ 36 | imageView.setImageResource((Integer) url); 37 | return; 38 | } 39 | if(url instanceof String){ 40 | this.mTargetImage =imageView; 41 | this.mUrl= (String) url; 42 | } 43 | execute(); 44 | } 45 | 46 | @Override 47 | protected void onPreExecute() { 48 | super.onPreExecute(); 49 | // MideaUtils.getInstance().log(TAG,"onPreExecute-->"); 50 | if(null!= mTargetImage &&loadPlaceholder>0){ 51 | mTargetImage.setImageResource(loadPlaceholder); 52 | } 53 | } 54 | 55 | @Override 56 | protected Object doInBackground(Object... objects) { 57 | if(TextUtils.isEmpty(mUrl)){ 58 | return null; 59 | } 60 | try { 61 | URL url = new URL(mUrl); 62 | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 63 | connection.setDoInput(true);//使用URL进行输入 64 | connection.setUseCaches(false);//忽略缓存 65 | connection.setConnectTimeout(10000); 66 | connection.setReadTimeout(10000); 67 | connection.connect();//开始链接 68 | //获取文件总长度 69 | int contentLength = connection.getContentLength(); 70 | int responseCode = connection.getResponseCode(); 71 | if(responseCode == HttpURLConnection.HTTP_OK&&contentLength>0){ 72 | InputStream inputStream= connection.getInputStream(); 73 | if(null!=inputStream){ 74 | BitmapFactory.Options options = new BitmapFactory.Options(); 75 | options.inPreferredConfig = Bitmap.Config.RGB_565;//Bitmap压缩 76 | Bitmap bitmap = BitmapFactory.decodeStream(inputStream,null,options); 77 | return bitmap; 78 | } 79 | } 80 | } catch (Throwable e) { 81 | 82 | } 83 | return null; 84 | } 85 | 86 | @Override 87 | protected void onPostExecute(Object bitmap) { 88 | super.onPostExecute(bitmap); 89 | if(null!= mTargetImage){ 90 | if(null!=bitmap){ 91 | if(bitmap instanceof Bitmap){ 92 | mTargetImage.setImageBitmap((Bitmap) bitmap); 93 | }else if(bitmap instanceof Drawable){ 94 | mTargetImage.setImageDrawable((Drawable) bitmap); 95 | }else{ 96 | if(errorPlaceholder>0) mTargetImage.setImageResource(errorPlaceholder); 97 | } 98 | //bitmap.recycle(); 99 | }else{ 100 | if(errorPlaceholder>0) mTargetImage.setImageResource(errorPlaceholder); 101 | } 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/utils/InitHelper.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.utils; 2 | 3 | import android.text.TextUtils; 4 | 5 | /** 6 | * created by hty 7 | * 2022/11/17 8 | * Desc:初始化帮助类 9 | */ 10 | public class InitHelper { 11 | 12 | public static void init(String target){ 13 | try { 14 | if(!TextUtils.isEmpty(target)&&PlatformUtils.getInstance().checkedPreferencesExist()){ 15 | 16 | } 17 | }catch (Throwable e){} 18 | } 19 | 20 | public static void unInit(){ 21 | try { 22 | if(PlatformUtils.getInstance().checkedPreferencesExist()){ 23 | 24 | } 25 | }catch (Throwable e){} 26 | } 27 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/utils/Logger.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.utils; 2 | 3 | import android.util.Log; 4 | 5 | /** 6 | * created by hty 7 | * 2022/3/24 8 | * Desc: 9 | */ 10 | public class Logger { 11 | 12 | private static boolean sDebug = true; 13 | 14 | public static final String TAG="PlatformSDK"; 15 | 16 | /** 17 | * 日志级别 18 | */ 19 | public static final int DEBUG = 0; 20 | public static final int INFO = 1; 21 | public static final int ASSERT = 2; 22 | public static final int VERBOSE = 3; 23 | public static final int WARN = 4; 24 | public static final int ERROR = 5; 25 | 26 | public static void setDebug(boolean debug) { 27 | Logger.sDebug = debug; 28 | } 29 | 30 | public static void d(String msg) { 31 | d(TAG,msg); 32 | } 33 | 34 | public static void d(String tag,String msg) { 35 | if (!sDebug) return; 36 | Log.d(tag, msg); 37 | } 38 | 39 | public static void i(String msg) { 40 | i(TAG,msg); 41 | } 42 | 43 | public static void i(String tag,String msg) { 44 | if (!sDebug) return; 45 | Log.i(tag, msg); 46 | } 47 | 48 | public static void v(String msg) { 49 | v(TAG,msg); 50 | } 51 | 52 | public static void v(String tag,String msg) { 53 | if (!sDebug) return; 54 | Log.v(tag, msg); 55 | } 56 | 57 | public static void w(String msg) { 58 | w(TAG,msg); 59 | } 60 | 61 | public static void w(String tag,String msg) { 62 | if (!sDebug) return; 63 | Log.w(tag, msg); 64 | } 65 | 66 | public static void e(String msg) { 67 | e(TAG,msg); 68 | } 69 | 70 | public static void e(String tag,String msg) { 71 | if (!sDebug) return; 72 | Log.e(tag, msg); 73 | } 74 | 75 | /** 76 | * 日志 77 | * @param tag 标记 78 | * @param msg 消息 79 | * @param level 日志等级 80 | */ 81 | public static void log(String tag,String msg,int level){ 82 | switch (level) { 83 | case DEBUG: 84 | case INFO: 85 | d(tag,msg); 86 | break; 87 | case ASSERT: 88 | i(tag,msg); 89 | break; 90 | case VERBOSE: 91 | v(tag,msg); 92 | break; 93 | case WARN: 94 | w(tag,msg); 95 | break; 96 | case ERROR: 97 | e(tag,msg); 98 | break; 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/widget/LayoutProvider.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.widget; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.graphics.Outline; 5 | import android.view.View; 6 | import android.view.ViewOutlineProvider; 7 | 8 | /** 9 | * created by hty 10 | * 2022/11/8 11 | * Desc:View圆角 12 | */ 13 | @SuppressLint("NewApi") 14 | public class LayoutProvider extends ViewOutlineProvider { 15 | 16 | private float mRadius; 17 | 18 | public LayoutProvider(float radius){ 19 | this.mRadius = radius; 20 | } 21 | 22 | @Override 23 | public void getOutline(View view, Outline outline) { 24 | outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mRadius); 25 | view.setClipToOutline(true); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/widget/LoadingView.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.widget; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.View; 6 | import android.widget.LinearLayout; 7 | import android.widget.ProgressBar; 8 | import android.widget.TextView; 9 | import com.platform.lib.R; 10 | 11 | /** 12 | * created by hty 13 | * 2022/11/8 14 | * Desc:加载中 15 | */ 16 | public class LoadingView extends LinearLayout { 17 | 18 | private ProgressBar mProgressBar; 19 | private TextView mTvContent; 20 | 21 | public LoadingView(Context context) { 22 | this(context,null); 23 | } 24 | 25 | public LoadingView(Context context, AttributeSet attrs) { 26 | this(context, attrs,0); 27 | } 28 | 29 | public LoadingView(Context context, AttributeSet attrs, int defStyleAttr) { 30 | super(context, attrs, defStyleAttr); 31 | View.inflate(context, R.layout.lib_view_loading,this); 32 | mProgressBar = (ProgressBar) findViewById(R.id.lib_view_progress); 33 | mTvContent = (TextView) findViewById(R.id.lib_view_content); 34 | } 35 | 36 | public void showRequst(String message) { 37 | if(null!=mProgressBar){ 38 | mProgressBar.setVisibility(VISIBLE); 39 | mProgressBar.setIndeterminate(true); 40 | } 41 | if(null!=mTvContent) mTvContent.setText(message); 42 | } 43 | 44 | public void showResult(String message) { 45 | if (null != mProgressBar) { 46 | mProgressBar.setIndeterminate(false); 47 | mProgressBar.setVisibility(GONE); 48 | } 49 | if (null != mTvContent) mTvContent.setText(message); 50 | } 51 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/widget/NativeRender.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.widget; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.widget.FrameLayout; 6 | import android.widget.ImageView; 7 | import android.widget.RelativeLayout; 8 | import android.widget.TextView; 9 | import com.bytedance.msdk.api.v2.ad.nativeAd.GMNativeAd; 10 | import com.platform.lib.R; 11 | import com.platform.lib.listener.NativeRenderControl; 12 | import com.platform.lib.utils.ImageLoader; 13 | import com.platform.lib.utils.PlatformUtils; 14 | 15 | /** 16 | * created by hty 17 | * 2022/11/8 18 | * Desc:原生信息流渲染器 19 | */ 20 | public class NativeRender implements NativeRenderControl { 21 | 22 | @Override 23 | public View getRenderView(Context context) { 24 | return View.inflate(context, R.layout.lib_native_render,null); 25 | } 26 | 27 | @Override 28 | public void onRenderNativeView(View selfRenderView, GMNativeAd nativeAd, float adWidth) { 29 | if(null!=selfRenderView&&null!=nativeAd){ 30 | //标题栏 31 | TextView titleView = (TextView) selfRenderView.findViewById(R.id.lib_native_title); 32 | //Icon 33 | FrameLayout iconArea = (FrameLayout) selfRenderView.findViewById(R.id.lib_native_icon); 34 | PlatformUtils.getInstance().setCircleRadius(iconArea,PlatformUtils.getInstance().dpToPxInt(8f)); 35 | //描述信息 36 | TextView descView = (TextView) selfRenderView.findViewById(R.id.lib_native_desc); 37 | //下载、打开按钮 38 | TextView ctaView = (TextView) selfRenderView.findViewById(R.id.lib_native_btn); 39 | //广告内容平台 40 | TextView adFromView = (TextView) selfRenderView.findViewById(R.id.lib_native_from); 41 | //广告主封面 42 | ImageView cover = (ImageView) selfRenderView.findViewById(R.id.lib_native_cover); 43 | //广告平台LOGO 44 | ImageView logoView = (ImageView) selfRenderView.findViewById(R.id.lib_native_ad_logo); 45 | //关闭按钮 46 | View closeView = selfRenderView.findViewById(R.id.lib_native_close); 47 | //主视图(封面图片、封面视频)容器 48 | FrameLayout contentArea = (FrameLayout) selfRenderView.findViewById(R.id.lib_native_ad_container); 49 | //主视图的宽高 50 | int mainImageWidth = nativeAd.getImageWidth(); 51 | int mainImageHeight = nativeAd.getImageHeight(); 52 | //确定最大渲染宽度 53 | int realMainImageWidth = PlatformUtils.getInstance().dpToPxInt(adWidth); 54 | RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) contentArea.getLayoutParams(); 55 | if(mainImageWidth>0&&mainImageHeight>0){ 56 | layoutParams.width = realMainImageWidth; 57 | layoutParams.height = realMainImageWidth * mainImageHeight / mainImageWidth; 58 | }else{ 59 | layoutParams.width = realMainImageWidth; 60 | layoutParams.height = realMainImageWidth * 9 / 16; 61 | } 62 | contentArea.setLayoutParams(layoutParams); 63 | String imageUrl = nativeAd.getImageUrl(); 64 | String title = nativeAd.getTitle(); 65 | String description = nativeAd.getDescription(); 66 | String actionText = nativeAd.getActionText(); 67 | titleView.setText(title); 68 | descView.setText(description); 69 | ctaView.setText(actionText); 70 | new ImageLoader().displayImage(cover,imageUrl); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /gromore/src/main/java/com/platform/lib/widget/SplashView.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.widget; 2 | 3 | import android.content.Context; 4 | import android.text.TextUtils; 5 | import android.util.AttributeSet; 6 | import android.widget.FrameLayout; 7 | import com.bytedance.msdk.api.v2.ad.splash.GMSplashAd; 8 | import com.platform.lib.constants.AdConstance; 9 | import com.platform.lib.listener.OnSplashListener; 10 | import com.platform.lib.listener.OnSplashStatusListener; 11 | import com.platform.lib.manager.PlatformManager; 12 | import com.platform.lib.utils.PlatformUtils; 13 | 14 | /** 15 | * created by hty 16 | * 2022/10/8 17 | * Desc:开屏广告容器包装,内部根据广告配置自动识别广告平台和渲染广告 18 | * 1、开始加载广告:{@link #loadSplashAd(String ad_code, OnSplashStatusListener listener)} 19 | */ 20 | public class SplashView extends FrameLayout implements OnSplashListener { 21 | 22 | private OnSplashStatusListener mListener; 23 | private String mCurrentId; 24 | 25 | public SplashView(Context context) { 26 | super(context); 27 | } 28 | 29 | public SplashView(Context context, AttributeSet attrs) { 30 | super(context, attrs); 31 | } 32 | 33 | public SplashView(Context context, AttributeSet attrs, int defStyleAttr) { 34 | super(context, attrs, defStyleAttr); 35 | } 36 | 37 | /** 38 | * 加载开屏广告 39 | * @param ad_code 广告位ID 40 | * @param listener 状态监听 41 | */ 42 | public void loadSplashAd(String ad_code, OnSplashStatusListener listener){ 43 | loadSplashAd(ad_code,AdConstance.SCENE_CACHE,listener); 44 | } 45 | 46 | /** 47 | * 加载开屏广告 48 | * @param ad_code 广告位ID 49 | * @param scene 场景 50 | * @param listener 状态监听 51 | */ 52 | public void loadSplashAd(String ad_code, String scene,OnSplashStatusListener listener){ 53 | loadSplashAd(ad_code,scene,PlatformUtils.getInstance().getScreenWidth(),PlatformUtils.getInstance().getScreenHeight(), listener); 54 | } 55 | 56 | /** 57 | * 加载开屏广告 58 | * @param ad_code 广告位ID 59 | * @param scene 场景 60 | * @param width 预期渲染的宽,单位:分辨率 61 | * @param width 预期渲染的高,单位:分辨率 62 | * @param listener 状态监听 63 | */ 64 | public void loadSplashAd(String ad_code, String scene,int width,int height,OnSplashStatusListener listener){ 65 | this.mListener=listener; 66 | if(!TextUtils.isEmpty(ad_code)){ 67 | this.mCurrentId=new StringBuilder(ad_code).toString(); 68 | PlatformManager.getInstance().loadSplash(PlatformUtils.getInstance().getActivity(getContext()),ad_code,scene,width,height,SplashView.this); 69 | }else{ 70 | if(null!=mListener) mListener.onError(AdConstance.CODE_ID_UNKNOWN, PlatformManager.getInstance().getText(AdConstance.CODE_ID_UNKNOWN),ad_code); 71 | } 72 | } 73 | 74 | @Override 75 | public void onSuccess(GMSplashAd atSplashAd) { 76 | // Logger.d("onSuccess-->ATSplashAd"); 77 | if(null!=atSplashAd){ 78 | removeAllViews(); 79 | atSplashAd.showAd(this); 80 | }else{ 81 | onError(0,null,""); 82 | } 83 | } 84 | 85 | @Override 86 | public void onShow() { 87 | // Logger.d("onShow-->"); 88 | if(null!=mListener) mListener.onShow(); 89 | } 90 | 91 | @Override 92 | public void onClose() { 93 | // Logger.d("onClose-->"); 94 | removeAllViews(); 95 | if(null!=mListener) mListener.onClose(); 96 | } 97 | 98 | @Override 99 | public void onTimeOut() { 100 | // Logger.d("onTimeOut-->"); 101 | onError(AdConstance.CODE_TIMOUT,PlatformManager.getInstance().getText(AdConstance.CODE_TIMOUT),mCurrentId); 102 | } 103 | 104 | @Override 105 | public void onClick() { 106 | // Logger.d("onClick-->"); 107 | if(null!=mListener) mListener.onClick(); 108 | } 109 | 110 | @Override 111 | public void onError(int code, String message, String adCode) { 112 | // Logger.d("onError-->code:"+code+",message:"+message+",id:"+adCode); 113 | if(null!=mListener) mListener.onError(code,message,adCode); 114 | } 115 | 116 | @Override 117 | protected void onDetachedFromWindow() { 118 | super.onDetachedFromWindow(); 119 | onReset(); 120 | } 121 | 122 | public void onReset(){ 123 | mListener=null; 124 | } 125 | } -------------------------------------------------------------------------------- /gromore/src/main/res/drawable/lib_bg_close.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gromore/src/main/res/drawable/lib_native_bg_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /gromore/src/main/res/drawable/lib_native_bg_from.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gromore/src/main/res/layout/lib_activity_reward.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 26 | -------------------------------------------------------------------------------- /gromore/src/main/res/layout/lib_view_express_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /gromore/src/main/res/layout/lib_view_loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 21 | -------------------------------------------------------------------------------- /gromore/src/main/res/mipmap-xxhdpi/lib_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/gromore/src/main/res/mipmap-xxhdpi/lib_close.png -------------------------------------------------------------------------------- /gromore/src/main/res/values-v19/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 26 | 27 | -------------------------------------------------------------------------------- /gromore/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FD3765 4 | #FFFFFF 5 | 6 | -------------------------------------------------------------------------------- /gromore/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "advert" 2 | include ':app-topon' 3 | include ':app-gromore' 4 | include ':topon' 5 | include ':gromore' -------------------------------------------------------------------------------- /topon/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /topon/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group='com.github.hty527'//xxx:代表你的github用户名 5 | 6 | android { 7 | compileSdkVersion 29 8 | buildToolsVersion '29.0.3' 9 | 10 | defaultConfig { 11 | minSdkVersion 17 12 | targetSdkVersion 29 13 | versionCode rootProject.ext.topon.versionCode 14 | versionName rootProject.ext.topon.versionName 15 | } 16 | 17 | buildTypes { 18 | debug { 19 | debuggable true 20 | zipAlignEnabled false 21 | minifyEnabled false 22 | signingConfig signingConfigs.debug 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | } 25 | release { 26 | debuggable false 27 | zipAlignEnabled true 28 | minifyEnabled true 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | signingConfig signingConfigs.debug 31 | } 32 | } 33 | 34 | lintOptions { 35 | abortOnError false 36 | } 37 | 38 | compileOptions { 39 | sourceCompatibility JavaVersion.VERSION_1_8 40 | targetCompatibility JavaVersion.VERSION_1_8 41 | } 42 | } 43 | 44 | dependencies { 45 | //当library和主模块同时引用第三方aar文件时,library模块需要使用compileOnly关键字来引用aar 46 | compileOnly fileTree(include: ['*.jar', '*.aar'], dir: 'libs_topon') 47 | } -------------------------------------------------------------------------------- /topon/libs_topon/anythink_banner.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/topon/libs_topon/anythink_banner.aar -------------------------------------------------------------------------------- /topon/libs_topon/anythink_china_core.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/topon/libs_topon/anythink_china_core.aar -------------------------------------------------------------------------------- /topon/libs_topon/anythink_core.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/topon/libs_topon/anythink_core.aar -------------------------------------------------------------------------------- /topon/libs_topon/anythink_interstitial.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/topon/libs_topon/anythink_interstitial.aar -------------------------------------------------------------------------------- /topon/libs_topon/anythink_native.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/topon/libs_topon/anythink_native.aar -------------------------------------------------------------------------------- /topon/libs_topon/anythink_rewardvideo.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/topon/libs_topon/anythink_rewardvideo.aar -------------------------------------------------------------------------------- /topon/libs_topon/anythink_splash.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/topon/libs_topon/anythink_splash.aar -------------------------------------------------------------------------------- /topon/libs_topon/gson-2.8.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/topon/libs_topon/gson-2.8.4.jar -------------------------------------------------------------------------------- /topon/libs_topon/tramini_sdk.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/topon/libs_topon/tramini_sdk.aar -------------------------------------------------------------------------------- /topon/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | 2 | -optimizationpasses 5 3 | -useuniqueclassmembernames 4 | #优化时允许访问并修改有修饰符的类和类的成员 5 | -allowaccessmodification 6 | #混淆时是否记录日志 7 | -verbose 8 | #忽略警告 9 | -ignorewarnings 10 | # 混淆时所采用的算法 11 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 12 | #-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*,!code/allocation/variable 13 | -keepattributes EnclosingMethod 14 | -dontoptimize 15 | # 混淆时不使用大小写混合,混淆后的类名为小写 16 | # windows下的同学还是加入这个选项吧(windows大小写不敏感) 17 | -dontusemixedcaseclassnames 18 | # 指定不去忽略非公共的库的类 19 | # 默认跳过,有些情况下编写的代码与类库中的类在同一个包下,并且持有包中内容的引用,此时就需要加入此条声明 20 | -dontskipnonpubliclibraryclasses 21 | # 指定不去忽略非公共的库的类的成员 22 | -dontskipnonpubliclibraryclassmembers 23 | # 不做预检验,preverify是proguard的四个步骤之一 24 | # Android不需要preverify,去掉这一步可以加快混淆速度 25 | -dontpreverify 26 | # 有了verbose这句话,混淆后就会生成映射文件 27 | # 包含有类名->混淆后类名的映射关系 28 | # 然后使用printmapping指定映射文件的名称 29 | #-verbose 30 | 31 | #保持自定义控件类不被混淆 32 | -keepclasseswithmembers class * { 33 | public (android.content.Context, android.util.AttributeSet); 34 | } 35 | #保持自定义控件类不被混淆 36 | -keepclasseswithmembers class * { 37 | public (android.content.Context); 38 | public (android.content.Context, android.util.AttributeSet); 39 | public (android.content.Context, android.util.AttributeSet, int); 40 | } 41 | -keep public class * extends android.app.Activity{ 42 | public ; 43 | public ; 44 | } 45 | -keep public class * extends android.app.Application{ 46 | public ; 47 | public ; 48 | } 49 | 50 | #SDK所有R文件不参与混淆 51 | -keep public class com.platform.lib.R$*{ 52 | public static final int *; 53 | } 54 | 55 | #保留出口及出口内的部分方法不被混淆 56 | #保留AdvertManager类的所有公开方法这个 57 | #-keep class com.topon.advert.manager.AdvertManager {*;} 58 | -keep class com.platform.lib.manager.PlatformManager { 59 | public *; 60 | } 61 | -keep class com.platform.lib.manager.TableScreenManager { 62 | public *; 63 | } 64 | -keep class com.platform.lib.manager.PlayManager { 65 | public *; 66 | } 67 | -keep class com.platform.lib.constants.AdConstance {*;} 68 | -keep class com.platform.lib.bean.Result { 69 | public *; 70 | } 71 | #-keep class com.platform.lib.utils.Logger { 72 | # public *; 73 | #} 74 | -keep class com.platform.lib.listener.** {*;} 75 | #保留ExpressView类的requst及destroy方法 76 | -keep class com.platform.lib.widget.ExpressView { 77 | public void requst(); 78 | public void onResume(); 79 | public void onPause(); 80 | public void destroy(); 81 | public void addErrorView(int, java.lang.String, java.lang.String); 82 | } 83 | -keep class com.platform.lib.widget.SplashView { 84 | public *; 85 | } 86 | #将所有混淆的类放到指定目录下 87 | -repackageclasses com.platform.core 88 | 89 | ##删除所有的log代码 90 | #-assumenosideeffects 91 | #class android.util.Log 92 | # { 93 | # public static *** 94 | # e(...); 95 | # public static *** 96 | # w(...); 97 | # public static *** 98 | # wtf(...); 99 | # public static *** 100 | # d(...); 101 | # public static *** 102 | # v(...); 103 | #} -------------------------------------------------------------------------------- /topon/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 7 | 8 | 9 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/bean/Result.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.bean; 2 | 3 | import android.text.TextUtils; 4 | 5 | /** 6 | * created by hty 7 | * 2022/10/8 8 | * Desc:广告播放完成的状态及信息 9 | */ 10 | public class Result { 11 | 12 | private String adCode;//广告位ID 13 | private String isClick;//是否点击了广告,1:点击了广告,0:未点击广告 14 | private boolean rewardVerify;//是否是一个有效的播放 15 | private String cpmInfo;//广告的ecpm信息,cpm/cpm精度/展示单价等json字段,例如格式:{"price":"20.28470431","precision":"exact","pre_price":"0.02028470431"} 16 | private int platformId;//广告的实际平台标识,详见https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_callback_access?id=callback_info说明 17 | private String customData;//启用服务端验证下发奖励时的用户自定义数据 18 | 19 | public String getAdCode() { 20 | return adCode; 21 | } 22 | 23 | public void setAdCode(String adCode) { 24 | this.adCode = adCode; 25 | } 26 | 27 | public String getIsClick() { 28 | return isClick; 29 | } 30 | 31 | public void setIsClick(String isClick) { 32 | this.isClick = isClick; 33 | } 34 | 35 | public boolean isRewardVerify() { 36 | return rewardVerify; 37 | } 38 | 39 | public void setRewardVerify(boolean rewardVerify) { 40 | this.rewardVerify = rewardVerify; 41 | } 42 | 43 | /** 44 | * @return 广告的ecpm信息,cpm/cpm精度/展示单价等json字段,例如格式:{"price":"20.28470431","precision":"exact","pre_price":"0.02028470431"} 45 | */ 46 | public String getCpmInfo() { 47 | if(TextUtils.isEmpty(cpmInfo)) cpmInfo ="0"; 48 | return cpmInfo; 49 | } 50 | 51 | public void setCpmInfo(String cpmInfo) { 52 | this.cpmInfo = cpmInfo; 53 | } 54 | 55 | public int getPlatformId() { 56 | return platformId; 57 | } 58 | 59 | public void setPlatformId(int platformId) { 60 | this.platformId = platformId; 61 | } 62 | 63 | public String getCustomData() { 64 | return customData; 65 | } 66 | 67 | public void setCustomData(String customData) { 68 | this.customData = customData; 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | return "Result{" + 74 | "adCode='" + adCode + '\'' + 75 | ", isClick='" + isClick + '\'' + 76 | ", rewardVerify='" + rewardVerify + '\'' + 77 | ", cpmInfo='" + cpmInfo + '\'' + 78 | ", platformId=" + platformId + 79 | ", customData='" + customData + '\'' + 80 | '}'; 81 | } 82 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/constants/AdConstance.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.constants; 2 | 3 | /** 4 | * created by hty 5 | * 2022/10/8 6 | * Desc: 7 | */ 8 | public interface AdConstance { 9 | 10 | /** 11 | * 广告平台 12 | */ 13 | String SOURCE_TT = "1";//穿山甲 14 | String SOURCE_TX = "3";//优量汇 15 | String SOURCE_KS = "5";//快手 16 | String SOURCE_TO = "8";//topon聚合平台 17 | 18 | /** 19 | * 广告位类型 20 | */ 21 | String TYPE_STREAM = "1";//信息流 22 | String TYPE_INSERT = "2";//插屏广告 23 | String TYPE_BANNER = "3";//Banner 24 | String TYPE_REWARD_VIDEO = "4";//激励视频 25 | String TYPE_FULL_VIDEO = "5";//全屏视频 26 | String TYPE_SPLASH = "6";//开屏广告 27 | 28 | /** 29 | * 广告状态 30 | */ 31 | String STATUS_LOADED_SUCCESS = "1";//加载成功 32 | String STATUS_LOADED_ERROR = "2";//加载失败 33 | String STATUS_SHOW_SUCCESS = "3";//显示成功 34 | String STATUS_SHOW_ERROR = "4";//显示失败 35 | 36 | /** 37 | * 错误码 38 | */ 39 | int CODE_CONTEXT_INVALID = 1; //上下文无效 40 | int CODE_ACTIVITY_INVALID = 2; //Activity无效或已被关闭 41 | int CODE_VIEWGROUP_INVALID = 3; //ViewGroup容器无效 42 | int CODE_APPID_INVALID = 4; //app_id无效 43 | int CODE_APPSECRECY_INVALID = 5; //app_secrecy无效 44 | int CODE_ID_UNKNOWN = 6;//未知的广告位 45 | int CODE_ID_INVALID = 7;//无效的广告位ID 46 | int CODE_TYPE_INVALID = 8;//无效的广告位类型 47 | int CODE_TIMOUT = 9;//超时 48 | int CODE_ADINFO_INVALID = 10;//广告对象无效 49 | int CODE_REPEATED = 11;//正在显示中 50 | int CODE_AD_EMPTY = 12;//暂无广告填充 51 | int CODE_AD_LOADING = 13;//广告正在请求中 52 | int CODE_EXIST_CACHE = 14;//存在缓存广告 53 | int CODE_APPLY_FAIL = 15;//广告应用到布局失败 54 | int CODE_DEVELOP = 16;//开发者模式,跳过广告 55 | int CODE_CONFIG_LOADING = 17;//广告配置正在加载中 56 | int CODE_AD_DISABLED = 18;//广告不可用 57 | 58 | /** 59 | * 错误描述信息 60 | */ 61 | String ERROR_CONTEXT_INVALID = "context invalid"; //上下文无效 62 | String ERROR_ACTIVITY_INVALID = "activity invalid"; //Activity无效或已被关闭 63 | String ERROR_VIEWGROUP_INVALID = "viewgroup invalid";//ViewGroup容器无效 64 | String ERROR_APPID_INVALID = "app_id invalid"; //app_id无效 65 | String ERROR_APPSECRECY_INVALID = "app_secrecy invalid"; //app_secrecy无效 66 | String ERROR_ID_UNKNOWN = "id unknown";//未知的广告位 67 | String ERROR_ID_INVALID = "id is invalid";//无效的广告位ID 68 | String ERROR_TYPE_INVALID = "type is invalid";//无效的广告位类型 69 | String ERROR_TIMOUT = "timeout";//超时 70 | String ERROR_ADINFO_INVALID = "ad invalid";//广告对象无效 71 | String ERROR_REPEATED = "is showing";//正在显示中 72 | String ERROR_AD_EMPTY = "ad is empty";//暂无广告填充 73 | String ERROR_AD_LOADING = "please wait...";//广告正在请求中 74 | String ERROR_EXIST_CACHE = "exist_cache";//存在缓存广告 75 | String ERROR_APPLY_FAIL = "express apply fail";//广告应用到布局失败 76 | String ERROR_DEVELOP = "develop mode,skip";//开发者模式,跳过广告 77 | String ERROR_CONFIG_LOADING = "config loading";//广告配置正在加载中 78 | String ERROR_AD_DISABLED = "ad disabled";//广告不可用 79 | 80 | /** 81 | * 加载广告场景 82 | */ 83 | String SCENE_CACHE = "-1";//默认是缓存广告 84 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/listener/BaseListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | /** 4 | * created by hty 5 | * 2022/10/8 6 | * Desc:监听器基类 7 | */ 8 | public interface BaseListener { 9 | 10 | /** 11 | * 广告被显示了 12 | */ 13 | void onShow(); 14 | 15 | /** 16 | * 广告被点击了 17 | */ 18 | void onClick(); 19 | 20 | /** 21 | * 广告被关闭了 22 | */ 23 | void onClose(); 24 | 25 | /** 26 | * 广告拉取/播放错误 27 | * @param code 错误码,参考:AdConstance 和 https://docs.toponad.com/#/zh-cn/android/android_doc/android_errorcode 28 | * @param message 错误信息 29 | * @param adCode 广告位ID 30 | */ 31 | void onError(int code, String message, String adCode); 32 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/listener/NativeRenderControl.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import com.anythink.nativead.api.ATNativeMaterial; 6 | import com.anythink.nativead.api.ATNativePrepareInfo; 7 | 8 | /** 9 | * created by hty 10 | * 2022/10/12 11 | * Desc:原生自渲染信息流广告填充器 12 | */ 13 | public interface NativeRenderControl { 14 | 15 | /** 16 | * 创建自定义UI组件 17 | * @param context 广告ExpressView上下文。返回一个有效的自定义ViewGroup,SDK内部会添加到容器中 18 | * @return 19 | */ 20 | V getRenderView(Context context); 21 | 22 | /** 23 | * 将广告信息绑定到自定义UI组件上,并且将各子自定义ViewGroup(比如点击按钮、icon组件)绑定到native广告上 24 | * @param selfRenderView 将广告信息绑定到自定义UI组件上,并且将各子自定义ViewGroup(比如点击按钮、icon组件)绑定到native广告上,selfRenderView:自定义渲染UI组件 25 | * @param adMaterial 原生广告信息 26 | * @param adWidth 期望渲染的广告宽度,高度SDK自适应,会通过OnExpressAdListener回调通知实际渲染的高度 27 | * @param nativePrepareInfo 包含各子自定义ViewGroup(比如点击按钮、icon组件)等组件信息 28 | */ 29 | void onRenderNativeView(V selfRenderView, ATNativeMaterial adMaterial, float adWidth, ATNativePrepareInfo nativePrepareInfo); 30 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/listener/OnEventListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * created by hty 7 | * 2022/10/8 8 | * Desc:广告各状态全局状态监听 9 | */ 10 | public interface OnEventListener { 11 | 12 | /** 13 | * 广告的缓存、展示功能是否可用 14 | * @return 广告的缓存、展示功能是否可用,true:可用,false:被禁用 15 | */ 16 | boolean isAvailable(); 17 | 18 | /** 19 | * 根据错误码返回文字文案 20 | * @param code 错误码参考AdConstance定义的"错误码" 21 | * @return 如果返回的文字为空,则使用SDK内部默认文案 22 | */ 23 | String getText(int code); 24 | 25 | /** 26 | * 自定义透传的数据 27 | * @return 自定义透传的数据,开启服务端验证的激励视频代码位传入。SDK将回传给给代码位指定的回调地址 28 | * 参考:https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_rewardedvideo_auto_access 29 | */ 30 | Map localExtra(); 31 | 32 | /** 33 | * 广告事件回调 34 | * @param scene 播放广告的场景 35 | * @param ad_type 广告类型,Constance申明 36 | * @param ad_code 广告位ID 37 | * @param ad_status 广告状态:1:加载成功 2:加载失败 3:显示成功 4:显示失败 38 | * @param error_code 错误码 39 | * @param error_msg 全量的错误信息 40 | */ 41 | void onEvent(String scene, String ad_type, String ad_code, String ad_status, int error_code, String error_msg); 42 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/listener/OnExpressAdListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | /** 4 | * created by hty 5 | * 2022/10/12 6 | * Desc:信息流\Banner渲染状态监听 7 | */ 8 | public interface OnExpressAdListener { 9 | 10 | /** 11 | * 广告加载成功了 12 | */ 13 | void onSuccess(); 14 | 15 | /** 16 | * 广告被显示了 17 | */ 18 | void onShow(); 19 | 20 | /** 21 | * 广告被点击了 22 | */ 23 | void onClick(); 24 | 25 | /** 26 | * 广告成功渲染后的高度,单位:像素。仅Banner和信息流回调 27 | * @param adViewHeight 28 | */ 29 | void onAdViewHeight(int adViewWidth,int adViewHeight); 30 | 31 | /** 32 | * 广告被移除了 33 | */ 34 | void onClose(); 35 | 36 | /** 37 | * 播放失败 38 | * @param code 错误码 39 | * @param message 描述信息 40 | * @param adCode 广告位ID 41 | */ 42 | void onError(int code, String message, String adCode); 43 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/listener/OnExpressListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import com.anythink.banner.api.ATBannerView; 4 | import com.anythink.nativead.api.NativeAd; 5 | 6 | /** 7 | * created by hty 8 | * 2022/10/8 9 | * Desc:信息流、Banner广告的加载状态 10 | */ 11 | public interface OnExpressListener extends BaseListener { 12 | 13 | /** 14 | * 信息流广告加载成功 15 | * @param nativeAd 16 | */ 17 | void onSuccessExpressed(NativeAd nativeAd); 18 | 19 | /** 20 | * banner广告加载成功 21 | * @param atBannerView 22 | */ 23 | void onSuccessBanner(ATBannerView atBannerView); 24 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/listener/OnInitListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import com.anythink.core.api.ATInitConfig; 4 | import java.util.List; 5 | 6 | /** 7 | * created by hty 8 | * 2022/10/8 9 | * Desc:初始化状态 10 | */ 11 | public abstract class OnInitListener { 12 | 13 | /** 14 | * 构建初始化配置,开发者可重写此配置,自定义自己的配置 15 | * @return 16 | */ 17 | public List getSdkConfig() { 18 | return null; 19 | } 20 | 21 | /** 22 | * 初始化成功 23 | * @param adCode 广告位ID 24 | */ 25 | public void onSuccess(String adCode){} 26 | 27 | /** 28 | * 初始化失败 29 | * @param code 错误码,参考Constance类 30 | * @param message 描述信息 31 | */ 32 | public void onError(int code,String message){} 33 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/listener/OnPlayListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import android.app.Activity; 4 | import com.anythink.core.api.ATAdInfo; 5 | import com.anythink.rewardvideo.api.ATRewardVideoAd; 6 | import com.platform.lib.bean.Result; 7 | 8 | /** 9 | * created by hty 10 | * 2022/10/8 11 | * Desc:激励视频\信息流\Banner\插屏等广告 播放状态监听器 12 | */ 13 | public abstract class OnPlayListener { 14 | 15 | /** 16 | * 广告加载成功了(播放激励视频时回调) 17 | * @param atRewardVideoAd 仅激励视频并且非全自动时此对象可能不为空 18 | */ 19 | public void onSuccess(ATRewardVideoAd atRewardVideoAd){} 20 | 21 | /** 22 | * 第三方广告Activity被创建了 23 | * @param activity 24 | */ 25 | public void onAdvertActivityCreated(Activity activity){} 26 | 27 | /** 28 | * 广告被显示了 29 | */ 30 | public void onShow(){} 31 | 32 | /** 33 | * 广告被点击了(播放激励视频时回调) 34 | */ 35 | public void onClick(){} 36 | 37 | /** 38 | * 广告被点击了(播放激励视频时回调) 39 | * @param atAdInfo 广告信息 40 | */ 41 | public void onClick(ATAdInfo atAdInfo){} 42 | 43 | /** 44 | * 广告播放合法有效 45 | */ 46 | public void onRewardVerify(){} 47 | 48 | /** 49 | * 播放失败 50 | * @param code 错误码 51 | * @param message 描述信息 52 | * @param adCode 广告位ID 53 | */ 54 | public void onError(int code, String message, String adCode){} 55 | 56 | /** 57 | * 当播放激励视频时,无论何种原因,广告播放关闭了,此方法会回调。其它广告类型仅在广告正常关闭时回调 58 | * @param result 播放状态,当有效播放或开发者模式时不为空,其他状态为null,请注意! 59 | */ 60 | public abstract void onClose(Result result); 61 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/listener/OnRewardVideoListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import com.anythink.core.api.ATAdInfo; 4 | import com.anythink.rewardvideo.api.ATRewardVideoAd; 5 | 6 | /** 7 | * created by hty 8 | * 2022/10/8 9 | * Desc:激励视频加载\播放等原始状态监听 10 | */ 11 | public interface OnRewardVideoListener { 12 | 13 | /** 14 | * 广告正在加载中 15 | */ 16 | void onLoading(); 17 | 18 | /** 19 | * 加载视频广告成功 20 | * @param atRewardVideoAd 21 | */ 22 | void onSuccess(ATRewardVideoAd atRewardVideoAd); 23 | 24 | /** 25 | * 广告被显示了 26 | */ 27 | void onShow(); 28 | 29 | /** 30 | * 广告被点击了 31 | * @param atAdInfo 32 | */ 33 | void onClick(ATAdInfo atAdInfo); 34 | 35 | /** 36 | * 该视频广告的有效性校验 37 | */ 38 | void onRewardVerify(); 39 | 40 | /** 41 | * 广告被关闭了 42 | * @param cpmInfo cpm/cpm精度/展示单价等json字段,例如格式:{"price":"20.28470431","precision":"exact","pre_price":"0.02028470431"} 43 | * @param customData 自定义透传参数 44 | */ 45 | void onClose(String cpmInfo,String customData); 46 | 47 | /** 48 | * 广告拉取/播放错误 49 | * @param code 错误码,参考:AdConstance 和 https://docs.toponad.com/#/zh-cn/android/android_doc/android_errorcode 50 | * @param message 错误信息 51 | * @param adCode 广告位ID 52 | */ 53 | void onError(int code, String message, String adCode); 54 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/listener/OnSplashListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import com.anythink.splashad.api.ATSplashAd; 4 | 5 | /** 6 | * created by hty 7 | * 2022/10/8 8 | * Desc:开屏广告的加载\播放状态 9 | */ 10 | public interface OnSplashListener extends BaseListener { 11 | 12 | /** 13 | * 加载开屏广告成功了 14 | * @param atSplashAd 15 | */ 16 | void onSuccess(ATSplashAd atSplashAd); 17 | 18 | /** 19 | * 广告加载超时了 20 | */ 21 | void onTimeOut(); 22 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/listener/OnSplashStatusListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | /** 4 | * created by hty 5 | * 2022/11/8 6 | * Desc:开屏 7 | */ 8 | public interface OnSplashStatusListener extends BaseListener {} -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/listener/OnTabScreenListener.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.listener; 2 | 3 | import com.anythink.interstitial.api.ATInterstitial; 4 | 5 | /** 6 | * created by hty 7 | * 2022/10/8 8 | * Desc:插屏广告的加载监听 9 | */ 10 | public interface OnTabScreenListener extends BaseListener { 11 | /** 12 | * 插屏广告加载中 13 | */ 14 | void onLoading(); 15 | 16 | /** 17 | * 加载插屏广告成功了 18 | * @param interactionAd 19 | */ 20 | void onSuccess(ATInterstitial interactionAd); 21 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/utils/InitHelper.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.utils; 2 | 3 | import android.text.TextUtils; 4 | 5 | /** 6 | * created by hty 7 | * 2022/11/17 8 | * Desc:初始化帮助类 9 | */ 10 | public class InitHelper { 11 | 12 | public static void init(String target){ 13 | try { 14 | if(!TextUtils.isEmpty(target)&&PlatformUtils.getInstance().checkedPreferencesExist()){ 15 | 16 | } 17 | }catch (Throwable e){} 18 | } 19 | 20 | public static void unInit(){ 21 | try { 22 | if(PlatformUtils.getInstance().checkedPreferencesExist()){ 23 | 24 | } 25 | }catch (Throwable e){} 26 | } 27 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/utils/Logger.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.utils; 2 | 3 | import android.util.Log; 4 | 5 | /** 6 | * created by hty 7 | * 2022/3/24 8 | * Desc: 9 | */ 10 | public class Logger { 11 | 12 | private static boolean sDebug = true; 13 | 14 | public static final String TAG="PlatformSDK"; 15 | 16 | /** 17 | * 日志级别 18 | */ 19 | public static final int DEBUG = 0; 20 | public static final int INFO = 1; 21 | public static final int ASSERT = 2; 22 | public static final int VERBOSE = 3; 23 | public static final int WARN = 4; 24 | public static final int ERROR = 5; 25 | 26 | public static void setDebug(boolean debug) { 27 | Logger.sDebug = debug; 28 | } 29 | 30 | public static void d(String msg) { 31 | d(TAG,msg); 32 | } 33 | 34 | public static void d(String tag,String msg) { 35 | if (!sDebug) return; 36 | Log.d(tag, msg); 37 | } 38 | 39 | public static void i(String msg) { 40 | i(TAG,msg); 41 | } 42 | 43 | public static void i(String tag,String msg) { 44 | if (!sDebug) return; 45 | Log.i(tag, msg); 46 | } 47 | 48 | public static void v(String msg) { 49 | v(TAG,msg); 50 | } 51 | 52 | public static void v(String tag,String msg) { 53 | if (!sDebug) return; 54 | Log.v(tag, msg); 55 | } 56 | 57 | public static void w(String msg) { 58 | w(TAG,msg); 59 | } 60 | 61 | public static void w(String tag,String msg) { 62 | if (!sDebug) return; 63 | Log.w(tag, msg); 64 | } 65 | 66 | public static void e(String msg) { 67 | e(TAG,msg); 68 | } 69 | 70 | public static void e(String tag,String msg) { 71 | if (!sDebug) return; 72 | Log.e(tag, msg); 73 | } 74 | 75 | /** 76 | * 日志 77 | * @param tag 标记 78 | * @param msg 消息 79 | * @param level 日志等级 80 | */ 81 | public static void log(String tag,String msg,int level){ 82 | switch (level) { 83 | case DEBUG: 84 | case INFO: 85 | d(tag,msg); 86 | break; 87 | case ASSERT: 88 | i(tag,msg); 89 | break; 90 | case VERBOSE: 91 | v(tag,msg); 92 | break; 93 | case WARN: 94 | w(tag,msg); 95 | break; 96 | case ERROR: 97 | e(tag,msg); 98 | break; 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/widget/LayoutProvider.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.widget; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.graphics.Outline; 5 | import android.view.View; 6 | import android.view.ViewOutlineProvider; 7 | 8 | /** 9 | * Created by TinyHung@outlook.com 10 | * 2022/10/13 11 | */ 12 | @SuppressLint("NewApi") 13 | public class LayoutProvider extends ViewOutlineProvider { 14 | 15 | private float mRadius; 16 | 17 | public LayoutProvider(float radius){ 18 | this.mRadius = radius; 19 | } 20 | 21 | @Override 22 | public void getOutline(View view, Outline outline) { 23 | outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mRadius); 24 | view.setClipToOutline(true); 25 | } 26 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/widget/LoadingView.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.widget; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.View; 6 | import android.widget.LinearLayout; 7 | import android.widget.ProgressBar; 8 | import android.widget.TextView; 9 | import com.platform.lib.R; 10 | 11 | /** 12 | * created by hty 13 | * 2022/3/25 14 | * Desc:加载中 15 | */ 16 | public class LoadingView extends LinearLayout { 17 | 18 | private ProgressBar mProgressBar; 19 | private TextView mTvContent; 20 | 21 | public LoadingView(Context context) { 22 | this(context,null); 23 | } 24 | 25 | public LoadingView(Context context, AttributeSet attrs) { 26 | this(context, attrs,0); 27 | } 28 | 29 | public LoadingView(Context context, AttributeSet attrs, int defStyleAttr) { 30 | super(context, attrs, defStyleAttr); 31 | View.inflate(context, R.layout.lib_view_loading,this); 32 | mProgressBar = (ProgressBar) findViewById(R.id.lib_view_progress); 33 | mTvContent = (TextView) findViewById(R.id.lib_view_content); 34 | } 35 | 36 | public void showRequst(String message) { 37 | if(null!=mProgressBar){ 38 | mProgressBar.setVisibility(VISIBLE); 39 | mProgressBar.setIndeterminate(true); 40 | } 41 | if(null!=mTvContent) mTvContent.setText(message); 42 | } 43 | 44 | public void showResult(String message) { 45 | if (null != mProgressBar) { 46 | mProgressBar.setIndeterminate(false); 47 | mProgressBar.setVisibility(GONE); 48 | } 49 | if (null != mTvContent) mTvContent.setText(message); 50 | } 51 | } -------------------------------------------------------------------------------- /topon/src/main/java/com/platform/lib/widget/SplashView.java: -------------------------------------------------------------------------------- 1 | package com.platform.lib.widget; 2 | 3 | import android.content.Context; 4 | import android.text.TextUtils; 5 | import android.util.AttributeSet; 6 | import android.widget.FrameLayout; 7 | import com.anythink.splashad.api.ATSplashAd; 8 | import com.platform.lib.constants.AdConstance; 9 | import com.platform.lib.listener.OnSplashListener; 10 | import com.platform.lib.listener.OnSplashStatusListener; 11 | import com.platform.lib.manager.PlatformManager; 12 | import com.platform.lib.utils.PlatformUtils; 13 | 14 | /** 15 | * created by hty 16 | * 2022/10/8 17 | * Desc:开屏广告容器包装,内部根据广告配置自动识别广告平台和渲染广告 18 | * 1、开始加载广告:{@link #loadSplashAd(String ad_code, OnSplashStatusListener listener)} 19 | */ 20 | public class SplashView extends FrameLayout implements OnSplashListener { 21 | 22 | private OnSplashStatusListener mListener; 23 | private String mCurrentId; 24 | 25 | public SplashView(Context context) { 26 | super(context); 27 | } 28 | 29 | public SplashView(Context context, AttributeSet attrs) { 30 | super(context, attrs); 31 | } 32 | 33 | public SplashView(Context context, AttributeSet attrs, int defStyleAttr) { 34 | super(context, attrs, defStyleAttr); 35 | } 36 | 37 | /** 38 | * 加载开屏广告 39 | * @param ad_code 广告位ID 40 | * @param listener 状态监听 41 | */ 42 | public void loadSplashAd(String ad_code, OnSplashStatusListener listener){ 43 | loadSplashAd(ad_code,AdConstance.SCENE_CACHE,listener); 44 | } 45 | 46 | /** 47 | * 加载开屏广告 48 | * @param ad_code 广告位ID 49 | * @param scene 场景 50 | * @param listener 状态监听 51 | */ 52 | public void loadSplashAd(String ad_code, String scene,OnSplashStatusListener listener){ 53 | loadSplashAd(ad_code,scene,PlatformUtils.getInstance().getScreenWidth(),PlatformUtils.getInstance().getScreenHeight(), listener); 54 | } 55 | 56 | /** 57 | * 加载开屏广告 58 | * @param ad_code 广告位ID 59 | * @param scene 场景 60 | * @param width 预期渲染的宽,单位:分辨率 61 | * @param width 预期渲染的高,单位:分辨率 62 | * @param listener 状态监听 63 | */ 64 | public void loadSplashAd(String ad_code, String scene,int width,int height,OnSplashStatusListener listener){ 65 | this.mListener=listener; 66 | if(!TextUtils.isEmpty(ad_code)){ 67 | this.mCurrentId=new StringBuilder(ad_code).toString(); 68 | PlatformManager.getInstance().loadSplash(PlatformUtils.getInstance().getActivity(getContext()),ad_code,scene,width,height,SplashView.this); 69 | }else{ 70 | if(null!=mListener) mListener.onError(AdConstance.CODE_ID_UNKNOWN, PlatformManager.getInstance().getText(AdConstance.CODE_ID_UNKNOWN),ad_code); 71 | } 72 | } 73 | 74 | @Override 75 | public void onSuccess(ATSplashAd atSplashAd) { 76 | // Logger.d("onSuccess-->ATSplashAd"); 77 | if(null!=atSplashAd){ 78 | removeAllViews(); 79 | atSplashAd.show(PlatformUtils.getInstance().getActivity(getContext()),this); 80 | }else{ 81 | onError(0,null,""); 82 | } 83 | } 84 | 85 | @Override 86 | public void onShow() { 87 | // Logger.d("onShow-->"); 88 | if(null!=mListener) mListener.onShow(); 89 | } 90 | 91 | @Override 92 | public void onClose() { 93 | // Logger.d("onClose-->"); 94 | removeAllViews(); 95 | if(null!=mListener) mListener.onClose(); 96 | } 97 | 98 | @Override 99 | public void onTimeOut() { 100 | // Logger.d("onTimeOut-->"); 101 | onError(AdConstance.CODE_TIMOUT,PlatformManager.getInstance().getText(AdConstance.CODE_TIMOUT),mCurrentId); 102 | } 103 | 104 | @Override 105 | public void onClick() { 106 | // Logger.d("onClick-->"); 107 | if(null!=mListener) mListener.onClick(); 108 | } 109 | 110 | @Override 111 | public void onError(int code, String message, String adCode) { 112 | // Logger.d("onError-->code:"+code+",message:"+message+",id:"+adCode); 113 | if(null!=mListener) mListener.onError(code,message,adCode); 114 | } 115 | 116 | @Override 117 | protected void onDetachedFromWindow() { 118 | super.onDetachedFromWindow(); 119 | onReset(); 120 | } 121 | 122 | public void onReset(){ 123 | mListener=null; 124 | } 125 | } -------------------------------------------------------------------------------- /topon/src/main/res/drawable/lib_bg_close.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /topon/src/main/res/drawable/lib_native_bg_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /topon/src/main/res/drawable/lib_native_bg_from.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /topon/src/main/res/layout/lib_activity_reward.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 26 | -------------------------------------------------------------------------------- /topon/src/main/res/layout/lib_native_render.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 15 | 16 | 20 | 21 | 34 | 35 | 42 | 43 | 44 | 51 | 52 | 53 | 61 | 66 | 74 | 83 | 92 | 93 | 97 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /topon/src/main/res/layout/lib_view_express_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /topon/src/main/res/layout/lib_view_loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 21 | -------------------------------------------------------------------------------- /topon/src/main/res/mipmap-xxhdpi/lib_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hty527/advert/3f356eaedab8ed67b1409eff6d3ca2ac5667da0f/topon/src/main/res/mipmap-xxhdpi/lib_close.png -------------------------------------------------------------------------------- /topon/src/main/res/values-v19/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 26 | 27 | -------------------------------------------------------------------------------- /topon/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FD3765 4 | #FFFFFF 5 | 6 | -------------------------------------------------------------------------------- /topon/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 25 | 28 | 29 | --------------------------------------------------------------------------------