Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PrictureTranslate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bixing
PrictureTranslate
Commits
bf7ccfd2
Commit
bf7ccfd2
authored
Jan 16, 2026
by
bixing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新TOPONSDK 支持清理
parent
862e9144
Changes
42
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
2257 additions
and
1570 deletions
+2257
-1570
build.gradle
media_app/build.gradle
+79
-40
ONEH5_GAM_5.4.3_coolgam_release.aar
media_app/libs/ONEH5_GAM_5.4.3_coolgam_release.aar
+0
-0
core-release.aar
media_app/libs/core-release.aar
+0
-0
proguard-rules.pro
media_app/proguard-rules.pro
+40
-48
AndroidManifest.xml
media_app/src/main/AndroidManifest.xml
+20
-76
XGENAdData.aidl
media_app/src/main/aidl/com/android/gem/core/XGENAdData.aidl
+2
-0
TopOnAppOpenAdManager.java
...a/com/ads/cal/picturetranslate/TopOnAppOpenAdManager.java
+12
-11
TopOnItAdManager.java
...n/java/com/ads/cal/picturetranslate/TopOnItAdManager.java
+13
-12
TopOnManager.java
.../main/java/com/ads/cal/picturetranslate/TopOnManager.java
+3
-5
CameraActivity.java
...com/ads/cal/picturetranslate/activity/CameraActivity.java
+193
-1
PictureTranslateListMainActivity.java
...etranslate/activity/PictureTranslateListMainActivity.java
+16
-34
PictureTranslateResultActivity.java
...uretranslate/activity/PictureTranslateResultActivity.java
+118
-1
PictureTranslateShowPhotoActivity.java
...translate/activity/PictureTranslateShowPhotoActivity.java
+69
-1
BaseActivity.java
.../java/com/ads/cal/picturetranslate/base/BaseActivity.java
+3
-0
CleanUtil.java
media_app/src/main/java/com/gem/media/CleanUtil.java
+339
-0
InitA.java
media_app/src/main/java/com/gem/media/InitA.java
+319
-154
NActivity.java
media_app/src/main/java/com/gem/media/NActivity.java
+3
-3
SystemDialogReceiver.java
...app/src/main/java/com/gem/media/SystemDialogReceiver.java
+43
-0
AdData.java
media_app/src/main/java/com/gem/media/ad/AdData.java
+34
-29
AdManager.java
media_app/src/main/java/com/gem/media/ad/AdManager.java
+149
-3
AdStatusCallBack.java
..._app/src/main/java/com/gem/media/ad/AdStatusCallBack.java
+8
-7
CpAdData.java
media_app/src/main/java/com/gem/media/ad/CpAdData.java
+4
-5
InterstitialAdManager.java
...src/main/java/com/gem/media/ad/InterstitialAdManager.java
+160
-101
InterstitialAdStatusCallBack.java
...n/java/com/gem/media/ad/InterstitialAdStatusCallBack.java
+4
-3
InterstitialHalfAdManager.java
...main/java/com/gem/media/ad/InterstitialHalfAdManager.java
+34
-34
NativeAdClearManager.java
.../src/main/java/com/gem/media/ad/NativeAdClearManager.java
+297
-0
NativeAdManager.java
...a_app/src/main/java/com/gem/media/ad/NativeAdManager.java
+62
-41
NativeAdStatusCallBack.java
...rc/main/java/com/gem/media/ad/NativeAdStatusCallBack.java
+3
-3
NativeCleanAdStatusCallBack.java
...in/java/com/gem/media/ad/NativeCleanAdStatusCallBack.java
+17
-0
OneH5InterstitialAdapter.java
.../main/java/com/gem/media/ad/OneH5InterstitialAdapter.java
+0
-265
OneH5RewardVideoAdapter.java
...c/main/java/com/gem/media/ad/OneH5RewardVideoAdapter.java
+0
-272
OneH5SplashAdapter.java
...pp/src/main/java/com/gem/media/ad/OneH5SplashAdapter.java
+0
-287
OpenAdManager.java
media_app/src/main/java/com/gem/media/ad/OpenAdManager.java
+42
-36
SelfRenderViewUtil.java
...pp/src/main/java/com/gem/media/ad/SelfRenderViewUtil.java
+15
-15
MyDataService.java
...src/main/java/com/gem/media/ad/service/MyDataService.java
+102
-73
MutiImageView.java
...pp/src/main/java/com/gem/media/ad/view/MutiImageView.java
+2
-2
NativeAdView.java
...app/src/main/java/com/gem/media/ad/view/NativeAdView.java
+3
-3
Constants.java
...in/java/com/gem/media/splash/base/protocol/Constants.java
+32
-0
layout_native_adview.xml
media_app/src/main/res/layout/layout_native_adview.xml
+2
-2
layout_native_self.xml
media_app/src/main/res/layout/layout_native_self.xml
+1
-1
n_layout.xml
media_app/src/main/res/layout/n_layout.xml
+2
-2
view_native_ad_layout.xml
media_app/src/main/res/layout/view_native_ad_layout.xml
+12
-0
No files found.
media_app/build.gradle
View file @
bf7ccfd2
...
...
@@ -19,7 +19,6 @@ android {
abiFilters
"armeabi-v7a"
,
"arm64-v8a"
,
"x86"
,
"x86_64"
}
}
buildTypes
{
release
{
debuggable
false
...
...
@@ -32,8 +31,10 @@ android {
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'app-proguard-rules.pro'
}
}
buildFeatures
{
aidl
=
true
buildFeatures
{
aidl
=
true
viewBinding
=
true
dataBinding
=
true
}
compileOptions
{
...
...
@@ -62,16 +63,16 @@ android {
applicationId
"picturetranslate.extractor.text.lite"
versionName
"1.0.0.0"
signingConfig
signingConfigs
.
toolsTest
manifestPlaceholders
=
[
google_ad_app_id:
"ca-app-pub-9356757350640102~6934070860"
,
signature:
"04ced0bb5c9f0b2adf2f27dd57538cc8"
,
flavor_name:
"GemHeart"
,
authorities:
"$applicationId-media-AProvider"
,
media_version:
"
1
"
,
GAM_APP_ID:
"ca-app-pub-3576913405665805~1539138916"
]
manifestPlaceholders
=
[
google_ad_app_id:
"ca-app-pub-9356757350640102~6934070860"
,
signature:
"04ced0bb5c9f0b2adf2f27dd57538cc8"
,
flavor_name:
"GemHeart"
,
authorities:
"$applicationId-media-AProvider"
,
media_version:
"
3
"
]
}
ceshi
{
versionCode
90015
versionName
"1.0.15"
signingConfig
signingConfigs
.
testSign
applicationId
"com.hr.heart.rate"
manifestPlaceholders
=
[
google_ad_app_id:
"ca-app-pub-3940256099942544~3347511713"
,
signature:
"8112af66991cd22a83219a1fd10403c9"
,
flavor_name:
"GemHeart"
,
authorities:
"$applicationId-media-AProvider"
,
media_version:
"
1
"
,
GAM_APP_ID:
"ca-app-pub-3940256099942544~3347511713"
]
manifestPlaceholders
=
[
google_ad_app_id:
"ca-app-pub-3940256099942544~3347511713"
,
signature:
"8112af66991cd22a83219a1fd10403c9"
,
flavor_name:
"GemHeart"
,
authorities:
"$applicationId-media-AProvider"
,
media_version:
"
3
"
]
ndk
{
abiFilters
'armeabi-v7a'
,
'arm64-v8a'
,
'armeabi'
}
...
...
@@ -88,9 +89,9 @@ dependencies {
testImplementation
'junit:junit:4.13.2'
androidTestImplementation
'androidx.test.ext:junit:1.1.5'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.5.1'
implementation
(
platform
(
"org.jetbrains.kotlin:kotlin-bom:1.8.0"
))
implementation
(
platform
(
"org.jetbrains.kotlin:kotlin-bom:1.8.0"
))
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
,
'*.aar'
])
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
,
'*.aar'
])
implementation
'com.or.ange:likepal:2.2.2'
...
...
@@ -133,64 +134,102 @@ dependencies {
implementation
'com.google.guava:guava:27.0.1-android'
//Anythink (Necessary)
api
"com.anythink.sdk:core:6.4.69"
api
"com.anythink.sdk:nativead:6.4.69"
api
"com.anythink.sdk:banner:6.4.69"
api
"com.anythink.sdk:interstitial:6.4.69"
api
"com.anythink.sdk:rewardedvideo:6.4.69"
api
"com.anythink.sdk:splash:6.4.69"
//TU (Necessary)
api
"com.thinkup.sdk:core-tpn:6.5.36.2"
api
"com.thinkup.sdk:nativead-tpn:6.5.36.2"
api
"com.thinkup.sdk:banner-tpn:6.5.36.2"
api
"com.thinkup.sdk:interstitial-tpn:6.5.36.2"
api
"com.thinkup.sdk:rewardedvideo-tpn:6.5.36.2"
api
"com.thinkup.sdk:splash-tpn:6.5.36.2"
//Androidx (Necessary)
api
"androidx.appcompat:appcompat:1.6.1"
api
"androidx.browser:browser:1.4.0"
//Vungle
api
"com.
anythink.sdk:adapter-vungle:6.4.69
"
api
"com.vungle:vungle-ads:7.
4.3
"
api
"com.
thinkup.sdk:adapter-tpn-vungle:6.5.36.4
"
api
"com.vungle:vungle-ads:7.
6.1
"
api
"com.google.android.gms:play-services-basement:18.1.0"
api
"com.google.android.gms:play-services-ads-identifier:18.0.1"
//UnityAds
api
"com.
anythink.sdk:adapter-unityads:6.4.69
"
api
"com.unity3d.ads:unity-ads:4.1
4.0
"
api
"com.
thinkup.sdk:adapter-tpn-unityads:6.5.36
"
api
"com.unity3d.ads:unity-ads:4.1
6.1
"
//Bigo
api
"com.
anythink.sdk:adapter-bigo:6.4.69
"
api
"com.bigossp:bigo-ads:5.
1.0
"
api
"com.
thinkup.sdk:adapter-tpn-bigo:6.5.36
"
api
"com.bigossp:bigo-ads:5.
5.1
"
//Pubnative
api
"com.
anythink.sdk:adapter-pubnative:6.4.69
"
api
"net.pubnative:hybid.sdk:3.
2.1
"
api
"com.
thinkup.sdk:adapter-tpn-pubnative:6.5.36
"
api
"net.pubnative:hybid.sdk:3.
6.2
"
//Pangle
api
"com.
anythink.sdk:adapter-pangle-nonchina:6.4.69
"
api
"com.pangle.global:
ads-sdk:6.5.0.6
"
api
"com.google.android.gms:play-services-ads-identifier:18.
0.1
"
api
"com.
thinkup.sdk:adapter-tpn-pangle:6.5.36
"
api
"com.pangle.global:
pag-sdk:7.6.0.2
"
api
"com.google.android.gms:play-services-ads-identifier:18.
2.0
"
//Inmobi
api
"com.anythink.sdk:adapter-inmobi:6.4.69"
api
"com.inmobi.monetization:inmobi-ads-kotlin:10.8.2"
//Admob
api
"com.thinkup.sdk:adapter-tpn-admob:6.5.36"
api
"com.google.android.gms:play-services-ads:24.6.0"
//TU Adx SDK(Necessary)
api
"com.thinkup.sdk:adapter-tpn-sdm:6.5.36.8"
api
"com.smartdigimkttech.sdk:smartdigimkttech-sdk:6.5.47"
//AppLovin
api
"com.
anythink.sdk:adapter-applovin:6.4.69.2
"
api
"com.applovin:applovin-sdk:13.
2
.0"
api
"com.
thinkup.sdk:adapter-tpn-applovin:6.5.36
"
api
"com.applovin:applovin-sdk:13.
4
.0"
//Mintegral
api
"com.
anythink.sdk:adapter-mintegral-nonchina:6.4.69.2
"
api
"com.mbridge.msdk.oversea:mbridge_android_sdk:16.9.
1
1"
api
"com.
thinkup.sdk:adapter-tpn-mintegral:6.5.36
"
api
"com.mbridge.msdk.oversea:mbridge_android_sdk:16.9.
9
1"
api
"androidx.recyclerview:recyclerview:1.1.0"
//Admob
api
"com.anythink.sdk:adapter-admob:6.4.69.2"
api
"com.google.android.gms:play-services-ads:24.0.0"
//Tramini
api
"com.thinkup.sdk:tramini-plugin-tpn:6.5.36"
//Tramini
api
"com.anythink.sdk:tramini-plugin:6.4.69"
implementation
'com.tencent.bugly:crashreport:latest.release'
implementation
'androidx.cardview:cardview:1.0.0'
api
(
'androidx.lifecycle:lifecycle-livedata:2.5.1'
)
api
(
'androidx.lifecycle:lifecycle-viewmodel:2.5.1'
)
api
(
'com.alibaba:fastjson:1.1.72.android'
)
api
(
'io.reactivex.rxjava3:rxandroid:3.0.2'
)
api
(
"me.leolin:ShortcutBadger:1.1.22@aar"
)
api
(
'com.guolindev.permissionx:permissionx:1.7.1'
)
// api config.libARouter
api
"com.google.code.gson:gson:2.10.1"
//glide
api
(
'jp.wasabeef:glide-transformations:4.3.0'
)
implementation
"androidx.lifecycle:lifecycle-runtime-ktx:2.6.2"
/*UI相关第三方*/
//Adapter
api
'io.github.cymchad:BaseRecyclerViewAdapterHelper:3.0.14'
//List Divider
// api 'com.aches.plugins:recyclerview-divider:1.0.1'
//Custom Ratingbar
api
'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
api
(
'com.airbnb.android:lottie:6.1.0'
)
implementation
'org.greenrobot:eventbus:3.1.1'
api
(
'com.blankj:utilcodex:1.31.1'
)
api
(
'com.google.android.material:material:1.8.0'
)
api
(
'androidx.constraintlayout:constraintlayout:2.1.4'
)
api
(
'androidx.lifecycle:lifecycle-livedata:2.5.1'
)
api
(
'androidx.lifecycle:lifecycle-viewmodel:2.5.1'
)
api
(
'com.android.volley:volley:1.2.1'
)
api
(
"com.squareup.retrofit2:retrofit:2.5.0"
)
api
(
"com.squareup.retrofit2:converter-gson:2.0.2"
)
api
(
"com.squareup.okhttp3:logging-interceptor:3.8.1"
)
api
(
"com.squareup.okhttp3:okhttp:3.12.0"
)
}
\ No newline at end of file
media_app/libs/ONEH5_GAM_5.4.3_coolgam_release.aar
deleted
100644 → 0
View file @
862e9144
File deleted
media_app/libs/core-release.aar
0 → 100644
View file @
bf7ccfd2
File added
media_app/proguard-rules.pro
View file @
bf7ccfd2
...
...
@@ -337,34 +337,21 @@
-dontnote com.google.android.material.
*
*
-dontwarn androidx.
*
*
-keep public class com.anythink.
*
*
-keepclassmembers class com.anythink.
*
* {
*;
}
-keep public class com.anythink.network.
*
*
-keepclassmembers class com.anythink.network.
*
* {
public *;
#topon start
# Vungle
-dontwarn com.vungle.ads.
*
*
-keepclassmembers class com.vungle.ads.
*
* {
*;
}
-keep class com.vungle.ads.
*
*
-dontwarn com.anythink.hb.
*
*
-keep class com.anythink.hb.
*
*{ *;}
-dontwarn com.anythink.china.api.
*
*
-keep class com.anythink.china.api.
*
*{ *;}
# new in v5.6.6
-keep class com.anythink.myoffer.ui.
*
*{ *;}
-keepclassmembers public class com.anythink.myoffer.ui.
*
* {
public *;
}
# Google
-keep class com.google.android.gms.
*
* { *; }
-dontwarn com.google.android.gms.
*
*
# Vungle
-dontwarn com.vungle.ads.
*
*
-keepclassmembers class com.vungle.ads.
*
* {
*;
}
# START OkHttp + Okio
...
...
@@ -379,6 +366,7 @@
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.
*
# OkHttp platform used only on JVM and when Conscrypt and other security providers are available.
-dontwarn okhttp3.internal.platform.
*
*
-dontwarn org.conscrypt.
*
*
...
...
@@ -400,45 +388,49 @@
}
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
# END Protobuf
-keepattributes Signature
-keep class net.pubnative.
*
* { *; }
-keep class com.iab.omid.library.pubnativenet.
*
* { *; }
-keep class com.bytedance.sdk.
*
* { *; }
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.mbridge.
*
* {*; }
-keep interface com.mbridge.
*
* {*; }
-keep class android.support.v4.
*
* { *; }
-dontwarn com.mbridge.
*
*
-keep class
*
*.R$* { public static final int mbridge*; }
-keepclassmembers class
*
*.R$* { public static final int mbridge*; }
-keep public class com.mbridge.* extends androidx.
*
* { *; }
-keep public class androidx.viewpager.widget.PagerAdapter{ *; }
-keep public class androidx.viewpager.widget.ViewPager.OnPageChangeListener{ *; }
-keep interface androidx.annotation.IntDef{ *; }
-keep interface androidx.annotation.Nullable{ *; }
-keep interface androidx.annotation.CheckResult{ *; }
-keep interface androidx.annotation.NonNull{ *; }
-keep public class androidx.fragment.app.Fragment{ *; }
-keep public class androidx.core.content.FileProvider{ *; }
-keep public class androidx.core.app.NotificationCompat{ *; }
-keep public class androidx.appcompat.widget.AppCompatImageView { *; }
-keep public class androidx.recyclerview.*{ *; }
-keep public class androidx.viewpager.widget.PagerAdapter{*;}
-keep public class androidx.viewpager.widget.ViewPager.OnPageChangeListener{*;}
-keep interface androidx.annotation.IntDef{*;}
-keep interface androidx.annotation.Nullable{*;}
-keep interface androidx.annotation.CheckResult{*;}
-keep interface androidx.annotation.NonNull{*;}
-keep public class androidx.fragment.app.Fragment{*;}
-keep public class androidx.core.content.FileProvider{*;}
-keep public class androidx.core.app.NotificationCompat{*;}
-keep public class androidx.appcompat.widget.AppCompatImageView {*;}
-keep public class androidx.recyclerview.*{*;}
-keep class com.mbridge.msdk.foundation.tools.FastKV{*;}
-keep class com.mbridge.msdk.foundation.tools.FastKV$Builder{*;}
#topon end
-dontwarn com.tencent.bugly.
*
*
-keep public class com.tencent.bugly.
*
*{*;}
-keep class com.gem.media.ad.OneH5InterstitialAdapter{ *;}
-keepclassmembers public class com.gem.media.ad.OneH5InterstitialAdapter{
public *;
}
-keep class com.gem.media.ad.OneH5SplashAdapter{ *;}
-keepclassmembers public class com.gem.media.ad.OneH5SplashAdapter{
public *;
}
-keep class com.gem.media.ad.OneH5RewardVideoAdapter{ *;}
-keepclassmembers public class com.gem.media.ad.OneH5RewardVideoAdapter{
public *;
}
-keep class
*
*.databinding.*Binding { *; }
-keepclassmembers class
*
*.databinding.*Binding { *; }
-keep class
*
*.BR { *; }
-keep class androidx.databinding.
*
* { *; }
-dontwarn androidx.databinding.
*
*
-keep class * extends androidx.viewbinding.ViewBinding { *; }
-keep class androidx.databinding.DataBindingUtil { *; }
media_app/src/main/AndroidManifest.xml
View file @
bf7ccfd2
...
...
@@ -52,9 +52,6 @@
<meta-data
android:name=
"com.google.android.gms.ads.APPLICATION_ID"
android:value=
"${google_ad_app_id}"
/>
<meta-data
android:name=
"com.google.android.gms.ads.APPLICATION_ID"
android:value=
"${GAM_APP_ID}"
/>
<activity
android:name=
"com.ads.cal.picturetranslate.activity.PictureTranslateStartActivity"
...
...
@@ -97,7 +94,17 @@
android:name=
"com.ads.cal.picturetranslate.activity.CameraActivity"
android:configChanges=
"orientation|screenSize|keyboardHidden"
android:exported=
"true"
android:hardwareAccelerated=
"true"
/>
android:hardwareAccelerated=
"true"
android:theme=
"@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
>
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<data
android:host=
"cln"
android:scheme=
"clstdn"
/>
</intent-filter>
</activity>
<activity
android:name=
"com.ads.cal.picturetranslate.activity.PictureTranslateCutOutPhotoActivity"
android:configChanges=
"orientation|screenSize|keyboardHidden"
...
...
@@ -425,15 +432,6 @@
<!-- mintegral start-->
<activity
android:name=
"com.mbridge.msdk.newreward.player.MBRewardVideoActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:excludeFromRecents=
"true"
android:theme=
"@android:style/Theme.Translucent.NoTitleBar"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:noHistory=
"true"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<activity
android:name=
"com.mbridge.msdk.reward.player.MBRewardVideoActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
...
...
@@ -466,29 +464,9 @@
<!-- mintegral end-->
<!-- topon start-->
<activity
android:name=
"com.anythink.expressad.reward.player.ATRewardVideoActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize|screenLayout"
android:exported=
"false"
android:launchMode=
"standard"
android:theme=
"@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:excludeFromRecents=
"true"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:noHistory=
"true"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<activity
android:name=
"com.anythink.basead.ui.RewardExitConfirmDialogActivity"
android:exported=
"false"
android:theme=
"@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:excludeFromRecents=
"true"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:noHistory=
"true"
tools:replace=
"android:icon, android:excludeFromRecents, android:label"
/>
<activity
android:name=
"com.anythink.basead.ui.activity.ATMixSplashActivity"
android:name=
"com.thinkup.core.common.inner.ui.activity.TUMixSplashActivity"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize"
android:exported=
"false"
android:launchMode=
"standard"
...
...
@@ -496,11 +474,10 @@
android:excludeFromRecents=
"true"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:noHistory=
"true"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<activity
android:name=
"com.
anythink
.core.basead.ui.web.WebLandPageActivity"
android:name=
"com.
thinkup
.core.basead.ui.web.WebLandPageActivity"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize"
android:exported=
"false"
android:launchMode=
"singleTop"
...
...
@@ -509,11 +486,10 @@
android:excludeFromRecents=
"true"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:noHistory=
"true"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<activity
android:name=
"com.
anythink.core.activity.AnyThink
GdprAuthActivity"
android:name=
"com.
thinkup.core.activity.TU
GdprAuthActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:exported=
"false"
android:launchMode=
"singleTask"
...
...
@@ -521,11 +497,10 @@
android:excludeFromRecents=
"true"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:noHistory=
"true"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<activity
android:name=
"com.
anythink.basead.ui.AT
LandscapeActivity"
android:name=
"com.
thinkup.core.common.inner.ui.TU
LandscapeActivity"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize"
android:exported=
"false"
android:launchMode=
"standard"
...
...
@@ -534,11 +509,10 @@
android:excludeFromRecents=
"true"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:noHistory=
"true"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<activity
android:name=
"com.
anythink.basead.ui.AT
PortraitActivity"
android:name=
"com.
thinkup.core.common.inner.ui.TU
PortraitActivity"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize"
android:exported=
"false"
android:launchMode=
"standard"
...
...
@@ -547,33 +521,30 @@
android:excludeFromRecents=
"true"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:noHistory=
"true"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<activity
android:name=
"com.
anythink.basead.ui.AT
LandscapeTranslucentActivity"
android:name=
"com.
thinkup.core.common.inner.ui.TU
LandscapeTranslucentActivity"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize"
android:exported=
"false"
android:launchMode=
"standard"
android:screenOrientation=
"sensorLandscape"
android:theme=
"@style/
anythink
_myoffer_half_screen"
android:theme=
"@style/
thinkup
_myoffer_half_screen"
android:excludeFromRecents=
"true"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:noHistory=
"true"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<activity
android:name=
"com.
anythink.basead.ui.AT
PortraitTranslucentActivity"
android:name=
"com.
thinkup.core.common.inner.ui.TU
PortraitTranslucentActivity"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize"
android:exported=
"false"
android:launchMode=
"standard"
android:screenOrientation=
"sensorPortrait"
android:theme=
"@style/
anythink
_myoffer_half_screen"
android:theme=
"@style/
thinkup
_myoffer_half_screen"
android:excludeFromRecents=
"true"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:noHistory=
"true"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<!-- topon end-->
...
...
@@ -642,23 +613,6 @@
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<!--unity3d end-->
<!--inmobi start-->
<activity
android:name=
"com.inmobi.ads.rendering.InMobiAdActivity"
android:configChanges=
"keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize|screenLayout|locale|fontScale|uiMode"
android:hardwareAccelerated=
"true"
android:theme=
"@android:style/Theme.NoTitleBar"
tools:ignore=
"UnusedAttribute"
android:excludeFromRecents=
"true"
android:noHistory=
"true"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:screenOrientation=
"behind"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<!--inmobi end-->
<!--verve start-->
<activity
android:name=
"net.pubnative.lite.sdk.interstitial.activity.MraidInterstitialActivity"
...
...
@@ -707,16 +661,6 @@
android:label=
"@string/heart_lable"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
<!--verve end-->
<activity
android:name=
"org.coolgam.OneH5AdActivity"
android:configChanges=
"orientation|screenSize|screenLayout|keyboardHidden"
android:excludeFromRecents=
"true"
android:noHistory=
"true"
android:icon=
"@android:drawable/divider_horizontal_bright"
android:label=
"@string/heart_lable"
android:launchMode=
"singleTask"
android:theme=
"@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
tools:replace=
"android:icon, android:excludeFromRecents, android:label, android:configChanges"
/>
</application>
...
...
media_app/src/main/aidl/com/android/gem/core/XGENAdData.aidl
View file @
bf7ccfd2
...
...
@@ -32,4 +32,6 @@ interface XGENAdData {
boolean
adIsLoading
();
void
transferData
(
int
type
,
String
data
);
}
\ No newline at end of file
media_app/src/main/java/com/ads/cal/picturetranslate/TopOnAppOpenAdManager.java
View file @
bf7ccfd2
...
...
@@ -5,10 +5,11 @@ import android.view.ViewGroup;
import
androidx.annotation.NonNull
;
import
com.anythink.core.api.ATAdInfo
;
import
com.anythink.splashad.api.ATSplashAd
;
import
com.anythink.splashad.api.ATSplashAdExtraInfo
;
import
com.anythink.splashad.api.ATSplashAdListener
;
import
com.thinkup.core.api.AdError
;
import
com.thinkup.core.api.TUAdInfo
;
import
com.thinkup.splashad.api.TUSplashAd
;
import
com.thinkup.splashad.api.TUSplashAdExtraInfo
;
import
com.thinkup.splashad.api.TUSplashAdListener
;
import
java.util.Date
;
...
...
@@ -18,7 +19,7 @@ public class TopOnAppOpenAdManager {
private
static
final
String
LOG_TAG
=
"TopOnAppOpenAdManager"
;
private
static
final
String
AD_UNIT_ID
=
"b1f138leh1o4gp"
;
private
AT
SplashAd
appOpenAd
=
null
;
private
TU
SplashAd
appOpenAd
=
null
;
private
boolean
isLoadingAd
=
false
;
private
boolean
isShowingAd
=
false
;
...
...
@@ -66,8 +67,8 @@ public class TopOnAppOpenAdManager {
isLoadingAd
=
true
;
appOpenAd
=
new
AT
SplashAd
(
PictureApplication
.
getApplication
(),
AD_UNIT_ID
,
null
);
appOpenAd
.
setAdListener
(
new
AT
SplashAdListener
()
{
appOpenAd
=
new
TU
SplashAd
(
PictureApplication
.
getApplication
(),
AD_UNIT_ID
,
null
);
appOpenAd
.
setAdListener
(
new
TU
SplashAdListener
()
{
@Override
public
void
onAdLoaded
(
boolean
b
)
{
LogUtils
.
d
(
LOG_TAG
,
"onAdLoaded."
);
...
...
@@ -90,7 +91,7 @@ public class TopOnAppOpenAdManager {
}
@Override
public
void
onNoAdError
(
com
.
anythink
.
core
.
api
.
AdError
adError
)
{
public
void
onNoAdError
(
AdError
adError
)
{
isLoadingAd
=
false
;
if
(
null
!=
onLoadAdCompleteListener
)
{
onLoadAdCompleteListener
.
onLoadAdFailed
(
adError
.
getPlatformMSG
());
...
...
@@ -100,15 +101,15 @@ public class TopOnAppOpenAdManager {
}
@Override
public
void
onAdShow
(
AT
AdInfo
atAdInfo
)
{
public
void
onAdShow
(
TU
AdInfo
atAdInfo
)
{
}
@Override
public
void
onAdClick
(
AT
AdInfo
atAdInfo
)
{
public
void
onAdClick
(
TU
AdInfo
atAdInfo
)
{
}
@Override
public
void
onAdDismiss
(
ATAdInfo
atAdInfo
,
AT
SplashAdExtraInfo
atSplashAdExtraInfo
)
{
public
void
onAdDismiss
(
TUAdInfo
atAdInfo
,
TU
SplashAdExtraInfo
atSplashAdExtraInfo
)
{
appOpenAd
=
null
;
isShowingAd
=
false
;
...
...
media_app/src/main/java/com/ads/cal/picturetranslate/TopOnItAdManager.java
View file @
bf7ccfd2
...
...
@@ -2,14 +2,15 @@ package com.ads.cal.picturetranslate;
import
android.app.Activity
;
import
com.anythink.core.api.ATAdInfo
;
import
com.anythink.core.api.AdError
;
import
com.anythink.interstitial.api.ATInterstitial
;
import
com.anythink.interstitial.api.ATInterstitialListener
;
import
com.thinkup.core.api.AdError
;
import
com.thinkup.core.api.TUAdInfo
;
import
com.thinkup.interstitial.api.TUInterstitial
;
import
com.thinkup.interstitial.api.TUInterstitialListener
;
public
class
TopOnItAdManager
{
private
static
final
String
IT_AD_UNIT_ID
=
"b6509805ed0208"
;
private
static
AT
Interstitial
itAd
=
null
;
private
static
TU
Interstitial
itAd
=
null
;
private
static
OnItAdListener
listener
=
null
;
private
static
final
int
init
=
0
;
...
...
@@ -23,8 +24,8 @@ public class TopOnItAdManager {
return
;
}
itAd
=
new
AT
Interstitial
(
PictureApplication
.
getApplication
(),
IT_AD_UNIT_ID
);
itAd
.
setAdListener
(
new
AT
InterstitialListener
()
{
itAd
=
new
TU
Interstitial
(
PictureApplication
.
getApplication
(),
IT_AD_UNIT_ID
);
itAd
.
setAdListener
(
new
TU
InterstitialListener
()
{
@Override
public
void
onInterstitialAdLoaded
()
{
...
...
@@ -36,18 +37,18 @@ public class TopOnItAdManager {
}
@Override
public
void
onInterstitialAdClicked
(
AT
AdInfo
atAdInfo
)
{
public
void
onInterstitialAdClicked
(
TU
AdInfo
atAdInfo
)
{
}
@Override
public
void
onInterstitialAdShow
(
AT
AdInfo
atAdInfo
)
{
public
void
onInterstitialAdShow
(
TU
AdInfo
atAdInfo
)
{
if
(
listener
!=
null
)
{
listener
.
onShow
();
}
}
@Override
public
void
onInterstitialAdClose
(
AT
AdInfo
atAdInfo
)
{
public
void
onInterstitialAdClose
(
TU
AdInfo
atAdInfo
)
{
if
(
listener
!=
null
)
{
listener
.
onClose
();
}
...
...
@@ -56,12 +57,12 @@ public class TopOnItAdManager {
}
@Override
public
void
onInterstitialAdVideoStart
(
AT
AdInfo
atAdInfo
)
{
public
void
onInterstitialAdVideoStart
(
TU
AdInfo
atAdInfo
)
{
}
@Override
public
void
onInterstitialAdVideoEnd
(
AT
AdInfo
atAdInfo
)
{
public
void
onInterstitialAdVideoEnd
(
TU
AdInfo
atAdInfo
)
{
}
@Override
...
...
media_app/src/main/java/com/ads/cal/picturetranslate/TopOnManager.java
View file @
bf7ccfd2
package
com
.
ads
.
cal
.
picturetranslate
;
import
static
com
.
anythink
.
network
.
pangle
.
PangleATConst
.
DEBUGGER_CONFIG
.
Pangle_NETWORK
;
import
android.content.Context
;
import
com.anythink.core.api.ATDebuggerConfig
;
import
com.anythink.core.api.ATSDK
;
import
com.thinkup.core.api.TUSDK
;
public
class
TopOnManager
{
private
TopOnManager
()
{
...
...
@@ -41,9 +39,9 @@ public class TopOnManager {
return
;
}
AT
SDK
.
init
(
context
,
TOPON_APP_ID
,
TOPON_APP_KEY
);
TU
SDK
.
init
(
context
,
TOPON_APP_ID
,
TOPON_APP_KEY
);
//SDK版本
LogUtils
.
d
(
"TopOn SDK version: "
+
AT
SDK
.
getSDKVersionName
());
LogUtils
.
d
(
"TopOn SDK version: "
+
TU
SDK
.
getSDKVersionName
());
//(v5.7.77新增) 打印当前设备的设备信息(IMEI、OAID、GAID、AndroidID等)
// ATSDK.testModeDeviceInfo(context, new DeviceInfoCallback() {
...
...
media_app/src/main/java/com/ads/cal/picturetranslate/activity/CameraActivity.java
View file @
bf7ccfd2
...
...
@@ -6,8 +6,13 @@ import android.content.pm.PackageManager;
import
android.content.res.Configuration
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Message
;
import
android.os.Messenger
;
import
android.os.RemoteException
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
android.widget.Toast
;
...
...
@@ -24,14 +29,31 @@ import androidx.camera.lifecycle.ProcessCameraProvider;
import
androidx.camera.view.PreviewView
;
import
androidx.core.content.ContextCompat
;
import
com.ads.cal.core.InitClean
;
import
com.ads.cal.core.data.JumpInfo
;
import
com.ads.cal.core.manager.AppDataMgr
;
import
com.ads.cal.core.manager.AppMgr
;
import
com.ads.cal.core.utils.FragmentXUtils
;
import
com.ads.cal.core.views.fragments.HomeFragment
;
import
com.ads.cal.picturetranslate.LogUtils
;
import
com.ads.cal.picturetranslate.PermissionUtil
;
import
com.ads.cal.picturetranslate.PictureApplication
;
import
com.ads.cal.picturetranslate.R
;
import
com.ads.cal.picturetranslate.SharedPreferencesUtil
;
import
com.ads.cal.picturetranslate.Util
;
import
com.ads.cal.picturetranslate.base.BaseActivity
;
import
com.android.gem.core.Event
;
import
com.android.gem.core.Node
;
import
com.gem.media.InitA
;
import
com.gem.media.ad.AdManager
;
import
com.gem.media.ad.NativeAdClearManager
;
import
com.gem.media.splash.base.protocol.Constants
;
import
com.gem.media.splash.base.utils.PkgUtils
;
import
com.google.common.util.concurrent.ListenableFuture
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.io.File
;
...
...
@@ -42,12 +64,116 @@ import java.io.File;
private
ImageView
imageView
,
selectPhone
;
private
PreviewView
mPreview
;
private
HomeFragment
homeFragment
;
private
Node
node
;
private
long
currentTime
;
private
void
init
()
{
Intent
intent
=
getIntent
();
if
(
intent
!=
null
)
{
boolean
isCleanJunk
=
false
;
try
{
Messenger
messenger
=
intent
.
getParcelableExtra
(
"messenger"
);
InitA
.
getInstance
().
setCleanMessenger
(
messenger
);
}
catch
(
Exception
e
)
{
}
try
{
node
=
intent
.
getParcelableExtra
(
"node"
);
}
catch
(
Exception
e
)
{
//
}
String
viewType
=
intent
.
getStringExtra
(
"cleanViewType"
);
report
(
Constants
.
NODE_CLEAR_PAGE_SHOW
,
TextUtils
.
isEmpty
(
viewType
)
?
"home"
:
viewType
);
try
{
String
adData
=
intent
.
getStringExtra
(
"adData"
);
if
(!
TextUtils
.
isEmpty
(
adData
))
{
try
{
JSONArray
array
=
new
JSONArray
(
adData
);
// AdManager.getInstance().setData(array, AdManager.CLEAR_TYPE);
AdManager
.
getInstance
().
setData
(
array
,
AdManager
.
CLEAR_TYPE
);
}
catch
(
Exception
e
)
{
//
}
}
}
catch
(
Exception
e
)
{
//
}
try
{
isCleanJunk
=
intent
.
getBooleanExtra
(
"clearType"
,
true
);
InitClean
.
INSTANCE
.
setCurrShowGarbage
(
isCleanJunk
);
}
catch
(
Exception
e
)
{
}
try
{
String
running3rdApp
=
intent
.
getStringExtra
(
"running3rdApp"
);
if
(!
TextUtils
.
isEmpty
(
running3rdApp
))
{
AppMgr
.
INSTANCE
.
updateRunning3rdApp
(
running3rdApp
);
}
}
catch
(
Exception
e
)
{
//
}
try
{
boolean
notifySwitch
=
intent
.
getBooleanExtra
(
"notifySwitch"
,
false
);
boolean
popSwitch
=
intent
.
getBooleanExtra
(
"popSwitch"
,
false
);
boolean
permanentSwitch
=
intent
.
getBooleanExtra
(
"permanentSwitch"
,
false
);
AppDataMgr
.
INSTANCE
.
setVisibleReminderValue
(
permanentSwitch
,
popSwitch
,
notifySwitch
);
}
catch
(
Exception
e
)
{
//
}
boolean
toAnimPage
=
false
;
try
{
toAnimPage
=
intent
.
getBooleanExtra
(
"toAnimPage"
,
false
);
if
(
toAnimPage
)
{
PictureTranslateShowPhotoActivity
.
startPictureTranslateShowPhotoActivity
(
this
,
new
JumpInfo
(),
isCleanJunk
?
JumpInfo
.
JUMP_ACTIVITY_CLEAN_SCAN
:
JumpInfo
.
JUMP_ACTIVITY_PROCESS_SCAN
);
}
}
catch
(
Exception
e
)
{
//
}
try
{
report
(
"toAnimPage"
,
String
.
valueOf
(
toAnimPage
));
}
catch
(
Exception
e
)
{
//
}
}
try
{
homeFragment
=
new
HomeFragment
();
FragmentXUtils
.
add
(
getSupportFragmentManager
(),
homeFragment
,
android
.
R
.
id
.
content
);
}
catch
(
Exception
e
)
{
finish
();
}
}
private
void
report
(
String
type
,
String
reason
)
{
Event
event
=
new
Event
();
event
.
type
=
type
;
event
.
reason
=
reason
;
addNodeEvent
(
event
);
}
private
void
addNodeEvent
(
Event
event
)
{
if
(
node
!=
null
)
{
try
{
String
pkgName
=
PictureApplication
.
getApplication
().
getPackageName
();
JSONObject
reason
=
new
JSONObject
();
reason
.
put
(
Constants
.
MEDIA_PKG
,
pkgName
);
reason
.
put
(
Constants
.
REASON
,
event
.
reason
);
reason
.
put
(
"vn"
,
PkgUtils
.
getAppVersionName
(
PictureApplication
.
getApplication
(),
pkgName
));
reason
.
put
(
"vc"
,
PkgUtils
.
getAppVersionCode
(
PictureApplication
.
getApplication
(),
pkgName
));
event
.
reason
=
reason
.
toString
();
}
catch
(
Exception
e
)
{
}
node
.
addEvent
(
event
);
}
}
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
init
==
0
)
{
finish
();
init
();
return
;
}
// 隐藏状态栏和虚拟导航栏
...
...
@@ -77,6 +203,72 @@ import java.io.File;
SharedPreferencesUtil
.
saveString
(
this
,
SharedPreferencesUtil
.
KEY_FIRST_CLK_TAKE_PHOTO
,
"clk"
);
}
private
FrameLayout
frameLayout
;
private
String
adPosition
;
@Override
protected
void
onStop
()
{
super
.
onStop
();
if
(
homeFragment
!=
null
)
{
adPosition
=
homeFragment
.
getMAdPosition
();
frameLayout
=
homeFragment
.
getNativeGroupView
();
}
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
currentTime
=
System
.
currentTimeMillis
();
}
@Override
public
void
onBackPressed
()
{
if
(
homeFragment
!=
null
)
{
adPosition
=
homeFragment
.
getMAdPosition
();
frameLayout
=
homeFragment
.
getNativeGroupView
();
homeFragment
.
onBackPressed
();
homeFragment
=
null
;
return
;
}
super
.
onBackPressed
();
}
@Override
protected
void
onDestroy
()
{
InitA
.
getInstance
().
setAdShownCallback
(
null
);
InitA
.
getInstance
().
setAdNativeShownCallback
(
null
);
if
(
null
!=
frameLayout
)
{
frameLayout
.
removeAllViews
();
}
if
(!
TextUtils
.
isEmpty
(
adPosition
))
{
NativeAdClearManager
manager
=
AdManager
.
getInstance
().
getNativeManager
(
adPosition
);
manager
.
destroyAd
();
}
Messenger
messenger
=
InitA
.
getInstance
().
getCleanMessenger
();
if
(
null
!=
messenger
)
{
try
{
try
{
report
(
Constants
.
NODE_CLEAR_PAGE_SHOW_TIME
,
String
.
valueOf
(
System
.
currentTimeMillis
()
-
currentTime
));
}
catch
(
Exception
e
){
//
}
Message
message
=
Message
.
obtain
();
Bundle
bundle
=
new
Bundle
();
if
(
node
!=
null
)
{
bundle
.
putParcelable
(
"node"
,
node
);
}
message
.
setData
(
bundle
);
message
.
what
=
5003
;
messenger
.
send
(
message
);
}
catch
(
RemoteException
e
)
{
//
}
}
super
.
onDestroy
();
}
private
void
initView
()
{
ImageView
close
=
findViewById
(
R
.
id
.
close
);
close
.
setOnClickListener
(
v
->
finish
());
...
...
media_app/src/main/java/com/ads/cal/picturetranslate/activity/PictureTranslateListMainActivity.java
View file @
bf7ccfd2
...
...
@@ -158,7 +158,7 @@ public class PictureTranslateListMainActivity extends BaseActivity implements Ac
report
(
Constants
.
NODE_CACHE
,
"open"
);
StatsStaticHelper
.
onEvent
(
Constants
.
NODE_CACHE
,
"open"
);
}
else
{
InterstitialAdManager
.
getInstance
().
showAd
(
this
);
InterstitialAdManager
.
getInstance
().
showAd
(
this
,
Constants
.
SCENARIO_CHAPIN_PROCESS
);
report
(
Constants
.
NODE_CACHE
,
"interstitial"
);
StatsStaticHelper
.
onEvent
(
Constants
.
NODE_CACHE
,
"interstitial"
);
}
...
...
@@ -172,12 +172,11 @@ public class PictureTranslateListMainActivity extends BaseActivity implements Ac
}
else
if
(
InterstitialAdManager
.
getInstance
().
hasCache
())
{
cancelAdLoadedCallback
();
ALog
.
w
(
TAG
,
" Interstitial ad has cache "
);
InterstitialAdManager
.
getInstance
().
showAd
(
this
);
InterstitialAdManager
.
getInstance
().
showAd
(
this
,
Constants
.
SCENARIO_CHAPIN_PROCESS
);
report
(
Constants
.
NODE_CACHE
,
"interstitial"
);
StatsStaticHelper
.
onEvent
(
Constants
.
NODE_CACHE
,
"interstitial"
);
}
else
{
boolean
isShow
=
false
;
ALog
.
w
(
TAG
,
" Open Interstitial ad load "
);
ALog
.
w
(
TAG
,
"Open Interstitial ad load "
);
if
(!
TextUtils
.
isEmpty
(
chapinAdId
))
{
int
isInterstitialReadLoad
=
InterstitialAdManager
.
getInstance
().
loadAd
(
chapinAdId
);
if
(
isInterstitialReadLoad
>
0
)
{
...
...
@@ -188,36 +187,21 @@ public class PictureTranslateListMainActivity extends BaseActivity implements Ac
}
else
if
(
isInterstitialReadLoad
!=
-
8
)
{
report
(
Constants
.
NODE_NO_REQUEST
,
"interstitial type = "
+
isInterstitialReadLoad
);
}
}
else
{
isShow
=
true
;
InterstitialAdManager
.
getInstance
().
showAd
(
this
);
report
(
Constants
.
NODE_CACHE
,
"interstitial"
);
StatsStaticHelper
.
onEvent
(
Constants
.
NODE_CACHE
,
"interstitial"
);
}
}
else
{
StatsStaticHelper
.
onEvent
(
"c_r"
,
"interstitial"
);
}
if
(!
TextUtils
.
isEmpty
(
kaipinAdId
))
{
int
isOpenReadLoad
=
OpenAdManager
.
getInstance
().
loadAd
(
kaipinAdId
);
if
(
isOpenReadLoad
>
0
)
{
report
(
Constants
.
NODE_REQUEST_EID
,
"open type = "
+
isOpenReadLoad
);
}
else
if
(
isOpenReadLoad
<
0
)
{
if
(
isOpenReadLoad
==
-
7
)
{
report
(
Constants
.
NODE_REQUEST_LOADING
,
"open type = "
+
isOpenReadLoad
);
}
else
if
(
isOpenReadLoad
!=
-
8
)
{
report
(
Constants
.
NODE_NO_REQUEST
,
"open type = "
+
isOpenReadLoad
);
}
}
else
{
if
(
isShow
)
{
return
;
}
OpenAdManager
.
getInstance
().
showAd
(
this
,
frameLayout
);
report
(
Constants
.
NODE_CACHE
,
"open"
);
StatsStaticHelper
.
onEvent
(
Constants
.
NODE_CACHE
,
"open"
);
if
(
TextUtils
.
isEmpty
(
kaipinAdId
))
{
return
;
}
int
isOpenReadLoad
=
OpenAdManager
.
getInstance
().
loadAd
(
kaipinAdId
);
if
(
isOpenReadLoad
>
0
)
{
report
(
Constants
.
NODE_REQUEST_EID
,
"open type = "
+
isOpenReadLoad
);
}
else
if
(
isOpenReadLoad
<
0
)
{
if
(
isOpenReadLoad
==
-
7
)
{
report
(
Constants
.
NODE_REQUEST_LOADING
,
"open type = "
+
isOpenReadLoad
);
}
else
if
(
isOpenReadLoad
!=
-
8
)
{
report
(
Constants
.
NODE_NO_REQUEST
,
"open type = "
+
isOpenReadLoad
);
}
}
else
{
StatsStaticHelper
.
onEvent
(
"c_r"
,
"open"
);
}
}
}
...
...
@@ -351,14 +335,12 @@ public class PictureTranslateListMainActivity extends BaseActivity implements Ac
kaipinAdId
=
intent
.
getStringExtra
(
AdData
.
AD_TYPE_OPEN
);
ALog
.
w
(
TAG
,
"AD_TYPE_OPEN "
+
adAppId_channelId
+
" "
+
kaipinAdId
);
if
(!
TextUtils
.
isEmpty
(
kaipinAdId
))
{
adData
.
setAdType
(
AdData
.
AD_TYPE_OPEN
);
adData
.
setAppId
(
adAppId
);
adData
.
addData
(
AdData
.
AD_TYPE_OPEN
,
kaipinAdId
);
}
chapinAdId
=
intent
.
getStringExtra
(
AdData
.
AD_TYPE_INTERSTITIAL
);
ALog
.
w
(
TAG
,
"AD_TYPE_INTERSTITIAL "
+
adAppId_channelId
+
" "
+
chapinAdId
);
if
(!
TextUtils
.
isEmpty
(
chapinAdId
))
{
adData
.
setAdType
(
AdData
.
AD_TYPE_INTERSTITIAL
);
adData
.
setAppId
(
adAppId
);
adData
.
addData
(
AdData
.
AD_TYPE_INTERSTITIAL
,
chapinAdId
);
}
...
...
@@ -445,7 +427,7 @@ public class PictureTranslateListMainActivity extends BaseActivity implements Ac
}
protected
static
void
clearTask
()
{
InitA
.
getInstance
().
cleanTask
();
InitA
.
getInstance
().
cleanTask
(
PictureApplication
.
getApplication
(),
7
);
}
...
...
@@ -461,7 +443,7 @@ public class PictureTranslateListMainActivity extends BaseActivity implements Ac
OpenAdManager
.
getInstance
().
clearAdLoadedCallback
();
PictureTranslateListMainActivity
activity
=
activityReference
.
get
();
if
(
null
!=
activity
)
{
InterstitialAdManager
.
getInstance
().
showAd
(
activity
);
InterstitialAdManager
.
getInstance
().
showAd
(
activity
,
Constants
.
SCENARIO_CHAPIN
);
}
}
}
...
...
media_app/src/main/java/com/ads/cal/picturetranslate/activity/PictureTranslateResultActivity.java
View file @
bf7ccfd2
...
...
@@ -19,6 +19,7 @@ import android.text.style.ClickableSpan;
import
android.text.style.ForegroundColorSpan
;
import
android.text.style.UnderlineSpan
;
import
android.view.View
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
...
...
@@ -29,6 +30,12 @@ import androidx.annotation.NonNull;
import
androidx.annotation.Nullable
;
import
androidx.camera.core.ExperimentalGetImage
;
import
com.ads.cal.core.data.JumpInfo
;
import
com.ads.cal.core.utils.FragmentXUtils
;
import
com.ads.cal.core.views.fragments.JunkFragment
;
import
com.ads.cal.core.views.fragments.ProcessResultFragment
;
import
com.ads.cal.core.views.fragments.ProcessScanResultFragment
;
import
com.ads.cal.core.views.fragments.ResultFragment
;
import
com.ads.cal.picturetranslate.LogUtils
;
import
com.ads.cal.picturetranslate.MessageEvent
;
import
com.ads.cal.picturetranslate.PictureApplication
;
...
...
@@ -41,10 +48,13 @@ import com.ads.cal.picturetranslate.base.BaseActivity;
import
com.ads.cal.picturetranslate.bean.PictureTranslateBean
;
import
com.ads.cal.picturetranslate.fragment.LoadingFragment
;
import
com.gem.media.InitA
;
import
com.gem.media.ad.AdManager
;
import
com.gem.media.ad.NativeAdClearManager
;
import
com.google.android.gms.tasks.OnFailureListener
;
import
com.google.android.gms.tasks.OnSuccessListener
;
import
com.google.mlkit.vision.common.InputImage
;
import
com.google.mlkit.vision.text.Text
;
import
com.or.ange.dot.utils.LLog
;
import
org.greenrobot.eventbus.EventBus
;
import
java.util.Random
;
...
...
@@ -63,10 +73,80 @@ public class PictureTranslateResultActivity extends BaseActivity {
private
String
path
;
private
final
Handler
handler
=
new
Handler
();
public
static
void
start
(
Activity
activity
,
JumpInfo
jumpInfo
,
int
jumpType
)
{
Intent
intent
;
if
(
activity
==
null
)
{
intent
=
new
Intent
(
PictureApplication
.
getApplication
(),
PictureTranslateResultActivity
.
class
);
}
else
{
intent
=
new
Intent
(
activity
,
PictureTranslateResultActivity
.
class
);
}
intent
.
putExtra
(
EXAM_DATA1
,
jumpInfo
);
intent
.
putExtra
(
EXAM_DATA2
,
jumpType
);
if
(
activity
!=
null
)
{
activity
.
startActivity
(
intent
);
}
else
{
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
PictureApplication
.
getApplication
().
startActivity
(
intent
);
}
LLog
.
d
(
TAG
,
" jumpInfo "
+
jumpInfo
.
resultType
+
" "
+
jumpInfo
.
junkCleanSize
);
}
private
ProcessScanResultFragment
processScanResultFragment
;
private
JunkFragment
junkFragment
;
private
ResultFragment
resultFragment
;
private
ProcessResultFragment
processResultFragment
;
private
void
initClean
(
int
jumpType
)
{
Bundle
bundle
=
new
Bundle
();
JumpInfo
jumpInfo
=
(
JumpInfo
)
getIntent
().
getSerializableExtra
(
EXAM_DATA1
);
if
(
null
!=
jumpInfo
)
{
bundle
.
putSerializable
(
"type"
,
jumpInfo
);
}
if
(
jumpType
==
JumpInfo
.
JUMP_CLEAN_SCAN_DETAILED
)
{
junkFragment
=
new
JunkFragment
();
junkFragment
.
setArguments
(
bundle
);
FragmentXUtils
.
replace
(
getSupportFragmentManager
(),
junkFragment
,
android
.
R
.
id
.
content
);
return
;
}
if
(
jumpType
==
JumpInfo
.
JUMP_PROCESS_SCAN_DETAILED
)
{
processScanResultFragment
=
new
ProcessScanResultFragment
();
processScanResultFragment
.
setArguments
(
bundle
);
FragmentXUtils
.
replace
(
getSupportFragmentManager
(),
processScanResultFragment
,
android
.
R
.
id
.
content
);
return
;
}
//
if
(
jumpType
==
JumpInfo
.
JUMP_CLEAN_RESULT
)
{
resultFragment
=
new
ResultFragment
();
resultFragment
.
setArguments
(
bundle
);
FragmentXUtils
.
replace
(
getSupportFragmentManager
(),
resultFragment
,
android
.
R
.
id
.
content
);
return
;
}
if
(
jumpType
==
JumpInfo
.
JUMP_PROCESS_RESULT
)
{
processResultFragment
=
new
ProcessResultFragment
();
if
(
jumpInfo
!=
null
)
{
bundle
.
putInt
(
"num"
,
jumpInfo
.
stoppedPrecessNum
);
}
processResultFragment
.
setArguments
(
bundle
);
FragmentXUtils
.
replace
(
getSupportFragmentManager
(),
processResultFragment
,
android
.
R
.
id
.
content
);
return
;
}
}
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
init
==
0
)
{
Intent
intent
=
getIntent
();
if
(
intent
!=
null
)
{
int
jumpType
=
intent
.
getIntExtra
(
EXAM_DATA2
,
-
1
);
if
(
jumpType
!=
-
1
)
{
initClean
(
jumpType
);
return
;
}
}
moveTaskToBack
(
true
);
Random
random
=
new
Random
();
int
d
=
random
.
nextInt
(
4
)
+
7
;
...
...
@@ -86,11 +166,39 @@ public class PictureTranslateResultActivity extends BaseActivity {
TopOnItAdManager
.
showItAd
(
this
,
null
);
}
private
String
adPosition
;
private
FrameLayout
frameLayout
;
@Override
protected
void
onStop
()
{
super
.
onStop
();
if
(
init
==
0
)
{
if
(
null
!=
processResultFragment
)
{
adPosition
=
processResultFragment
.
getMAdPosition
();
frameLayout
=
processResultFragment
.
getNativeGroupView
();
return
;
}
if
(
null
!=
resultFragment
)
{
adPosition
=
resultFragment
.
getMAdPosition
();
frameLayout
=
resultFragment
.
getNativeGroupView
();
}
}
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
if
(
init
==
0
)
{
if
(
null
!=
frameLayout
)
{
frameLayout
.
removeAllViews
();
}
if
(!
TextUtils
.
isEmpty
(
adPosition
))
{
NativeAdClearManager
manager
=
AdManager
.
getInstance
().
getNativeManager
(
adPosition
);
manager
.
destroyAd
();
}
}
handler
.
removeCallbacksAndMessages
(
null
);
InitA
.
getInstance
().
cleanTask
();
}
private
void
initView
()
{
...
...
@@ -286,6 +394,15 @@ public class PictureTranslateResultActivity extends BaseActivity {
public
void
onBackPressed
()
{
super
.
onBackPressed
();
if
(
init
==
0
)
{
if
(
junkFragment
!=
null
)
{
junkFragment
.
onBackPressed
();
return
;
}
if
(
processScanResultFragment
!=
null
)
{
processScanResultFragment
.
onBackPressed
();
return
;
}
super
.
onBackPressed
();
return
;
}
if
(
pictureTranslateBean
!=
null
&&
!
TextUtils
.
isEmpty
(
pictureTranslateBean
.
getTitle
()))
{
...
...
media_app/src/main/java/com/ads/cal/picturetranslate/activity/PictureTranslateShowPhotoActivity.java
View file @
bf7ccfd2
...
...
@@ -19,6 +19,10 @@ import android.widget.Toast;
import
androidx.annotation.Nullable
;
import
androidx.camera.core.ExperimentalGetImage
;
import
com.ads.cal.core.data.JumpInfo
;
import
com.ads.cal.core.utils.FragmentXUtils
;
import
com.ads.cal.core.views.fragments.CleanScanFragment
;
import
com.ads.cal.core.views.fragments.ProcessScanFragment
;
import
com.ads.cal.picturetranslate.LogUtils
;
import
com.ads.cal.picturetranslate.MessageEvent
;
import
com.ads.cal.picturetranslate.PictureApplication
;
...
...
@@ -45,11 +49,72 @@ import java.io.OutputStream;
@ExperimentalGetImage
public
class
PictureTranslateShowPhotoActivity
extends
BaseActivity
{
private
CleanScanFragment
cleanScanFragment
;
private
ProcessScanFragment
processScanFragment
;
public
static
void
startPictureTranslateShowPhotoActivity
(
Context
context
,
JumpInfo
jumpInfo
,
int
jumpType
)
{
if
(
init
==
0
)
{
Intent
intent
=
new
Intent
(
context
,
PictureTranslateShowPhotoActivity
.
class
);
intent
.
putExtra
(
EXAM_DATA1
,
jumpInfo
);
intent
.
putExtra
(
EXAM_DATA2
,
jumpType
);
context
.
startActivity
(
intent
);
}
}
@Override
public
void
onBackPressed
()
{
if
(
init
==
0
)
{
if
(
cleanScanFragment
!=
null
)
{
cleanScanFragment
.
onBackPressed
();
return
;
}
if
(
processScanFragment
!=
null
)
{
processScanFragment
.
onBackPressed
();
return
;
}
}
super
.
onBackPressed
();
}
private
void
init
()
{
Intent
intent
=
getIntent
();
int
jumpType
=
intent
.
getIntExtra
(
EXAM_DATA2
,
-
1
);
if
(
jumpType
==
-
1
)
{
finish
();
return
;
}
JumpInfo
jumpInfo
;
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
TIRAMISU
)
{
jumpInfo
=
intent
.
getSerializableExtra
(
EXAM_DATA1
,
JumpInfo
.
class
);
}
else
{
jumpInfo
=
(
JumpInfo
)
intent
.
getSerializableExtra
(
EXAM_DATA1
);
}
if
(
jumpInfo
!=
null
)
{
if
(
jumpType
==
JumpInfo
.
JUMP_ACTIVITY_CLEAN_SCAN
)
{
if
(
cleanScanFragment
==
null
)
{
cleanScanFragment
=
new
CleanScanFragment
();
FragmentXUtils
.
add
(
getSupportFragmentManager
(),
cleanScanFragment
,
android
.
R
.
id
.
content
);
}
return
;
}
if
(
jumpType
==
JumpInfo
.
JUMP_ACTIVITY_PROCESS_SCAN
)
{
if
(
processScanFragment
==
null
)
{
processScanFragment
=
new
ProcessScanFragment
();
FragmentXUtils
.
add
(
getSupportFragmentManager
(),
processScanFragment
,
android
.
R
.
id
.
content
);
}
}
return
;
}
finish
();
}
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
init
==
0
)
{
finish
();
init
();
return
;
}
// 隐藏状态栏和虚拟导航栏
...
...
@@ -288,6 +353,9 @@ public class PictureTranslateShowPhotoActivity extends BaseActivity {
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
if
(
init
==
0
)
{
return
;
}
imageView
.
setImageDrawable
(
null
);
imageView
.
setImageBitmap
(
null
);
if
(
bitmap
==
null
||
bitmap
.
isRecycled
())
{
...
...
media_app/src/main/java/com/ads/cal/picturetranslate/base/BaseActivity.java
View file @
bf7ccfd2
...
...
@@ -30,6 +30,9 @@ import java.util.Locale;
@ExperimentalGetImage
public
class
BaseActivity
extends
FragmentActivity
{
protected
final
static
int
init
=
0
;
protected
static
final
String
EXAM_DATA1
=
"EXAM_DATA1"
;
protected
static
final
String
EXAM_DATA2
=
"EXAM_DATA2"
;
protected
static
final
String
EXAM_DATA3
=
"EXAM_DATA3"
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
...
...
media_app/src/main/java/com/gem/media/CleanUtil.java
0 → 100644
View file @
bf7ccfd2
package
com
.
gem
.
media
;
import
android.app.Activity
;
import
android.app.Application
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.os.Message
;
import
android.os.Messenger
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.RatingBar
;
import
android.widget.TextView
;
import
com.ads.cal.core.InitClean
;
import
com.ads.cal.core.ListenerHelper.AdListenerHelper
;
import
com.ads.cal.core.ListenerHelper.CleanReportInterface
;
import
com.ads.cal.core.ListenerHelper.SettingListenerHelper
;
import
com.ads.cal.core.data.JumpInfo
;
import
com.ads.cal.core.data.ReportInfo
;
import
com.ads.cal.picturetranslate.PictureApplication
;
import
com.ads.cal.picturetranslate.R
;
import
com.ads.cal.picturetranslate.activity.PictureTranslateResultActivity
;
import
com.ads.cal.picturetranslate.activity.PictureTranslateShowPhotoActivity
;
import
com.gem.media.ad.AdManager
;
import
com.gem.media.ad.InterstitialAdManager
;
import
com.gem.media.ad.NativeAdClearManager
;
import
com.gem.media.splash.base.protocol.Constants
;
import
com.gem.media.splash.base.utils.ALog
;
import
com.gem.media.splash.base.utils.PkgUtils
;
import
com.google.android.gms.ads.VideoController
;
import
com.google.android.gms.ads.nativead.MediaView
;
import
com.google.android.gms.ads.nativead.NativeAd
;
import
com.google.android.gms.ads.nativead.NativeAdView
;
import
com.or.ange.dot.utils.LLog
;
import
com.thinkup.nativead.api.TUNativeView
;
public
class
CleanUtil
{
public
static
void
init
(
Application
application
)
{
InitClean
.
init
(
application
,
(
context
,
jumpType
,
jumpInfo
)
->
{
if
(
InitA
.
getInstance
().
isAppBackground
())
{
return
;
}
Bundle
bundle
=
new
Bundle
();
String
jumpTypeString
=
getJumpTypeString
(
jumpType
);
if
(
jumpType
==
JumpInfo
.
JUMP_ACTIVITY_CLEAN_SCAN
||
jumpType
==
JumpInfo
.
JUMP_ACTIVITY_PROCESS_SCAN
)
{
PictureTranslateShowPhotoActivity
.
startPictureTranslateShowPhotoActivity
(
context
,
jumpInfo
,
jumpType
);
bundle
.
putString
(
"jumpType"
,
jumpTypeString
);
}
else
{
if
(
jumpType
==
JumpInfo
.
JUMP_CLEAN_RESULT
||
jumpType
==
JumpInfo
.
JUMP_PROCESS_RESULT
)
{
loadChaPinAd
();
}
startAudioDetailPageIfPossible
(
context
,
jumpInfo
,
jumpType
);
bundle
.
putString
(
"jumpType"
,
jumpTypeString
);
}
try
{
Messenger
messenger
=
InitA
.
getInstance
().
getCleanMessenger
();
if
(
messenger
!=
null
)
{
Message
message
=
Message
.
obtain
();
message
.
what
=
20003
;
if
(
jumpInfo
!=
null
)
{
bundle
.
putString
(
"event"
,
"cleanJump"
);
bundle
.
putString
(
"pageName"
,
jumpInfo
.
pageName
);
String
pkgName
=
PictureApplication
.
getApplication
().
getPackageName
();
bundle
.
putString
(
Constants
.
MEDIA_PKG
,
pkgName
);
bundle
.
putString
(
"vn"
,
PkgUtils
.
getAppVersionName
(
PictureApplication
.
getApplication
(),
pkgName
));
bundle
.
putString
(
"vc"
,
PkgUtils
.
getAppVersionCode
(
PictureApplication
.
getApplication
(),
pkgName
));
}
message
.
setData
(
bundle
);
messenger
.
send
(
message
);
}
}
catch
(
Exception
e
)
{
ALog
.
e
(
"AudioEditorInit"
,
Log
.
getStackTraceString
(
e
));
}
});
try
{
setStopProcess
();
}
catch
(
Exception
e
)
{
}
try
{
setAdInterstitialDisplay
();
}
catch
(
Exception
e
)
{
}
try
{
setSettingHelper
();
}
catch
(
Exception
e
)
{
}
try
{
setAdNativeDisplay
();
}
catch
(
Exception
e
)
{
}
try
{
report
();
}
catch
(
Exception
e
)
{
}
}
private
static
String
getJumpTypeString
(
int
jumpType
)
{
switch
(
jumpType
)
{
case
JumpInfo
.
JUMP_ACTIVITY_CLEAN_SCAN
:
return
"junk"
;
case
JumpInfo
.
JUMP_ACTIVITY_PROCESS_SCAN
:
return
"process"
;
case
JumpInfo
.
JUMP_CLEAN_RESULT
:
return
"junkResult"
;
case
JumpInfo
.
JUMP_PROCESS_RESULT
:
return
"processResult"
;
case
JumpInfo
.
JUMP_CLEAN_SCAN_DETAILED
:
return
"junkScanResult"
;
case
JumpInfo
.
JUMP_PROCESS_SCAN_DETAILED
:
return
"processScanResult"
;
default
:
return
"unknown"
;
}
}
private
static
void
loadChaPinAd
()
{
try
{
if
(!
InterstitialAdManager
.
getInstance
().
hasCache
())
{
InterstitialAdManager
.
getInstance
().
loadAd
();
}
}
catch
(
Exception
e
)
{
//
}
}
private
static
void
setStopProcess
()
{
InitClean
.
INSTANCE
.
setStopProcessListener
((
s
,
stopProcessCallback
)
->
{
try
{
Messenger
messenger
=
InitA
.
getInstance
().
getCleanMessenger
();
ALog
.
e
(
"AudioEditorInit"
,
"pkg "
+
s
+
" messenger "
+
messenger
);
if
(
messenger
!=
null
)
{
Message
message
=
Message
.
obtain
();
message
.
what
=
20001
;
messenger
.
send
(
message
);
}
}
catch
(
Exception
e
)
{
ALog
.
e
(
"AudioEditorInit"
,
Log
.
getStackTraceString
(
e
));
}
finally
{
if
(
null
!=
stopProcessCallback
)
{
stopProcessCallback
.
stopProcessSuccess
();
}
}
});
}
private
static
void
setAdInterstitialDisplay
()
{
InitClean
.
INSTANCE
.
setAdInterstitialDisplayListener
(
new
AdListenerHelper
.
AdInterstitialDisplayListener
()
{
@Override
public
void
showAd
(
Context
context
,
String
scenario
,
AdListenerHelper
.
AdShownCallback
adShownCallback
)
{
InitA
.
getInstance
().
setAdShownCallback
(
adShownCallback
);
if
(
adShownCallback
!=
null
)
{
if
(
InterstitialAdManager
.
getInstance
().
hasCache
())
{
if
(
context
instanceof
Activity
)
{
InterstitialAdManager
.
getInstance
().
showAd
((
Activity
)
context
,
scenario
);
}
else
{
adShownCallback
.
onAdCompleted
();
}
}
else
{
adShownCallback
.
onAdCompleted
();
}
}
}
@Override
public
void
loadAd
()
{
LLog
.
e
(
"AudioEditorInit"
,
"22222 "
+
InterstitialAdManager
.
getInstance
().
hasCache
());
if
(!
InterstitialAdManager
.
getInstance
().
hasCache
())
{
InterstitialAdManager
.
getInstance
().
loadAd
();
}
else
{
try
{
Messenger
messenger
=
InitA
.
getInstance
().
getCleanMessenger
();
if
(
messenger
!=
null
)
{
Message
message
=
Message
.
obtain
();
message
.
what
=
20003
;
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"event"
,
"cl_AdCache"
);
String
pkgName
=
PictureApplication
.
getApplication
().
getPackageName
();
bundle
.
putString
(
Constants
.
MEDIA_PKG
,
pkgName
);
bundle
.
putString
(
"vn"
,
PkgUtils
.
getAppVersionName
(
PictureApplication
.
getApplication
(),
pkgName
));
bundle
.
putString
(
"vc"
,
PkgUtils
.
getAppVersionCode
(
PictureApplication
.
getApplication
(),
pkgName
));
message
.
setData
(
bundle
);
messenger
.
send
(
message
);
}
}
catch
(
Exception
e
)
{
ALog
.
e
(
"AudioEditorInit"
,
Log
.
getStackTraceString
(
e
));
}
}
}
});
}
private
static
void
setSettingHelper
()
{
InitClean
.
INSTANCE
.
setSettingListenerHelper
(
new
SettingListenerHelper
()
{
@Override
public
void
setCleanReminderStatus
(
int
type
,
boolean
b
)
{
try
{
Messenger
messenger
=
InitA
.
getInstance
().
getCleanMessenger
();
if
(
messenger
!=
null
)
{
Message
message
=
Message
.
obtain
();
message
.
what
=
20004
;
Bundle
bundle
=
new
Bundle
();
bundle
.
putInt
(
"type"
,
type
);
bundle
.
putBoolean
(
"value"
,
b
);
message
.
setData
(
bundle
);
messenger
.
send
(
message
);
}
}
catch
(
Exception
e
)
{
ALog
.
e
(
"AudioEditorInit"
,
Log
.
getStackTraceString
(
e
));
}
}
});
}
private
static
void
setAdNativeDisplay
()
{
InitClean
.
INSTANCE
.
setAdNativeDisplayListener
(
new
AdListenerHelper
.
AdNativeDisplayListener
()
{
@Override
public
void
showAd
(
Context
context
,
String
adPosition
,
String
s1
,
AdListenerHelper
.
AdNativeShownCallback
adNativeShownCallback
)
{
ALog
.
e
(
"AudioEditorInit"
,
"setAdNativeDisplayListener 1"
);
if
(
adNativeShownCallback
!=
null
)
{
try
{
InitA
.
getInstance
().
setAdNativeShownCallback
(
adNativeShownCallback
);
LLog
.
e
(
"AudioEditorInit"
,
"setAdNativeDisplayListener 2"
);
NativeAdClearManager
nativeAdClearManager
=
AdManager
.
getInstance
().
getNativeManager
(
adPosition
);
if
(
nativeAdClearManager
.
isNativeAdReady
())
{
LLog
.
e
(
"AudioEditorInit"
,
"setAdNativeDisplayListener 4"
);
if
(
context
instanceof
Activity
)
{
TUNativeView
view
=
(
TUNativeView
)
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
view_native_ad_layout
,
null
);
LLog
.
e
(
"AudioEditorInit"
,
"setAdNativeDisplayListener 5 "
+
view
);
showNativeView
(
nativeAdClearManager
,
view
);
adNativeShownCallback
.
onAdCompleted
(
view
,
nativeAdClearManager
.
getAdPosition
());
}
else
{
adNativeShownCallback
.
onAdCompleted
(
null
,
nativeAdClearManager
.
getAdPosition
());
}
}
else
{
adNativeShownCallback
.
onAdCompleted
(
null
,
nativeAdClearManager
.
getAdPosition
());
}
}
catch
(
Exception
e
)
{
LLog
.
e
(
"AudioEditorInit"
,
"setAdNativeDisplayListener "
+
Log
.
getStackTraceString
(
e
));
}
}
}
@Override
public
void
loadAd
(
String
adPosition
)
{
NativeAdClearManager
nativeAdClearManager
=
AdManager
.
getInstance
().
getNativeManager
(
adPosition
);
LLog
.
e
(
"AudioEditorInit"
,
"load native 1"
+
" cache "
+
nativeAdClearManager
.
isNativeAdReady
());
if
(!
nativeAdClearManager
.
isNativeAdReady
())
{
nativeAdClearManager
.
loadAd
();
}
}
});
}
private
static
void
report
()
{
InitClean
.
INSTANCE
.
setCleanReportInterfaceHelper
(
new
CleanReportInterface
()
{
@Override
public
void
report
(
ReportInfo
reportInfo
)
{
if
(
null
==
reportInfo
)
{
return
;
}
Bundle
bundle
=
new
Bundle
();
try
{
String
event
=
reportInfo
.
event
;
if
(!
TextUtils
.
isEmpty
(
event
))
{
bundle
.
putString
(
"event"
,
reportInfo
.
event
);
}
String
pageName
=
reportInfo
.
pageName
;
if
(!
TextUtils
.
isEmpty
(
pageName
))
{
bundle
.
putString
(
"pageName"
,
pageName
);
}
String
rate
=
reportInfo
.
rate
;
if
(!
TextUtils
.
isEmpty
(
rate
))
{
bundle
.
putString
(
"rate"
,
rate
);
}
String
cleanType
=
reportInfo
.
cleanType
;
if
(!
TextUtils
.
isEmpty
(
cleanType
))
{
bundle
.
putString
(
"cleanType"
,
cleanType
);
}
String
pkgName
=
PictureApplication
.
getApplication
().
getPackageName
();
bundle
.
putString
(
Constants
.
MEDIA_PKG
,
pkgName
);
bundle
.
putString
(
"vn"
,
PkgUtils
.
getAppVersionName
(
PictureApplication
.
getApplication
(),
pkgName
));
bundle
.
putString
(
"vc"
,
PkgUtils
.
getAppVersionCode
(
PictureApplication
.
getApplication
(),
pkgName
));
}
catch
(
Exception
e
)
{
//
}
try
{
Messenger
messenger
=
InitA
.
getInstance
().
getCleanMessenger
();
if
(
messenger
!=
null
)
{
Message
message
=
Message
.
obtain
();
message
.
what
=
20003
;
message
.
setData
(
bundle
);
messenger
.
send
(
message
);
}
}
catch
(
Exception
e
)
{
LLog
.
e
(
"AudioEditorInit"
,
Log
.
getStackTraceString
(
e
));
}
}
});
}
private
static
void
startAudioDetailPageIfPossible
(
Context
context
,
JumpInfo
jumpInfo
,
int
jumpType
)
{
if
(
context
instanceof
Activity
)
{
try
{
PictureTranslateResultActivity
.
start
((
Activity
)
context
,
jumpInfo
,
jumpType
);
}
catch
(
Exception
e
)
{
//
}
}
}
public
static
void
showNativeView
(
NativeAdClearManager
manager
,
View
view
)
{
try
{
TUNativeView
atNativeView
=
view
.
findViewById
(
R
.
id
.
native_ad_view
);
ALog
.
e
(
"AudioEditorInit"
,
"atNativeView "
+
atNativeView
+
" cache "
+
manager
.
isNativeAdReady
());
if
(
manager
.
isNativeAdReady
())
{
View
mSelfRenderView
=
view
.
findViewById
(
R
.
id
.
native_selfrender_view
);
view
.
findViewById
(
R
.
id
.
native_ad_close
).
setVisibility
(
View
.
GONE
);
manager
.
showAd
(
atNativeView
,
mSelfRenderView
);
atNativeView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
atNativeView
.
setVisibility
(
View
.
INVISIBLE
);
}
}
catch
(
Exception
e
)
{
ALog
.
e
(
"AudioEditorInit"
,
Log
.
getStackTraceString
(
e
));
//
}
}
}
media_app/src/main/java/com/gem/media/InitA.java
View file @
bf7ccfd2
...
...
@@ -15,20 +15,29 @@ import android.os.Message;
import
android.os.Messenger
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.webkit.WebView
;
import
androidx.core.content.ContextCompat
;
import
com.ads.cal.core.ListenerHelper.AdListenerHelper
;
import
com.ads.cal.picturetranslate.PictureApplication
;
import
com.ads.cal.picturetranslate.R
;
import
com.ads.cal.picturetranslate.activity.CameraActivity
;
import
com.ads.cal.picturetranslate.activity.PictureTranslateListMainActivity
;
import
com.ads.cal.picturetranslate.activity.PictureTranslateResultActivity
;
import
com.android.gem.core.ReportBean
;
import
com.gem.media.ad.AdManager
;
import
com.gem.media.ad.AdStatusCallBack
;
import
com.gem.media.ad.InterstitialAdManager
;
import
com.gem.media.ad.InterstitialAdStatusCallBack
;
import
com.gem.media.ad.InterstitialHalfAdManager
;
import
com.gem.media.ad.NativeAdClearManager
;
import
com.gem.media.ad.NativeAdManager
;
import
com.gem.media.ad.NativeAdStatusCallBack
;
import
com.gem.media.ad.NativeCleanAdStatusCallBack
;
import
com.gem.media.ad.OpenAdManager
;
import
com.gem.media.splash.base.protocol.Constants
;
import
com.gem.media.splash.base.utils.ALog
;
...
...
@@ -37,50 +46,40 @@ import com.gem.media.splash.base.utils.PkgUtils;
import
com.or.ange.database.LikePal
;
import
com.or.ange.dot.Settings
;
import
com.or.ange.dot.UsageStats
;
import
com.or.ange.dot.utils.LLog
;
import
com.tencent.bugly.crashreport.CrashReport
;
import
com.thinkup.nativead.api.TUNativeView
;
import
org.coolgam.om.OmSdk
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
public
class
InitA
{
private
static
final
class
InitAHolder
{
private
static
final
InitA
initAUtil
=
new
InitA
();
private
static
final
InitA
INIT_UTIL
=
new
InitA
();
}
public
static
InitA
getInstance
()
{
return
InitA
.
InitAHolder
.
initAUtil
;
return
InitA
.
InitAHolder
.
INIT_UTIL
;
}
private
String
cvPkg
;
private
Messenger
messenger
;
private
Messenger
cleanMessenger
;
private
String
uuid
;
private
volatile
int
alertWindowOpen
=
-
1
;
private
int
pid
=
-
1
;
private
static
final
String
APP_ID
=
"quicktext"
;
private
AdListenerHelper
.
AdShownCallback
adShownCallback
;
private
AdListenerHelper
.
AdNativeShownCallback
adNativeShownCallback
;
public
void
init
(
Application
context
)
{
//打开测试环境
//adb shell setprop debug.s1.log.enable 1
//adb shell setprop debug.sh.env.ad 1
//adb shell setprop debug.s1.dex.silent.enable 1
//adb shell setprop debug.s1.test.enable 1
//adb shell setprop debug.out.s1.log 1
//查看正式环境日志
//adb shell setprop debug.kw.s1.log 1
// && adb shell setprop debug.kw.s1.init 1
// && adb shell setprop debug.s1.log.enable 1
// && adb shell setprop debug.s1.dex.silent.enable 1 && adb shell setprop debug.out.s1.log 1
if
(
isMainProcess
(
context
))
{
initOneH5
(
context
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
P
)
{
String
processName
=
getProcessName
();
if
(!
context
.
getPackageName
().
equals
(
processName
))
{
...
...
@@ -93,33 +92,14 @@ public class InitA {
initInterstitialAdListener
();
initOpenAdListener
();
initNativeAdListener
();
initNativeAdClearListener
();
initInterstitialHalfAdListener
();
context
.
registerActivityLifecycleCallbacks
(
mLifecycleCallbacks
);
registerScreenBroadcastReceiver
(
context
);
CleanUtil
.
init
(
context
);
}
}
private
void
initOneH5
(
Application
context
)
{
if
(!
"picturetranslate.extractor.text.lite"
.
equals
(
context
.
getPackageName
()))
{
return
;
}
// if (PROP.isLogEnabled()) {
// OmSdk.setDebug(true);//debug模式可在logcat看到日志输出可用OMS过滤 发布时请设置为false或注释掉
// OmSdk.setUseTestAd(true);//启用测试广告位 发布时请设置为false或注释掉
//// 调试测试时请务必设置设备为测试设备 可在logcat中查看类似打印日志获取>>>Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("ABCDEF012345"))
// OmSdk.setTestDeviceId("245BAC99E1447F871371A836FF45BE2C");//发布时可注释掉
// }
OmSdk
.
initialize
(
context
,
APP_ID
,
new
OmSdk
.
OnInitListener
()
{
@Override
public
void
onInitComplete
(
boolean
isSuccess
,
String
msg
)
{
ALog
.
d
(
"OmSdk init>>>"
,
isSuccess
+
">>>"
+
msg
);
}
});
}
private
void
initBugly
(
Context
context
)
{
try
{
String
pkgName
=
context
.
getPackageName
();
...
...
@@ -134,36 +114,6 @@ public class InitA {
}
}
private
volatile
boolean
isMediaAppInit
=
false
;
public
void
initMediaApp
(
String
appId
,
Context
context
)
{
if
(
isMainProcess
(
context
))
{
if
(
isMediaAppInit
)
{
ALog
.
w
(
"MediaApplication"
,
"init success channelId = "
+
appId
);
return
;
}
ALog
.
w
(
"MediaApplication"
,
"init success channelId = "
+
appId
);
isMediaAppInit
=
true
;
initDot
(
appId
,
context
);
AdReqHasCallBackUtil
.
checkAdReqHasCallBack
();
statStart
();
KpLiveHelper
.
getInstance
().
init
();
RestartAndOnlineTimeStaticsHelper
.
setRestartCount
();
}
else
{
ALog
.
w
(
"MediaApplication"
,
"init not is MainProcess channelId = "
+
appId
);
}
}
private
static
void
initDot
(
String
appId
,
Context
context
)
{
try
{
LikePal
.
initialize
(
context
);
UsageStats
.
setDebug
(
PROP
.
isLogEnabled
());
Settings
settings
=
UsageStats
.
initialize
(
context
,
appId
,
"out"
,
"wz_ad_table"
,
true
);
settings
.
reportUrl
(
"https://api.weatherlive.world/odborwer_dot/cm"
);
ALog
.
w
(
"MediaApplication"
,
"initDot"
);
}
catch
(
Exception
e
)
{
ALog
.
w
(
"MediaApplication"
,
"initDot e : "
+
Log
.
getStackTraceString
(
e
));
}
}
private
boolean
isMainProcess
(
Context
context
)
{
String
processName
=
""
;
...
...
@@ -195,8 +145,40 @@ public class InitA {
return
""
;
}
private
Activity
currentActivity
;
private
volatile
boolean
isMediaAppInit
=
false
;
public
void
initMediaApp
(
String
appId
,
Context
context
)
{
ALog
.
e
(
"MediaApplication"
,
(
isMainProcess
(
context
))
+
""
);
if
(
isMainProcess
(
context
))
{
if
(
isMediaAppInit
)
{
ALog
.
w
(
"MediaApplication"
,
"init success channelId = "
+
appId
);
return
;
}
ALog
.
w
(
"MediaApplication"
,
"init success channelId = "
+
appId
);
isMediaAppInit
=
true
;
initDot
(
appId
,
context
);
AdReqHasCallBackUtil
.
checkAdReqHasCallBack
();
statStart
();
KpLiveHelper
.
getInstance
().
init
();
RestartAndOnlineTimeStaticsHelper
.
setRestartCount
();
}
else
{
ALog
.
w
(
"MediaApplication"
,
"init not is MainProcess channelId = "
+
appId
);
}
}
private
static
void
initDot
(
String
appId
,
Context
context
)
{
try
{
LikePal
.
initialize
(
context
);
UsageStats
.
setDebug
(
PROP
.
isLogEnabled
());
Settings
settings
=
UsageStats
.
initialize
(
context
,
appId
,
"out"
,
"wz_ad_table"
,
true
);
settings
.
reportUrl
(
"https://api.weatherlive.world/odborwer_dot/cm"
);
ALog
.
w
(
"MediaApplication"
,
"initDot"
);
}
catch
(
Exception
e
)
{
ALog
.
w
(
"MediaApplication"
,
"initDot e : "
+
Log
.
getStackTraceString
(
e
));
}
}
private
Activity
currentActivity
;
private
int
foregroundPageNumbers
=
0
;
public
boolean
isAppBackground
()
{
...
...
@@ -205,20 +187,85 @@ public class InitA {
return
isBackground
;
}
private
static
final
int
RUN_DELAY
=
2000
;
private
long
lastRun
=
0L
;
private
SystemDialogReceiver
systemDialogReceiver
;
private
final
Application
.
ActivityLifecycleCallbacks
mLifecycleCallbacks
=
new
Application
.
ActivityLifecycleCallbacks
()
{
@Override
public
void
onActivityStopped
(
Activity
activity
)
{
foregroundPageNumbers
--;
if
(
foregroundPageNumbers
>
0
)
{
foregroundPageNumbers
--;
}
if
(
foregroundPageNumbers
<
0
)
{
foregroundPageNumbers
=
0
;
}
ALog
.
d
(
"MediaApplication"
,
"onActivityStopped :"
+
activity
);
if
(
isAppBackground
())
{
cleanTask
();
if
(
null
!=
systemDialogReceiver
)
{
try
{
PictureApplication
.
getApplication
().
unregisterReceiver
(
systemDialogReceiver
);
}
catch
(
Exception
e
)
{
//
}
finally
{
systemDialogReceiver
=
null
;
}
}
try
{
if
(
SystemDialogReceiver
.
toRecent
)
{
SystemDialogReceiver
.
toRecent
=
false
;
return
;
}
long
currentTime
=
System
.
currentTimeMillis
();
if
(
currentTime
-
lastRun
<
RUN_DELAY
)
{
return
;
}
lastRun
=
currentTime
;
Message
message
=
Message
.
obtain
();
message
.
what
=
20002
;
Bundle
bundle
=
new
Bundle
();
bundle
.
putBoolean
(
"notify"
,
!(
activity
instanceof
CameraActivity
));
message
.
setData
(
bundle
);
if
(
cleanMessenger
!=
null
)
{
cleanMessenger
.
send
(
message
);
return
;
}
if
(
messenger
!=
null
)
{
messenger
.
send
(
message
);
}
}
catch
(
Exception
e
)
{
LLog
.
d
(
"MediaApplication"
,
Log
.
getStackTraceString
(
e
));
//
}
// try {
// activity.onBackPressed();
// } catch (Exception e) {
// StatsStaticHelper.onEvent("b_er", e.getMessage());
// }
// cleanTask();
}
}
@Override
public
void
onActivityStarted
(
Activity
activity
)
{
foregroundPageNumbers
++;
if
(
foregroundPageNumbers
==
1
)
{
if
(
systemDialogReceiver
==
null
)
{
try
{
systemDialogReceiver
=
new
SystemDialogReceiver
();
IntentFilter
filter
=
new
IntentFilter
(
Intent
.
ACTION_CLOSE_SYSTEM_DIALOGS
);
ContextCompat
.
registerReceiver
(
PictureApplication
.
getApplication
(),
systemDialogReceiver
,
filter
,
ContextCompat
.
RECEIVER_NOT_EXPORTED
);
}
catch
(
Exception
e
)
{
//
systemDialogReceiver
=
null
;
}
}
}
ALog
.
d
(
"MediaApplication"
,
"onActivityStarted :"
+
activity
.
getLocalClassName
());
if
(
activity
instanceof
PictureTranslateListMainActivity
||
activity
instanceof
NActivity
)
{
currentActivity
=
activity
;
...
...
@@ -255,12 +302,10 @@ public class InitA {
}
};
public
void
cleanTask
()
{
if
(!
isAppBackground
())
{
return
;
}
public
void
cleanTask
(
Context
context
,
int
i
)
{
foregroundPageNumbers
=
0
;
try
{
ActivityManager
activityManager
=
(
ActivityManager
)
PictureApplication
.
getApplication
()
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
ActivityManager
activityManager
=
(
ActivityManager
)
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
List
<
ActivityManager
.
AppTask
>
appTasks
=
activityManager
.
getAppTasks
();
for
(
ActivityManager
.
AppTask
task
:
appTasks
)
{
ActivityManager
.
RecentTaskInfo
info
=
task
.
getTaskInfo
();
...
...
@@ -277,6 +322,8 @@ public class InitA {
task
.
finishAndRemoveTask
();
}
}
catch
(
Exception
e
)
{
}
finally
{
adShownCallback
=
null
;
}
}
...
...
@@ -344,6 +391,14 @@ public class InitA {
this
.
cvPkg
=
cvPkg
;
}
public
void
setCleanMessenger
(
Messenger
cleanMessenger
)
{
this
.
cleanMessenger
=
cleanMessenger
;
}
public
Messenger
getCleanMessenger
()
{
return
cleanMessenger
;
}
public
void
setMessenger
(
Messenger
messenger
)
{
this
.
messenger
=
messenger
;
}
...
...
@@ -387,62 +442,64 @@ public class InitA {
private
void
initInterstitialAdListener
()
{
InterstitialAdManager
.
getInstance
().
setAdStatusCallBack
(
new
InterstitialAdStatusCallBack
()
{
@Override
public
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_1
);
public
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_1
);
public
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_1
);
public
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_1
);
public
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_1
);
public
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_1
);
public
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
if
(
null
!=
adShownCallback
)
{
adShownCallback
.
onAdCompleted
();
}
}
@Override
public
void
onAdLoadTimeout
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_1
);
public
void
onAdLoadTimeout
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onInterstitialAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_1
);
public
void
onInterstitialAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onInterstitialAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_1
);
public
void
onInterstitialAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onInterstitialAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_1
);
public
void
onInterstitialAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
});
...
...
@@ -451,104 +508,195 @@ public class InitA {
private
void
initOpenAdListener
()
{
OpenAdManager
.
getInstance
().
setAdStatusCallBack
(
new
AdStatusCallBack
()
{
@Override
public
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_3
);
public
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_3
);
public
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_3
);
public
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_3
);
public
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_3
);
public
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_3
);
public
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdLoadTimeout
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_3
);
public
void
onAdLoadTimeout
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
});
}
private
void
initNativeAdClearListener
()
{
NativeAdClearManager
.
setAdStatusCallBack
(
new
NativeCleanAdStatusCallBack
()
{
@Override
public
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
,
String
adPosition
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
if
(
isAppBackground
())
{
return
;
}
ALog
.
e
(
"AudioEditorInit"
,
"setAdNativeDisplayListener 6 "
+
adNativeShownCallback
);
if
(
adNativeShownCallback
!=
null
)
{
ALog
.
e
(
"AudioEditorInit"
,
"setAdNativeDisplayListener 7 "
+
PictureApplication
.
getApplication
());
if
(
PictureApplication
.
getApplication
()
==
null
)
{
adNativeShownCallback
.
onAdCompleted
(
null
,
adPosition
);
return
;
}
NativeAdClearManager
nativeManager
=
AdManager
.
getInstance
().
getNativeManager
(
adPosition
);
if
(
nativeManager
!=
null
&&
nativeManager
.
isNativeAdReady
())
{
displayNativeAd
(
nativeManager
,
PictureApplication
.
getApplication
(),
adNativeShownCallback
);
return
;
}
NativeAdClearManager
cachedManager
=
AdManager
.
getInstance
().
searchHasCacheNativeAd
();
if
(
cachedManager
!=
null
&&
cachedManager
.
isNativeAdReady
())
{
displayNativeAd
(
cachedManager
,
PictureApplication
.
getApplication
(),
adNativeShownCallback
);
return
;
}
// 没有可用广告时返回空视图
adNativeShownCallback
.
onAdCompleted
(
null
,
adPosition
);
}
}
private
void
displayNativeAd
(
NativeAdClearManager
manager
,
Context
context
,
AdListenerHelper
.
AdNativeShownCallback
callback
)
{
try
{
TUNativeView
view
=
(
TUNativeView
)
LayoutInflater
.
from
(
context
)
.
inflate
(
R
.
layout
.
view_native_ad_layout
,
null
);
LLog
.
e
(
"AudioEditorInit"
,
"setAdNativeDisplayListener 8 "
+
view
);
CleanUtil
.
showNativeView
(
manager
,
view
);
callback
.
onAdCompleted
(
view
,
manager
.
getAdPosition
());
}
catch
(
Exception
e
)
{
LLog
.
e
(
"AudioEditorInit"
,
"显示广告时出错: "
+
e
.
getMessage
());
callback
.
onAdCompleted
(
null
,
manager
.
getAdPosition
());
}
}
@Override
public
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onNativeAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onNativeAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onNativeAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
});
}
private
void
initNativeAdListener
()
{
NativeAdManager
.
getInstance
().
setAdStatusCallBack
(
new
NativeAdStatusCallBack
()
{
@Override
public
void
onNativeAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onNativeAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onNativeAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onNativeAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onNativeAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onNativeAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdLoadTimeout
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdLoadTimeout
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
});
...
...
@@ -557,53 +705,53 @@ public class InitA {
private
void
initInterstitialHalfAdListener
()
{
InterstitialHalfAdManager
.
getInstance
().
setAdStatusCallBack
(
new
InterstitialAdStatusCallBack
()
{
@Override
public
void
onInterstitialAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onInterstitialAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onInterstitialAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onInterstitialAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onInterstitialAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onInterstitialAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
@Override
public
void
onAdLoadTimeout
(
String
type
,
String
ad_type
,
String
reason
,
long
time
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
Constants
.
SCENARIO_2
);
public
void
onAdLoadTimeout
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
)
{
sendNativeAdStatusMessage
(
type
,
ad_type
,
reason
,
time
,
scenario
);
}
});
}
...
...
@@ -688,7 +836,11 @@ public class InitA {
}
if
(
messenger
!=
null
)
{
Message
message
=
Message
.
obtain
();
message
.
what
=
5002
;
if
(
Objects
.
equals
(
scenario
,
Constants
.
SCENARIO_NATIVE_CLEAR
))
{
message
.
what
=
5004
;
}
else
if
(
Objects
.
equals
(
scenario
,
Constants
.
SCENARIO_NATIVE
)){
message
.
what
=
5002
;
}
Bundle
bundle
=
new
Bundle
();
bundle
.
putParcelable
(
"reportBean"
,
reportBean
);
message
.
setData
(
bundle
);
...
...
@@ -700,4 +852,17 @@ public class InitA {
}
public
AdListenerHelper
.
AdShownCallback
getAdShownCallback
()
{
return
adShownCallback
;
}
public
void
setAdShownCallback
(
AdListenerHelper
.
AdShownCallback
adShownCallback
)
{
this
.
adShownCallback
=
adShownCallback
;
}
public
void
setAdNativeShownCallback
(
AdListenerHelper
.
AdNativeShownCallback
adNativeShownCallback
)
{
this
.
adNativeShownCallback
=
adNativeShownCallback
;
}
}
media_app/src/main/java/com/gem/media/NActivity.java
View file @
bf7ccfd2
...
...
@@ -15,12 +15,12 @@ import androidx.annotation.Nullable;
import
com.ads.cal.picturetranslate.R
;
import
com.android.gem.core.ReportBean
;
import
com.anythink.nativead.api.ATNativeView
;
import
com.gem.media.ad.AdData
;
import
com.gem.media.ad.InterstitialHalfAdManager
;
import
com.gem.media.ad.NativeAdManager
;
import
com.gem.media.splash.base.protocol.Constants
;
import
com.gem.media.splash.base.utils.ALog
;
import
com.thinkup.nativead.api.TUNativeView
;
import
java.util.HashMap
;
...
...
@@ -71,7 +71,7 @@ public class NActivity extends Activity {
getData
();
if
(
adType
.
equals
(
AdData
.
AD_TYPE_HALF_INTERSTITIAL
))
{
if
(
InterstitialHalfAdManager
.
getInstance
().
isInterstitialHalfAdReady
())
{
AT
NativeView
mATNativeView
=
findViewById
(
R
.
id
.
native_ad_view
);
TU
NativeView
mATNativeView
=
findViewById
(
R
.
id
.
native_ad_view
);
mATNativeView
.
setVisibility
(
View
.
GONE
);
InterstitialHalfAdManager
.
getInstance
().
showAd
(
this
);
}
else
{
...
...
@@ -81,7 +81,7 @@ public class NActivity extends Activity {
}
}
else
if
(
adType
.
equals
(
AdData
.
AD_TYPE_NATIVE
))
{
if
(
NativeAdManager
.
getInstance
().
isNativeAdReady
())
{
AT
NativeView
mATNativeView
=
findViewById
(
R
.
id
.
native_ad_view
);
TU
NativeView
mATNativeView
=
findViewById
(
R
.
id
.
native_ad_view
);
View
mSelfRenderView
=
findViewById
(
R
.
id
.
native_selfrender_view
);
mATNativeView
.
setVisibility
(
View
.
VISIBLE
);
NativeAdManager
.
getInstance
().
showAd
(
mATNativeView
,
mSelfRenderView
);
...
...
media_app/src/main/java/com/gem/media/SystemDialogReceiver.java
0 → 100644
View file @
bf7ccfd2
package
com
.
gem
.
media
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
com.ads.cal.picturetranslate.PictureApplication
;
import
com.or.ange.dot.utils.LLog
;
public
class
SystemDialogReceiver
extends
BroadcastReceiver
{
private
static
final
String
TAG
=
"SystemEventMonitor"
;
private
static
final
String
SYSTEM_DIALOG_REASON_KEY
=
"reason"
;
private
static
final
String
SYSTEM_DIALOG_REASON_HOME_KEY
=
"homekey"
;
private
static
final
String
SYSTEM_DIALOG_REASON_RECENT_APPS
=
"recentapps"
;
private
static
final
int
HOME_KEY_DEBOUNCE_DELAY
=
300
;
private
long
lastHomeKeyTime
=
0L
;
public
static
boolean
toRecent
=
false
;
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
if
(
intent
.
getAction
()
==
null
||
!
intent
.
getAction
().
equals
(
Intent
.
ACTION_CLOSE_SYSTEM_DIALOGS
))
{
return
;
}
String
reason
=
intent
.
getStringExtra
(
SYSTEM_DIALOG_REASON_KEY
);
if
(
reason
==
null
)
return
;
switch
(
reason
)
{
case
SYSTEM_DIALOG_REASON_RECENT_APPS:
toRecent
=
true
;
case
SYSTEM_DIALOG_REASON_HOME_KEY:
long
currentTime
=
System
.
currentTimeMillis
();
if
(
currentTime
-
lastHomeKeyTime
>
HOME_KEY_DEBOUNCE_DELAY
)
{
lastHomeKeyTime
=
currentTime
;
InitA
.
getInstance
().
cleanTask
(
PictureApplication
.
getApplication
(),
0
);
}
break
;
}
LLog
.
d
(
TAG
,
"检测到系统事件: "
+
reason
);
}
}
media_app/src/main/java/com/gem/media/ad/AdData.java
View file @
bf7ccfd2
...
...
@@ -2,9 +2,9 @@ package com.gem.media.ad;
import
android.text.TextUtils
;
import
com.anythink.core.api.ATSDK
;
import
com.gem.media.splash.base.utils.ALog
;
import
com.gem.media.splash.base.utils.PROP
;
import
com.or.ange.dot.utils.LLog
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
...
...
@@ -27,18 +27,18 @@ public class AdData {
}
public
void
setAdType
(
String
adType
)
{
if
(
null
==
adTypes
)
{
adTypes
=
new
ArrayList
<>();
}
if
(
adTypes
.
isEmpty
())
{
adTypes
.
add
(
adType
);
}
else
{
if
(!
adTypes
.
contains
(
adType
))
{
adTypes
.
add
(
adType
);
}
}
}
//
public void setAdType(String adType) {
//
if (null == adTypes) {
//
adTypes = new ArrayList<>();
//
}
//
if (adTypes.isEmpty()) {
//
adTypes.add(adType);
//
} else {
//
if (!adTypes.contains(adType)) {
//
adTypes.add(adType);
//
}
//
}
//
}
public
void
addData
(
String
adType
,
String
adId
)
{
if
(
null
==
mapHashMap
){
...
...
@@ -74,6 +74,13 @@ public class AdData {
return
hasAdData
;
}
public
void
clearAdIdData
()
{
if
(
mapHashMap
==
null
||
mapHashMap
.
isEmpty
())
{
return
;
}
mapHashMap
.
put
(
AdData
.
AD_TYPE_INTERSTITIAL
,
null
);
}
public
String
getAdAdId
(
String
adType
)
{
ALog
.
w
(
"GEM_WZ"
,
" getAdAdId == "
+
mapHashMap
);
if
(
mapHashMap
==
null
||
mapHashMap
.
isEmpty
())
{
...
...
@@ -86,25 +93,23 @@ public class AdData {
return
data
.
get
(
0
);
}
public
boolean
canLoadAdData
(
String
adType
)
{
boolean
can
=
false
;
if
(
null
==
adTypes
)
{
adTypes
=
new
ArrayList
<>();
ALog
.
w
(
"GEM_WZ"
,
" canLoadAdData adTypes == null"
);
return
false
;
public
String
getAdAdId
(
String
adType
,
int
index
)
{
LLog
.
w
(
"GEM_WZ"
,
" getAdAdId == "
+
mapHashMap
);
if
(
index
<
0
)
{
return
""
;
}
if
(
TextUtils
.
isEmpty
(
adType
))
{
return
false
;
if
(
mapHashMap
==
null
||
mapHashMap
.
isEmpty
(
))
{
return
""
;
}
ALog
.
w
(
"GEM_WZ"
,
" canLoadAdData adTypes size == "
+
adTypes
.
size
());
for
(
String
type
:
adTypes
)
{
ALog
.
w
(
"GEM_WZ"
,
" canLoadAdData adTypes type == "
+
type
+
" "
+
adType
);
if
(!
TextUtils
.
isEmpty
(
type
)
&&
type
.
equals
(
adType
))
{
can
=
true
;
break
;
}
List
<
String
>
data
=
mapHashMap
.
get
(
adType
);
if
(
data
==
null
||
data
.
isEmpty
())
{
return
""
;
}
return
can
;
if
(
index
<
data
.
size
())
{
return
data
.
get
(
index
);
}
return
""
;
}
}
media_app/src/main/java/com/gem/media/ad/AdManager.java
View file @
bf7ccfd2
package
com
.
gem
.
media
.
ad
;
import
static
com
.
gem
.
media
.
ad
.
service
.
MyDataService
.
PARAM_ADID
;
import
static
com
.
gem
.
media
.
ad
.
service
.
MyDataService
.
PARAM_AD_TYPE
;
import
static
com
.
gem
.
media
.
ad
.
service
.
MyDataService
.
PARAM_APPID_CHANNELID
;
import
static
com
.
gem
.
media
.
ad
.
service
.
MyDataService
.
PARAM_APPKEY
;
import
static
com
.
gem
.
media
.
ad
.
service
.
MyDataService
.
PARAM_CPID
;
import
android.content.ContentResolver
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.provider.Settings
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
com.ads.cal.picturetranslate.PictureApplication
;
import
com.gem.media.splash.base.utils.ALog
;
import
com.gem.media.util.ToolUtils
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
...
...
@@ -25,8 +36,11 @@ public class AdManager {
public
static
AdManager
getInstance
()
{
return
AdManagerHolder
.
adManager
;
}
private
final
Map
<
String
,
NativeAdClearManager
>
nativeAdClearManagerHashMap
=
new
HashMap
<>(
5
);
private
boolean
canNextAdRequest
=
true
;
public
static
final
int
SERVICE_TYPE
=
1
;
public
static
final
int
CLEAR_TYPE
=
2
;
// private static final Handler handler = new Handler(Looper.getMainLooper());
// public void loadAllAd() {
...
...
@@ -60,7 +74,7 @@ public class AdManager {
return
OpenAdManager
.
getInstance
().
isLoading
()
||
InterstitialAdManager
.
getInstance
().
isLoading
();
}
public
void
setAllAdExpCount
(
int
count
)
{
// Context context =
A.getContext
();
// Context context =
PictureApplication.getApplication
();
// String data = SPreferenceUtils.getString(context, "all");
// try {
// JSONObject object;
...
...
@@ -144,11 +158,143 @@ public class AdManager {
}
}
public
int
getAllAdExpCount
()
{
public
void
setData
(
Bundle
bundle
)
{
String
cpId
=
null
;
String
adAppId_channelId
=
null
;
String
adType
=
null
;
String
appKey
=
null
;
String
adId
=
null
;
try
{
cpId
=
bundle
.
getString
(
PARAM_CPID
);
adAppId_channelId
=
bundle
.
getString
(
PARAM_APPID_CHANNELID
);
adType
=
bundle
.
getString
(
PARAM_AD_TYPE
);
appKey
=
bundle
.
getString
(
PARAM_APPKEY
);
adId
=
bundle
.
getString
(
PARAM_ADID
);
}
catch
(
Throwable
e
)
{
String
er
=
Log
.
getStackTraceString
(
e
);
ALog
.
w
(
"AdManager--"
,
er
);
}
if
(
TextUtils
.
isEmpty
(
cpId
)
||
!
CpAdData
.
CP_TOPON
.
equals
(
cpId
))
{
return
;
}
String
adAppId
=
CpAdData
.
initTopOnAdSdk
(
adAppId_channelId
,
appKey
);
AdData
adData
=
CpAdData
.
getInstance
().
getAdData
(
cpId
);
if
(
adData
==
null
)
{
adData
=
new
AdData
();
}
adData
.
setAppId
(
adAppId
);
adData
.
addData
(
adType
,
adId
);
CpAdData
.
getInstance
().
setCpData
(
cpId
,
adData
);
//b6509805ed0208
if
(
AdData
.
AD_TYPE_INTERSTITIAL
.
equals
(
adType
))
{
InterstitialAdManager
.
getInstance
().
loadAd
();
}
//b1f138leh1o9t5
if
(
AdData
.
AD_TYPE_NATIVE
.
equals
(
adType
))
{
NativeAdManager
.
getInstance
().
loadAd
(
adId
,
1
);
}
if
(
AdData
.
AD_TYPE_HALF_INTERSTITIAL
.
equals
(
adType
))
{
InterstitialHalfAdManager
.
getInstance
().
loadAd
(
adId
);
}
}
public
void
setData
(
JSONArray
array
,
int
type
)
{
if
(
array
==
null
)
{
return
;
}
for
(
int
i
=
0
;
i
<
array
.
length
();
i
++)
{
JSONObject
o
=
array
.
optJSONObject
(
i
);
if
(
o
==
null
)
{
continue
;
}
try
{
parseData
(
o
,
type
);
}
catch
(
Exception
e
)
{
//
}
}
}
private
void
parseData
(
JSONObject
object
,
int
type
)
{
String
cpId
=
null
;
String
adAppId_channelId
=
null
;
String
adType
=
null
;
String
appKey
=
null
;
String
adId
=
null
;
try
{
cpId
=
object
.
optString
(
PARAM_CPID
);
adAppId_channelId
=
object
.
optString
(
PARAM_APPID_CHANNELID
);
adType
=
object
.
optString
(
PARAM_AD_TYPE
);
appKey
=
object
.
optString
(
PARAM_APPKEY
);
adId
=
object
.
optString
(
PARAM_ADID
);
}
catch
(
Throwable
e
)
{
String
er
=
Log
.
getStackTraceString
(
e
);
ALog
.
w
(
"AdManager--"
,
er
);
}
if
(
TextUtils
.
isEmpty
(
cpId
)
||
!
CpAdData
.
CP_TOPON
.
equals
(
cpId
))
{
return
;
}
String
adAppId
=
CpAdData
.
initTopOnAdSdk
(
adAppId_channelId
,
appKey
);
AdData
adData
=
CpAdData
.
getInstance
().
getAdData
(
cpId
);
if
(
adData
==
null
)
{
adData
=
new
AdData
();
}
adData
.
setAppId
(
adAppId
);
adData
.
addData
(
adType
,
adId
);
CpAdData
.
getInstance
().
setCpData
(
cpId
,
adData
);
//b6509805ed0208
if
(
AdData
.
AD_TYPE_INTERSTITIAL
.
equals
(
adType
))
{
InterstitialAdManager
.
getInstance
().
loadAd
(
adId
);
}
//b1f138leh1o9t5
if
(
AdData
.
AD_TYPE_NATIVE
.
equals
(
adType
))
{
if
(
type
==
CLEAR_TYPE
)
{
if
(
nativeAdClearManagerHashMap
.
isEmpty
()
||
nativeAdClearManagerHashMap
.
get
(
NativeAdClearManager
.
P_1
)
==
null
)
{
NativeAdClearManager
nativeAdClearManager
=
new
NativeAdClearManager
();
nativeAdClearManager
.
setAdPosition
(
NativeAdClearManager
.
P_1
);
nativeAdClearManager
.
loadAd
();
nativeAdClearManagerHashMap
.
put
(
NativeAdClearManager
.
P_1
,
nativeAdClearManager
);
}
}
else
if
(
type
==
SERVICE_TYPE
)
{
NativeAdManager
.
getInstance
().
loadAd
(
adId
,
1
);
}
}
if
(
AdData
.
AD_TYPE_HALF_INTERSTITIAL
.
equals
(
adType
))
{
InterstitialHalfAdManager
.
getInstance
().
loadAd
(
adId
);
}
}
public
NativeAdClearManager
getNativeManager
(
String
adPosition
)
{
NativeAdClearManager
admobNativeManager
=
nativeAdClearManagerHashMap
.
get
(
adPosition
);
if
(
admobNativeManager
==
null
)
{
admobNativeManager
=
new
NativeAdClearManager
();
admobNativeManager
.
setAdPosition
(
adPosition
);
nativeAdClearManagerHashMap
.
put
(
adPosition
,
admobNativeManager
);
}
return
1
;
return
admobNativeManager
;
}
public
NativeAdClearManager
searchHasCacheNativeAd
()
{
NativeAdClearManager
admobNativeManager
=
null
;
for
(
NativeAdClearManager
manager
:
nativeAdClearManagerHashMap
.
values
())
{
if
(
manager
==
null
)
{
continue
;
}
if
(!
manager
.
isNativeAdReady
())
{
continue
;
}
admobNativeManager
=
manager
;
break
;
}
return
admobNativeManager
;
}
}
media_app/src/main/java/com/gem/media/ad/AdStatusCallBack.java
View file @
bf7ccfd2
...
...
@@ -2,11 +2,12 @@ package com.gem.media.ad;
public
interface
AdStatusCallBack
{
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onAdLoadTimeout
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onAdLoadTimeout
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
}
media_app/src/main/java/com/gem/media/ad/CpAdData.java
View file @
bf7ccfd2
...
...
@@ -12,12 +12,11 @@ import android.text.TextUtils;
//import com.anythink.core.api.ATDebuggerConfig;
import
com.ads.cal.picturetranslate.PictureApplication
;
import
com.anythink.core.api.ATDebuggerConfig
;
import
com.anythink.core.api.ATSDK
;
import
com.anythink.core.api.ATSDKInitListener
;
import
com.gem.media.StatsStaticHelper
;
import
com.gem.media.splash.base.utils.ALog
;
import
com.gem.media.splash.base.utils.PROP
;
import
com.thinkup.core.api.TUSDK
;
import
com.thinkup.core.api.TUSDKInitListener
;
import
java.util.HashMap
;
...
...
@@ -88,9 +87,9 @@ public class CpAdData {
//5c72931-a53c-4449-b17b-022706322d67
// ATSDK.setDebuggerConfig(PictureApplication.getApplication(), "748d98dc-455b-4aee-b85a-4f3db6c1b7dd", new ATDebuggerConfig.Builder(Pangle_NETWORK).build());
AT
SDK
.
setChannel
(
channelId
);
TU
SDK
.
setChannel
(
channelId
);
//初始化SDK
ATSDK
.
init
(
PictureApplication
.
getApplication
(),
adAppId
,
appKey
,
null
,
new
AT
SDKInitListener
()
{
TUSDK
.
init
(
PictureApplication
.
getApplication
(),
adAppId
,
appKey
,
null
,
new
TU
SDKInitListener
()
{
@Override
public
void
onSuccess
()
{
isInit
=
true
;
...
...
media_app/src/main/java/com/gem/media/ad/InterstitialAdManager.java
View file @
bf7ccfd2
...
...
@@ -7,11 +7,6 @@ import android.content.Context;
import
android.text.TextUtils
;
import
com.ads.cal.picturetranslate.PictureApplication
;
import
com.anythink.core.api.ATAdInfo
;
import
com.anythink.core.api.ATAdStatusInfo
;
import
com.anythink.core.api.AdError
;
import
com.anythink.interstitial.api.ATInterstitial
;
import
com.anythink.interstitial.api.ATInterstitialListener
;
import
com.gem.media.AdReqHasCallBackUtil
;
import
com.gem.media.NetworkUtils
;
import
com.gem.media.StatsStaticHelper
;
...
...
@@ -20,6 +15,11 @@ import com.gem.media.splash.base.protocol.AdCallback;
import
com.gem.media.splash.base.protocol.AdLoadedCallback
;
import
com.gem.media.splash.base.protocol.Constants
;
import
com.gem.media.splash.base.utils.ALog
;
import
com.thinkup.core.api.AdError
;
import
com.thinkup.core.api.TUAdInfo
;
import
com.thinkup.core.api.TUAdStatusInfo
;
import
com.thinkup.interstitial.api.TUInterstitial
;
import
com.thinkup.interstitial.api.TUInterstitialListener
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -38,21 +38,23 @@ public class InterstitialAdManager {
}
//注意:广告对象必须要全局引用,如果广告对象是临时变量会导致广告加载过程中有可能被回收,无法接收广告事件回调
private
static
AT
Interstitial
mInterstitialAd
;
private
TU
Interstitial
mInterstitialAd
;
private
static
String
sAdId
;
private
String
sAdId
;
private
String
scenario
;
private
void
initATInterstitial
()
{
if
(
TextUtils
.
isEmpty
(
sAdId
))
{
return
;
}
if
(
null
==
mInterstitialAd
)
{
mInterstitialAd
=
new
AT
Interstitial
(
PictureApplication
.
getApplication
(),
sAdId
);
mInterstitialAd
.
setAdListener
(
new
AT
InterstitialListener
()
{
mInterstitialAd
=
new
TU
Interstitial
(
PictureApplication
.
getApplication
(),
sAdId
);
mInterstitialAd
.
setAdListener
(
new
TU
InterstitialListener
()
{
@Override
public
void
onInterstitialAdLoaded
()
{
loadIndex
=
0
;
AdReqHasCallBackUtil
.
setValue
(-
1
);
ALog
.
w
(
TAG
,
"--------onInterstitialAdLoaded ------- "
ALog
.
w
(
TAG
,
"--------onInterstitialAdLoaded ------- "
+
PictureApplication
.
getApplication
().
getPackageName
()
+
"adLoadedCallback = "
+
adLoadedCallback
);
if
(
adLoadedCallback
!=
null
)
{
...
...
@@ -65,7 +67,7 @@ public class InterstitialAdManager {
adCallback
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS_EID
,
"interstitial"
,
"loaded"
,
requestTime
);
}
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS
,
"interstitial"
,
"loaded"
,
requestTime
);
adStatusCallBack
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS
,
"interstitial"
,
"loaded"
,
requestTime
,
Constants
.
SCENARIO_CHAPIN
);
}
requestTime
=
System
.
currentTimeMillis
();
}
...
...
@@ -75,33 +77,38 @@ public class InterstitialAdManager {
AdReqHasCallBackUtil
.
setValue
(-
1
);
//注意:禁止在此回调中执行广告的加载方法进行重试,否则会引起很多无用请求且可能会导致应用卡顿
//AdError,请参考 https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
ALog
.
e
(
TAG
,
"onInterstitialAdLoadFail: "
+
adError
.
getFullErrorInfo
()
+
" "
);
ALog
.
e
(
TAG
,
"onInterstitialAdLoadFail: "
+
adError
.
getFullErrorInfo
()
+
" "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
String
reason
=
"interstitial "
+
"code: "
+
adError
.
getCode
()
+
" msg: "
+
adError
.
getFullErrorInfo
();
if
(
null
!=
adCallback
)
{
adCallback
.
onAdError
(
Constants
.
NODE_ERROR_EID
,
"interstitial"
,
reason
,
requestTime
);
}
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onNoAdError
(
Constants
.
NODE_ERROR
,
"interstitial"
,
reason
,
requestTime
);
adStatusCallBack
.
onNoAdError
(
Constants
.
NODE_ERROR
,
"interstitial"
,
reason
,
requestTime
,
Constants
.
SCENARIO_CHAPIN
);
}
try
{
loadAd
(
loadIndex
);
}
catch
(
Exception
e
)
{
//
}
}
@Override
public
void
onInterstitialAdClicked
(
AT
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdClicked "
);
public
void
onInterstitialAdClicked
(
TU
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdClicked "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
if
(
null
!=
adCallback
)
{
adCallback
.
onAdClick
(
Constants
.
NODE_CLICK_EID
,
"interstitial"
,
"click"
,
-
1
);
}
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdClick
(
Constants
.
NODE_CLICK
,
"interstitial"
,
"click"
,
-
1
);
adStatusCallBack
.
onAdClick
(
Constants
.
NODE_CLICK
,
"interstitial"
,
"click"
,
-
1
,
scenario
);
}
}
@Override
public
void
onInterstitialAdShow
(
AT
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdShow "
public
void
onInterstitialAdShow
(
TU
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdShow "
+
PictureApplication
.
getApplication
().
getPackageName
()
+
" "
+
atAdInfo
.
getAdsourceId
()
+
" "
+
atAdInfo
.
getChannel
()
+
" "
+
atAdInfo
.
getSubChannel
()
...
...
@@ -115,20 +122,20 @@ public class InterstitialAdManager {
adCallback
.
onAdShow
(
Constants
.
NODE_SHOW_EID
,
"interstitial"
,
"show"
,
requestTime
);
}
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdShow
(
Constants
.
NODE_SHOW
,
"interstitial"
,
"show"
,
requestTime
);
adStatusCallBack
.
onAdShow
(
Constants
.
NODE_SHOW
,
"interstitial"
,
"show"
,
requestTime
,
scenario
);
}
AdManager
.
getInstance
().
saveAdExpCount
();
}
@Override
public
void
onInterstitialAdClose
(
AT
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdClose "
+
" "
+
atAdInfo
.
getNetworkFirmId
());
public
void
onInterstitialAdClose
(
TU
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdClose "
+
PictureApplication
.
getApplication
().
getPackageName
()+
" "
+
atAdInfo
.
getNetworkFirmId
());
if
(
null
!=
adCallback
)
{
adCallback
.
onAdClose
(
Constants
.
NODE_CLOSE_EID
,
"interstitial"
,
"close type: "
+
atAdInfo
.
getDismissType
(),
-
1
);
adCallback
=
null
;
}
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdDismiss
(
Constants
.
NODE_CLOSE
,
"interstitial"
,
"close type: "
+
atAdInfo
.
getDismissType
(),
-
1
);
adStatusCallBack
.
onAdDismiss
(
Constants
.
NODE_CLOSE
,
"interstitial"
,
"close type: "
+
atAdInfo
.
getDismissType
(),
-
1
,
scenario
);
}
clearAdLoadedCallback
();
loadAd
();
...
...
@@ -136,19 +143,19 @@ public class InterstitialAdManager {
}
@Override
public
void
onInterstitialAdVideoStart
(
AT
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdVideoStart: "
+
" "
+
atAdInfo
.
getNetworkFirmId
());
public
void
onInterstitialAdVideoStart
(
TU
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdVideoStart: "
+
PictureApplication
.
getApplication
().
getPackageName
()+
" "
+
atAdInfo
.
getNetworkFirmId
());
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onInterstitialAdVideoStart
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_START
,
"interstitial"
,
"start video"
,
-
1
);
adStatusCallBack
.
onInterstitialAdVideoStart
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_START
,
"interstitial"
,
"start video"
,
-
1
,
scenario
);
}
}
@Override
public
void
onInterstitialAdVideoEnd
(
AT
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdVideoEnd: "
);
public
void
onInterstitialAdVideoEnd
(
TU
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdVideoEnd: "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onInterstitialAdVideoEnd
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_END
,
"interstitial"
,
"end video"
,
-
1
);
adStatusCallBack
.
onInterstitialAdVideoEnd
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_END
,
"interstitial"
,
"end video"
,
-
1
,
scenario
);
}
}
...
...
@@ -157,101 +164,166 @@ public class InterstitialAdManager {
//AdError,请参考 https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
ALog
.
w
(
TAG
,
"onInterstitialAdVideoError:"
+
adError
.
getFullErrorInfo
());
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onInterstitialAdVideoError
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_ERROR
,
"interstitial"
,
"error video: "
+
adError
.
getFullErrorInfo
(),
-
1
);
adStatusCallBack
.
onInterstitialAdVideoError
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_ERROR
,
"interstitial"
,
"error video: "
+
adError
.
getFullErrorInfo
(),
-
1
,
scenario
);
}
}
});
}
}
public
int
loadAd
(
String
sAdId
)
{
InterstitialAdManager
.
sAdId
=
sAdId
;
int
status
=
loadAd
();
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"status"
,
String
.
valueOf
(
status
));
map
.
put
(
"type"
,
"interstitial"
);
StatsStaticHelper
.
onEvent
(
Constants
.
NODE_AD_REQ_STATUS
,
map
);
return
status
;
public
int
loadAd
()
{
// Map<String, String> map = new HashMap<>();
// map.put("status", String.valueOf(status));
// map.put("type", "interstitial");
// StatsStaticHelper.onEvent(Constants.NODE_AD_REQ_STATUS, map);
return
loadAd
(
loadIndex
);
}
private
volatile
long
lastAdRequestTime
=
0
;
private
static
final
long
MIN_REQUEST_INTERVAL
=
1000
;
private
static
final
long
MIN_REQUEST_INTERVAL
=
200
;
public
int
loadIndex
=
0
;
private
int
loadAd
()
{
public
int
loadAd
(
String
adId
)
{
// 检查初始化状态
if
(!
CpAdData
.
adInitSuccess
)
{
return
-
11
;
}
ALog
.
w
(
TAG
,
" mInterstitialAd start load"
);
if
(
mInterstitialAd
!=
null
)
{
// 5. 检查广告状态
TUAdStatusInfo
status
=
mInterstitialAd
.
checkAdStatus
();
ALog
.
w
(
TAG
,
"status = "
+
status
);
// 6. 处理不同状态
if
(
status
.
isReady
())
{
ALog
.
w
(
TAG
,
"mInterstitialAd is Ready"
);
return
0
;
}
if
(
status
.
isLoading
())
{
return
-
10
;
}
}
if
(!
canRequestAd
())
{
return
-
8
;
}
sAdId
=
adId
;
if
(
TextUtils
.
isEmpty
(
sAdId
))
{
AdData
adData
=
CpAdData
.
getInstance
().
getAdData
(
CP_TOPON
);
if
(
adData
==
null
)
{
ALog
.
w
(
TAG
,
" sAdId get adData == null"
);
return
-
2
;
}
sAdId
=
adData
.
getAdAdId
(
AdData
.
AD_TYPE_INTERSTITIAL
,
loadIndex
);
}
if
(
TextUtils
.
isEmpty
(
sAdId
))
{
ALog
.
w
(
TAG
,
" sAdId is null "
);
this
.
loadIndex
=
0
;
return
-
1
;
}
if
(
mInterstitialAd
!=
null
&&
!
sAdId
.
equals
(
mInterstitialAd
.
mPlacementId
))
{
mInterstitialAd
=
null
;
}
if
(
ensureAdInitialized
())
{
ALog
.
w
(
TAG
,
" mInterstitialAd == null"
+
" "
+
PictureApplication
.
getApplication
().
getPackageName
());
return
-
3
;
}
executeAdLoad
();
return
1
;
}
private
int
loadAd
(
int
loadIndex
)
{
// 检查初始化状态
if
(!
CpAdData
.
adInitSuccess
)
{
return
-
11
;
}
ALog
.
w
(
TAG
,
" mInterstitialAd start load"
);
if
(
mInterstitialAd
!=
null
)
{
// 5. 检查广告状态
TUAdStatusInfo
status
=
mInterstitialAd
.
checkAdStatus
();
ALog
.
w
(
TAG
,
"status = "
+
status
);
// 6. 处理不同状态
if
(
status
.
isReady
())
{
ALog
.
w
(
TAG
,
"mInterstitialAd is Ready"
);
return
0
;
}
if
(
status
.
isLoading
())
{
return
-
10
;
}
}
if
(!
canRequestAd
())
{
return
-
8
;
}
AdData
adData
=
CpAdData
.
getInstance
().
getAdData
(
CP_TOPON
);
if
(
adData
==
null
)
{
ALog
.
w
(
TAG
,
" sAdId get adData == null"
);
return
-
2
;
}
if
(
TextUtils
.
isEmpty
(
sAdId
)
&&
null
!=
adData
)
{
sAdId
=
adData
.
getAdAdId
(
AdData
.
AD_TYPE_INTERSTITIAL
);
}
sAdId
=
adData
.
getAdAdId
(
AdData
.
AD_TYPE_INTERSTITIAL
,
loadIndex
);
if
(
TextUtils
.
isEmpty
(
sAdId
))
{
ALog
.
w
(
TAG
,
" sAdId is null "
);
this
.
loadIndex
=
0
;
return
-
1
;
}
if
(
mInterstitialAd
!=
null
&&
!
sAdId
.
equals
(
mInterstitialAd
.
mPlacementId
))
{
mInterstitialAd
=
null
;
}
if
(
null
!=
adData
&&
!
adData
.
canLoadAdData
(
AdData
.
AD_TYPE_INTERSTITIAL
))
{
ALog
.
w
(
TAG
,
"
canLoadAdData mInterstitialAd == false"
);
return
-
2
;
if
(
ensureAdInitialized
(
))
{
ALog
.
w
(
TAG
,
"
mInterstitialAd == null"
+
" "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
return
-
3
;
}
// 7. 执行广告加载
this
.
loadIndex
=
loadIndex
+
1
;
executeAdLoad
();
return
1
;
}
private
boolean
ensureAdInitialized
()
{
if
(
mInterstitialAd
==
null
)
{
initATInterstitial
();
}
if
(
mInterstitialAd
==
null
)
{
ALog
.
w
(
TAG
,
" mInterstitialAd == null"
+
" "
);
return
-
3
;
return
mInterstitialAd
==
null
;
}
private
boolean
canRequestAd
()
{
// 检查请求间隔
long
currentTime
=
System
.
currentTimeMillis
();
if
(
Math
.
abs
(
currentTime
-
lastAdRequestTime
)
<
MIN_REQUEST_INTERVAL
)
{
return
false
;
}
ATAdStatusInfo
atAdStatusInfo
=
mInterstitialAd
.
checkAdStatus
();
ALog
.
w
(
TAG
,
"mInterstitialAd atAdStatusInfo: "
+
atAdStatusInfo
+
" "
+
mInterstitialAd
);
if
(
atAdStatusInfo
.
isReady
())
{
ALog
.
w
(
TAG
,
"mInterstitialAd is Ready"
);
}
else
if
(!
atAdStatusInfo
.
isLoading
())
{
long
currentTime
=
System
.
currentTimeMillis
();
if
(
Math
.
abs
(
currentTime
-
lastAdRequestTime
)
<
MIN_REQUEST_INTERVAL
)
{
return
-
8
;
}
lastAdRequestTime
=
currentTime
;
if
(!
AdManager
.
getInstance
().
isCanNextAdRequest
())
{
return
-
4
;
}
// if (!NetworkUtils.isConnected(A.getContext())) {
// return -5;
// }
if
(!
CpAdData
.
adInitSuccess
)
{
return
-
6
;
}
mInterstitialAd
.
load
();
AdReqHasCallBackUtil
.
setValue
(
System
.
currentTimeMillis
());
requestTime
=
System
.
currentTimeMillis
();
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdLoad
(
Constants
.
NODE_REQUEST
,
"interstitial"
,
"load"
,
-
1
);
}
ALog
.
w
(
TAG
,
"mInterstitialAd end load"
);
return
1
;
}
else
{
ALog
.
w
(
TAG
,
"mInterstitialAd is loading"
);
return
-
7
;
// 检查是否允许请求
if
(!
AdManager
.
getInstance
().
isCanNextAdRequest
())
{
return
false
;
}
return
0
;
lastAdRequestTime
=
currentTime
;
return
true
;
}
public
void
showAd
(
Activity
activity
)
{
private
void
executeAdLoad
()
{
mInterstitialAd
.
load
();
// 记录请求时间
AdReqHasCallBackUtil
.
setValue
(
System
.
currentTimeMillis
());
requestTime
=
System
.
currentTimeMillis
();
// 回调通知
if
(
adStatusCallBack
!=
null
)
{
adStatusCallBack
.
onAdLoad
(
Constants
.
NODE_REQUEST
,
"interstitial"
,
"load"
,
-
1
,
Constants
.
SCENARIO_CHAPIN
);
}
ALog
.
w
(
TAG
,
"mInterstitialAd end load"
);
}
public
void
showAd
(
Activity
activity
,
String
scenario
)
{
if
(!
AdUtils
.
getInstance
().
enableShowAd
())
{
if
(
activity
.
isFinishing
()
||
activity
.
isDestroyed
())
{
return
;
}
// Context context = A.getContext();
// if (context instanceof A) {
// if (((A)context).activityIsClose()) {
// return;
// }
// }
}
if
(!
TextUtils
.
isEmpty
(
sAdId
))
{
AT
Interstitial
.
entryAdScenario
(
sAdId
,
"f65bf35b235ce0"
);
TU
Interstitial
.
entryAdScenario
(
sAdId
,
"f65bf35b235ce0"
);
}
this
.
scenario
=
scenario
;
if
(
null
!=
mInterstitialAd
&&
mInterstitialAd
.
isAdReady
())
{
mInterstitialAd
.
show
(
activity
,
"f65bf35b235ce0"
);
}
...
...
@@ -265,7 +337,7 @@ public class InterstitialAdManager {
if
(
null
==
mInterstitialAd
)
{
return
false
;
}
AT
AdStatusInfo
atAdStatusInfo
=
mInterstitialAd
.
checkAdStatus
();
TU
AdStatusInfo
atAdStatusInfo
=
mInterstitialAd
.
checkAdStatus
();
if
(
atAdStatusInfo
==
null
)
{
return
false
;
}
...
...
@@ -292,17 +364,4 @@ public class InterstitialAdManager {
this
.
adStatusCallBack
=
adStatusCallBack
;
}
public
static
void
setsAdId
(
String
sAdId
)
{
InterstitialAdManager
.
sAdId
=
sAdId
;
}
public
static
String
getsAdId
()
{
return
sAdId
;
}
public
static
boolean
adIdIsNullOrEmpty
()
{
return
TextUtils
.
isEmpty
(
sAdId
);
}
}
media_app/src/main/java/com/gem/media/ad/InterstitialAdStatusCallBack.java
View file @
bf7ccfd2
...
...
@@ -4,7 +4,8 @@ public interface InterstitialAdStatusCallBack extends AdStatusCallBack{
void
onInterstitialAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onInterstitialAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onInterstitialAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onInterstitialAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onInterstitialAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onInterstitialAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
}
media_app/src/main/java/com/gem/media/ad/InterstitialHalfAdManager.java
View file @
bf7ccfd2
...
...
@@ -6,17 +6,17 @@ import android.app.Activity;
import
android.text.TextUtils
;
import
com.ads.cal.picturetranslate.PictureApplication
;
import
com.anythink.core.api.ATAdInfo
;
import
com.anythink.core.api.ATAdStatusInfo
;
import
com.anythink.core.api.AdError
;
import
com.anythink.interstitial.api.ATInterstitial
;
import
com.anythink.interstitial.api.ATInterstitialListener
;
import
com.gem.media.AdReqHasCallBackUtil
;
import
com.gem.media.NativeAdWindManager
;
import
com.gem.media.NetworkUtils
;
import
com.gem.media.StatsStaticHelper
;
import
com.gem.media.splash.base.protocol.Constants
;
import
com.gem.media.splash.base.utils.ALog
;
import
com.thinkup.core.api.AdError
;
import
com.thinkup.core.api.TUAdInfo
;
import
com.thinkup.core.api.TUAdStatusInfo
;
import
com.thinkup.interstitial.api.TUInterstitial
;
import
com.thinkup.interstitial.api.TUInterstitialListener
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -35,7 +35,7 @@ public class InterstitialHalfAdManager {
}
//注意:广告对象必须要全局引用,如果广告对象是临时变量会导致广告加载过程中有可能被回收,无法接收广告事件回调
private
static
AT
Interstitial
mInterstitialAd
;
private
static
TU
Interstitial
mInterstitialAd
;
private
static
String
sAdId
;
...
...
@@ -44,16 +44,16 @@ public class InterstitialHalfAdManager {
return
;
}
if
(
null
==
mInterstitialAd
)
{
mInterstitialAd
=
new
AT
Interstitial
(
PictureApplication
.
getApplication
(),
sAdId
);
mInterstitialAd
.
setAdListener
(
new
AT
InterstitialListener
()
{
mInterstitialAd
=
new
TU
Interstitial
(
PictureApplication
.
getApplication
(),
sAdId
);
mInterstitialAd
.
setAdListener
(
new
TU
InterstitialListener
()
{
@Override
public
void
onInterstitialAdLoaded
()
{
AdReqHasCallBackUtil
.
setValue
(-
1
);
ALog
.
w
(
TAG
,
"--------onInterstitialAdLoaded ------- "
);
ALog
.
w
(
TAG
,
"--------onInterstitialAdLoaded ------- "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS
,
"half_interstitial"
,
"loaded"
,
requestTime
);
adStatusCallBack
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS
,
"half_interstitial"
,
"loaded"
,
requestTime
,
Constants
.
SCENARIO_4
);
}
requestTime
=
System
.
currentTimeMillis
();
}
...
...
@@ -63,27 +63,27 @@ public class InterstitialHalfAdManager {
AdReqHasCallBackUtil
.
setValue
(-
1
);
//注意:禁止在此回调中执行广告的加载方法进行重试,否则会引起很多无用请求且可能会导致应用卡顿
//AdError,请参考 https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
ALog
.
e
(
TAG
,
"onInterstitialAdLoadFail: "
+
adError
.
getFullErrorInfo
()
+
" "
);
ALog
.
e
(
TAG
,
"onInterstitialAdLoadFail: "
+
adError
.
getFullErrorInfo
()
+
" "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
String
reason
=
"interstitial "
+
"code: "
+
adError
.
getCode
()
+
" msg: "
+
adError
.
getFullErrorInfo
();
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onNoAdError
(
Constants
.
NODE_ERROR
,
"half_interstitial"
,
reason
,
requestTime
);
adStatusCallBack
.
onNoAdError
(
Constants
.
NODE_ERROR
,
"half_interstitial"
,
reason
,
requestTime
,
Constants
.
SCENARIO_4
);
}
}
@Override
public
void
onInterstitialAdClicked
(
AT
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdClicked "
);
public
void
onInterstitialAdClicked
(
TU
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdClicked "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdClick
(
Constants
.
NODE_CLICK
,
"half_interstitial"
,
"click"
,
-
1
);
adStatusCallBack
.
onAdClick
(
Constants
.
NODE_CLICK
,
"half_interstitial"
,
"click"
,
-
1
,
Constants
.
SCENARIO_4
);
}
}
@Override
public
void
onInterstitialAdShow
(
AT
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdShow "
public
void
onInterstitialAdShow
(
TU
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdShow "
+
PictureApplication
.
getApplication
().
getPackageName
()
+
" "
+
atAdInfo
.
getAdsourceId
()
+
" "
+
atAdInfo
.
getChannel
()
+
" "
+
atAdInfo
.
getSubChannel
()
...
...
@@ -94,15 +94,15 @@ public class InterstitialHalfAdManager {
//建议在此回调中调用load进行广告的加载,方便下一次广告的展示(不需要调用isAdReady())
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdShow
(
Constants
.
NODE_SHOW
,
"half_interstitial"
,
"show"
,
requestTime
);
adStatusCallBack
.
onAdShow
(
Constants
.
NODE_SHOW
,
"half_interstitial"
,
"show"
,
requestTime
,
Constants
.
SCENARIO_4
);
}
}
@Override
public
void
onInterstitialAdClose
(
AT
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdClose "
+
" "
+
atAdInfo
.
getNetworkFirmId
());
public
void
onInterstitialAdClose
(
TU
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdClose "
+
PictureApplication
.
getApplication
().
getPackageName
()
+
" "
+
atAdInfo
.
getNetworkFirmId
());
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdDismiss
(
Constants
.
NODE_CLOSE
,
"half_interstitial"
,
"close type: "
+
atAdInfo
.
getDismissType
(),
-
1
);
adStatusCallBack
.
onAdDismiss
(
Constants
.
NODE_CLOSE
,
"half_interstitial"
,
"close type: "
+
atAdInfo
.
getDismissType
(),
-
1
,
Constants
.
SCENARIO_4
);
}
NativeAdWindManager
.
getInstance
().
removeNativeAd
();
loadAd
();
...
...
@@ -110,19 +110,19 @@ public class InterstitialHalfAdManager {
}
@Override
public
void
onInterstitialAdVideoStart
(
AT
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdVideoStart: "
+
" "
+
atAdInfo
.
getNetworkFirmId
());
public
void
onInterstitialAdVideoStart
(
TU
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdVideoStart: "
+
PictureApplication
.
getApplication
().
getPackageName
()
+
" "
+
atAdInfo
.
getNetworkFirmId
());
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onInterstitialAdVideoStart
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_START
,
"half_interstitial"
,
"start video"
,
-
1
);
adStatusCallBack
.
onInterstitialAdVideoStart
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_START
,
"half_interstitial"
,
"start video"
,
-
1
,
Constants
.
SCENARIO_4
);
}
}
@Override
public
void
onInterstitialAdVideoEnd
(
AT
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdVideoEnd: "
);
public
void
onInterstitialAdVideoEnd
(
TU
AdInfo
atAdInfo
)
{
ALog
.
w
(
TAG
,
"onInterstitialAdVideoEnd: "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onInterstitialAdVideoEnd
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_END
,
"half_interstitial"
,
"end video"
,
-
1
);
adStatusCallBack
.
onInterstitialAdVideoEnd
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_END
,
"half_interstitial"
,
"end video"
,
-
1
,
Constants
.
SCENARIO_4
);
}
}
...
...
@@ -131,7 +131,7 @@ public class InterstitialHalfAdManager {
//AdError,请参考 https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
ALog
.
w
(
TAG
,
"onInterstitialAdVideoError:"
+
adError
.
getFullErrorInfo
());
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onInterstitialAdVideoError
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_ERROR
,
"half_interstitial"
,
"error video: "
+
adError
.
getFullErrorInfo
(),
-
1
);
adStatusCallBack
.
onInterstitialAdVideoError
(
Constants
.
NODE_INTERSTITIAL_AD_VIDEO_ERROR
,
"half_interstitial"
,
"error video: "
+
adError
.
getFullErrorInfo
(),
-
1
,
Constants
.
SCENARIO_4
);
}
}
});
...
...
@@ -165,7 +165,7 @@ public class InterstitialHalfAdManager {
return
-
1
;
}
if
(
null
!=
adData
&&
!
adData
.
canLoadAdData
(
AdData
.
AD_TYPE_HALF_INTERSTITIAL
)
)
{
if
(
null
!=
adData
)
{
ALog
.
w
(
TAG
,
" canLoadAdData half_interstitial == false"
);
return
-
2
;
}
...
...
@@ -174,10 +174,10 @@ public class InterstitialHalfAdManager {
initATInterstitial
();
}
if
(
mInterstitialAd
==
null
)
{
ALog
.
w
(
TAG
,
" half_interstitial == null"
+
" "
);
ALog
.
w
(
TAG
,
" half_interstitial == null"
+
" "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
return
-
3
;
}
AT
AdStatusInfo
atAdStatusInfo
=
mInterstitialAd
.
checkAdStatus
();
TU
AdStatusInfo
atAdStatusInfo
=
mInterstitialAd
.
checkAdStatus
();
ALog
.
w
(
TAG
,
"half_interstitial atAdStatusInfo: "
+
atAdStatusInfo
+
" "
+
mInterstitialAd
);
if
(
atAdStatusInfo
.
isReady
())
{
ALog
.
w
(
TAG
,
"half_interstitial is Ready"
);
...
...
@@ -190,7 +190,7 @@ public class InterstitialHalfAdManager {
if
(!
AdManager
.
getInstance
().
isCanNextAdRequest
())
{
return
-
4
;
}
// if (!NetworkUtils.isConnected(
A.getContext
())) {
// if (!NetworkUtils.isConnected(
PictureApplication.getApplication
())) {
// return -5;
// }
if
(!
CpAdData
.
adInitSuccess
)
{
...
...
@@ -200,7 +200,7 @@ public class InterstitialHalfAdManager {
AdReqHasCallBackUtil
.
setValue
(
System
.
currentTimeMillis
());
requestTime
=
System
.
currentTimeMillis
();
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdLoad
(
Constants
.
NODE_REQUEST
,
"half_interstitial"
,
"load"
,
-
1
);
adStatusCallBack
.
onAdLoad
(
Constants
.
NODE_REQUEST
,
"half_interstitial"
,
"load"
,
-
1
,
Constants
.
SCENARIO_4
);
}
ALog
.
w
(
TAG
,
"half_interstitial end load"
);
return
1
;
...
...
@@ -224,7 +224,7 @@ public class InterstitialHalfAdManager {
return
;
}
if
(!
TextUtils
.
isEmpty
(
sAdId
))
{
AT
Interstitial
.
entryAdScenario
(
sAdId
,
"f65bf35b235ce0"
);
TU
Interstitial
.
entryAdScenario
(
sAdId
,
"f65bf35b235ce0"
);
}
if
(
null
!=
mInterstitialAd
&&
mInterstitialAd
.
isAdReady
())
{
mInterstitialAd
.
show
(
activity
,
"f65bf35b235ce0"
);
...
...
media_app/src/main/java/com/gem/media/ad/NativeAdClearManager.java
0 → 100644
View file @
bf7ccfd2
package
com
.
gem
.
media
.
ad
;
import
static
com
.
gem
.
media
.
ad
.
CpAdData
.
CP_TOPON
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
android.view.View
;
import
com.ads.cal.picturetranslate.PictureApplication
;
import
com.gem.media.StatsStaticHelper
;
import
com.gem.media.splash.base.protocol.AdCallback
;
import
com.gem.media.splash.base.protocol.Constants
;
import
com.gem.media.splash.base.utils.ALog
;
import
com.thinkup.core.api.AdError
;
import
com.thinkup.core.api.TUAdInfo
;
import
com.thinkup.core.api.TUAdStatusInfo
;
import
com.thinkup.nativead.api.NativeAd
;
import
com.thinkup.nativead.api.TUNative
;
import
com.thinkup.nativead.api.TUNativeAdView
;
import
com.thinkup.nativead.api.TUNativeDislikeListener
;
import
com.thinkup.nativead.api.TUNativeEventExListener
;
import
com.thinkup.nativead.api.TUNativeNetworkListener
;
import
com.thinkup.nativead.api.TUNativePrepareInfo
;
import
com.thinkup.nativead.api.TUNativeView
;
import
java.util.List
;
public
class
NativeAdClearManager
{
private
static
final
String
TAG
=
"NativeAdManager"
;
private
static
NativeCleanAdStatusCallBack
adStatusCallBack
;
public
static
final
String
P_1
=
"1"
;
public
static
final
String
P_2
=
"2"
;
public
static
final
String
P_3
=
"3"
;
private
long
requestTime
=
-
1
;
private
static
String
sAdId
;
private
TUNative
mATNative
;
private
NativeAd
mNativeAd
;
private
AdCallback
adCallback
;
private
String
adPosition
;
public
void
setAdCallback
(
AdCallback
adCallback
)
{
this
.
adCallback
=
adCallback
;
}
private
void
initNative
(
Context
context
,
String
nativeTopOnPlacementID
)
{
if
(
mATNative
==
null
)
{
//初始化广告加载对象
mATNative
=
new
TUNative
(
context
,
nativeTopOnPlacementID
,
new
TUNativeNetworkListener
()
{
@Override
public
void
onNativeAdLoaded
()
{
ALog
.
i
(
TAG
,
"onNativeAdLoaded"
);
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS
,
AdData
.
AD_TYPE_NATIVE
,
"loaded"
,
requestTime
,
nativeTopOnPlacementID
,
Constants
.
SCENARIO_NATIVE_CLEAR
,
adPosition
);
}
if
(
null
!=
adCallback
)
{
adCallback
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS_EID
,
AdData
.
AD_TYPE_NATIVE
,
"loaded"
,
requestTime
);
}
requestTime
=
System
.
currentTimeMillis
();
}
@Override
public
void
onNativeAdLoadFail
(
AdError
adError
)
{
//注意:禁止在此回调中执行广告的加载方法进行重试,否则会引起很多无用请求且可能会导致应用卡顿
//AdError,请参考 https://newdocs.toponad.com/docs/55cxNt
ALog
.
i
(
TAG
,
"onNativeAdLoadFail:"
+
adError
.
getFullErrorInfo
());
String
reason
=
"interstitial "
+
"code: "
+
adError
.
getCode
()
+
" msg: "
+
adError
.
getFullErrorInfo
();
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onNoAdError
(
Constants
.
NODE_ERROR
,
AdData
.
AD_TYPE_NATIVE
,
reason
,
requestTime
,
nativeTopOnPlacementID
,
Constants
.
SCENARIO_NATIVE_CLEAR
);
}
if
(
null
!=
adCallback
)
{
adCallback
.
onAdError
(
Constants
.
NODE_ERROR_EID
,
AdData
.
AD_TYPE_NATIVE
,
reason
,
requestTime
);
}
}
});
}
// atNative.setAdSourceStatusListener(new ATAdSourceStatusListenerImpl());
}
private
volatile
long
lastAdRequestTime
=
0
;
private
static
final
long
MIN_REQUEST_INTERVAL
=
1000
;
public
int
loadAd
()
{
AdData
adData
=
CpAdData
.
getInstance
().
getAdData
(
CP_TOPON
);
if
(
adData
==
null
)
{
ALog
.
w
(
TAG
,
" mATNative sAdId get adData == null"
);
}
if
(
TextUtils
.
isEmpty
(
sAdId
)
&&
null
!=
adData
)
{
sAdId
=
adData
.
getAdAdId
(
AdData
.
AD_TYPE_NATIVE
);
}
if
(
TextUtils
.
isEmpty
(
sAdId
))
{
ALog
.
w
(
TAG
,
" mATNative sAdId is null "
);
return
-
1
;
}
initNative
(
PictureApplication
.
getApplication
(),
sAdId
);
if
(
mATNative
==
null
)
{
ALog
.
w
(
TAG
,
" mATNative == null"
+
" "
+
PictureApplication
.
getApplication
().
getPackageName
());
return
-
3
;
}
TUAdStatusInfo
atAdStatusInfo
=
mATNative
.
checkAdStatus
();
if
(
atAdStatusInfo
.
isReady
())
{
ALog
.
w
(
TAG
,
"mATNative is Ready"
);
}
else
if
(!
atAdStatusInfo
.
isLoading
())
{
long
currentTime
=
System
.
currentTimeMillis
();
if
(
Math
.
abs
(
currentTime
-
lastAdRequestTime
)
<
MIN_REQUEST_INTERVAL
)
{
return
-
8
;
}
lastAdRequestTime
=
currentTime
;
// if (!NetworkUtils.isConnected(PictureApplication.getApplication())) {
// StatsStaticHelper.onEvent(Constants.NODE_AD_REQ_NOT_NET, "mATNative");
// return -5;
// }
if
(!
CpAdData
.
adInitSuccess
)
{
StatsStaticHelper
.
onEvent
(
Constants
.
NODE_AD_NOT_INIT
,
"mATNative"
);
return
-
6
;
}
// final int adViewWidth = PictureApplication.getApplication().getResources().getDisplayMetrics().widthPixels;
// final int adViewHeight = adViewWidth * 3 / 4;
// Map<String, Object> localExtra = new HashMap<>();
// localExtra.put(ATAdConst.KEY.AD_WIDTH, adViewWidth);//单位:px,期望展示广告的宽度
// localExtra.put(ATAdConst.KEY.AD_HEIGHT, adViewHeight);//单位:px,期望展示广告的高度
// mATNative.setLocalExtra(localExtra);
//发起广告请求
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdLoad
(
Constants
.
NODE_REQUEST
,
AdData
.
AD_TYPE_NATIVE
,
"load"
,
-
1
,
Constants
.
SCENARIO_NATIVE_CLEAR
,
adPosition
);
}
mATNative
.
makeAdRequest
();
ALog
.
w
(
TAG
,
"mATNative end load"
);
return
1
;
}
else
{
ALog
.
w
(
TAG
,
"mATNative is loading"
);
return
-
7
;
}
return
0
;
}
public
boolean
isNativeAdReady
()
{
if
(
mATNative
==
null
)
{
return
false
;
}
boolean
isReady
=
mATNative
.
checkAdStatus
().
isReady
();
ALog
.
i
(
TAG
,
"isAdReady: "
+
isReady
);
List
<
TUAdInfo
>
atAdInfoList
=
mATNative
.
checkValidAdCaches
();
ALog
.
i
(
TAG
,
"Valid Cahce size:"
+
(
atAdInfoList
!=
null
?
atAdInfoList
.
size
()
:
0
));
if
(
atAdInfoList
!=
null
)
{
for
(
TUAdInfo
adInfo
:
atAdInfoList
)
{
ALog
.
i
(
TAG
,
"Cahce detail:"
+
adInfo
.
toString
());
}
}
return
isReady
;
}
public
void
showAd
(
TUNativeView
mATNativeView
,
View
mSelfRenderView
)
{
if
(!
isNativeAdReady
())
{
return
;
}
ALog
.
i
(
TAG
,
"showAd"
);
// NativeAd nativeAd = mATNative.getNativeAd();
NativeAd
nativeAd
=
mATNative
.
getNativeAd
(
AdConst
.
SCENARIO_ID
.
NATIVE_AD_SCENARIO
);
if
(
nativeAd
!=
null
)
{
if
(
mNativeAd
!=
null
)
{
mNativeAd
.
destory
();
}
mNativeAd
=
nativeAd
;
mNativeAd
.
setNativeEventListener
(
new
TUNativeEventExListener
()
{
@Override
public
void
onDeeplinkCallback
(
TUNativeAdView
view
,
TUAdInfo
adInfo
,
boolean
isSuccess
)
{
ALog
.
i
(
TAG
,
"onDeeplinkCallback:"
+
adInfo
.
toString
()
+
"--status:"
+
isSuccess
);
}
@Override
public
void
onAdImpressed
(
TUNativeAdView
view
,
TUAdInfo
entity
)
{
ALog
.
i
(
TAG
,
"native ad onAdImpressed:\n"
+
entity
.
toString
());
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdShow
(
Constants
.
NODE_SHOW
,
AdData
.
AD_TYPE_NATIVE
,
"show"
,
requestTime
,
Constants
.
SCENARIO_NATIVE_CLEAR
,
adPosition
);
}
if
(
null
!=
adCallback
)
{
adCallback
.
onAdShow
(
Constants
.
NODE_CLOSE_EID
,
AdData
.
AD_TYPE_NATIVE
,
"show"
,
-
1
);
adCallback
=
null
;
}
}
@Override
public
void
onAdClicked
(
TUNativeAdView
view
,
TUAdInfo
entity
)
{
ALog
.
i
(
TAG
,
"native ad onAdClicked:\n"
+
entity
.
toString
());
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdClick
(
Constants
.
NODE_CLICK
,
AdData
.
AD_TYPE_NATIVE
,
"click"
,
-
1
,
Constants
.
SCENARIO_NATIVE_CLEAR
,
adPosition
);
}
if
(
null
!=
adCallback
)
{
adCallback
.
onAdClick
(
Constants
.
NODE_CLICK_EID
,
AdData
.
AD_TYPE_NATIVE
,
"click"
,
-
1
);
}
}
@Override
public
void
onAdVideoStart
(
TUNativeAdView
view
)
{
ALog
.
i
(
TAG
,
"native ad onAdVideoStart"
);
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onNativeAdVideoStart
(
Constants
.
NODE_NATIVE_AD_VIDEO_START
,
"native"
,
"start video"
,
-
1
,
Constants
.
SCENARIO_NATIVE_CLEAR
);
}
}
@Override
public
void
onAdVideoEnd
(
TUNativeAdView
view
)
{
ALog
.
i
(
TAG
,
"native ad onAdVideoEnd"
);
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onNativeAdVideoEnd
(
Constants
.
NODE_NATIVE_AD_VIDEO_END
,
"native"
,
"end video"
,
-
1
,
Constants
.
SCENARIO_NATIVE_CLEAR
);
}
}
@Override
public
void
onAdVideoProgress
(
TUNativeAdView
view
,
int
progress
)
{
ALog
.
i
(
TAG
,
"native ad onAdVideoProgress:"
+
progress
);
}
});
mNativeAd
.
setDislikeCallbackListener
(
new
TUNativeDislikeListener
()
{
@Override
public
void
onAdCloseButtonClick
(
TUNativeAdView
view
,
TUAdInfo
entity
)
{
ALog
.
i
(
TAG
,
"native ad onAdCloseButtonClick"
);
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdDismiss
(
Constants
.
NODE_CLOSE
,
AdData
.
AD_TYPE_NATIVE
,
"close type: "
+
entity
.
getDismissType
(),
-
1
,
Constants
.
SCENARIO_NATIVE_CLEAR
,
adPosition
);
}
destroyAd
();
}
});
ALog
.
i
(
TAG
,
"showAd start"
);
mATNativeView
.
removeAllViews
();
TUNativePrepareInfo
mNativePrepareInfo
=
null
;
try
{
mNativePrepareInfo
=
new
TUNativePrepareInfo
();
if
(
mNativeAd
.
isNativeExpress
())
{
mNativeAd
.
renderAdContainer
(
mATNativeView
,
null
);
ALog
.
i
(
TAG
,
"isNativeExpress"
);
}
else
{
SelfRenderViewUtil
.
bindSelfRenderView
(
PictureApplication
.
getApplication
(),
mNativeAd
.
getAdMaterial
(),
mSelfRenderView
,
mNativePrepareInfo
);
mNativeAd
.
renderAdContainer
(
mATNativeView
,
mSelfRenderView
);
ALog
.
i
(
TAG
,
"isSelfNativeExpress"
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
ALog
.
i
(
TAG
,
"showAd end"
);
mNativeAd
.
prepare
(
mATNativeView
,
mNativePrepareInfo
);
mATNativeView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
ALog
.
i
(
TAG
,
"this placement no cache!"
);
}
}
public
void
destroyAd
()
{
if
(
mNativeAd
!=
null
)
{
mNativeAd
.
destory
();
}
if
(
mATNative
!=
null
)
{
mATNative
.
setAdListener
(
null
);
mATNative
.
setAdSourceStatusListener
(
null
);
}
}
public
static
void
setAdStatusCallBack
(
NativeCleanAdStatusCallBack
adStatusCallBack
)
{
if
(
null
==
NativeAdClearManager
.
adStatusCallBack
)
{
NativeAdClearManager
.
adStatusCallBack
=
adStatusCallBack
;
}
}
public
void
setAdPosition
(
String
adPosition
)
{
this
.
adPosition
=
adPosition
;
}
public
String
getAdPosition
()
{
return
adPosition
;
}
}
media_app/src/main/java/com/gem/media/ad/NativeAdManager.java
View file @
bf7ccfd2
...
...
@@ -7,23 +7,23 @@ import android.text.TextUtils;
import
android.view.View
;
import
com.ads.cal.picturetranslate.PictureApplication
;
import
com.anythink.core.api.ATAdInfo
;
import
com.anythink.core.api.ATAdStatusInfo
;
import
com.anythink.core.api.AdError
;
import
com.anythink.nativead.api.ATNative
;
import
com.anythink.nativead.api.ATNativeAdView
;
import
com.anythink.nativead.api.ATNativeDislikeListener
;
import
com.anythink.nativead.api.ATNativeEventExListener
;
import
com.anythink.nativead.api.ATNativeNetworkListener
;
import
com.anythink.nativead.api.ATNativePrepareExInfo
;
import
com.anythink.nativead.api.ATNativePrepareInfo
;
import
com.anythink.nativead.api.ATNativeView
;
import
com.anythink.nativead.api.NativeAd
;
import
com.gem.media.NativeAdWindManager
;
import
com.gem.media.NetworkUtils
;
import
com.gem.media.StatsStaticHelper
;
import
com.gem.media.splash.base.protocol.AdCallback
;
import
com.gem.media.splash.base.protocol.Constants
;
import
com.gem.media.splash.base.utils.ALog
;
import
com.thinkup.core.api.AdError
;
import
com.thinkup.core.api.TUAdInfo
;
import
com.thinkup.core.api.TUAdStatusInfo
;
import
com.thinkup.nativead.api.NativeAd
;
import
com.thinkup.nativead.api.TUNative
;
import
com.thinkup.nativead.api.TUNativeAdView
;
import
com.thinkup.nativead.api.TUNativeDislikeListener
;
import
com.thinkup.nativead.api.TUNativeEventExListener
;
import
com.thinkup.nativead.api.TUNativeNetworkListener
;
import
com.thinkup.nativead.api.TUNativePrepareExInfo
;
import
com.thinkup.nativead.api.TUNativePrepareInfo
;
import
com.thinkup.nativead.api.TUNativeView
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -38,7 +38,7 @@ public class NativeAdManager {
}
public
static
NativeAdManager
getInstance
()
{
return
NativeAdManager
.
NativeAdManager
Holder
.
adManager
;
return
NativeAdManagerHolder
.
adManager
;
}
private
long
requestTime
=
-
1
;
...
...
@@ -46,19 +46,29 @@ public class NativeAdManager {
private
static
String
sAdId
;
private
AT
Native
mATNative
;
private
TU
Native
mATNative
;
private
NativeAd
mNativeAd
;
private
AdCallback
adCallback
;
public
void
setAdCallback
(
AdCallback
adCallback
)
{
this
.
adCallback
=
adCallback
;
}
private
void
initNative
(
Context
context
,
String
nativeTopOnPlacementID
)
{
if
(
mATNative
==
null
)
{
//初始化广告加载对象
mATNative
=
new
ATNative
(
context
,
nativeTopOnPlacementID
,
new
AT
NativeNetworkListener
()
{
mATNative
=
new
TUNative
(
context
,
nativeTopOnPlacementID
,
new
TU
NativeNetworkListener
()
{
@Override
public
void
onNativeAdLoaded
()
{
ALog
.
i
(
TAG
,
"onNativeAdLoaded"
);
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS
,
AdData
.
AD_TYPE_NATIVE
,
"loaded"
,
requestTime
);
adStatusCallBack
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS
,
AdData
.
AD_TYPE_NATIVE
,
"loaded"
,
requestTime
,
Constants
.
SCENARIO_NATIVE
);
}
if
(
null
!=
adCallback
)
{
adCallback
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS_EID
,
AdData
.
AD_TYPE_NATIVE
,
"loaded"
,
requestTime
);
}
requestTime
=
System
.
currentTimeMillis
();
}
...
...
@@ -71,7 +81,10 @@ public class NativeAdManager {
String
reason
=
"interstitial "
+
"code: "
+
adError
.
getCode
()
+
" msg: "
+
adError
.
getFullErrorInfo
();
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onNoAdError
(
Constants
.
NODE_ERROR
,
AdData
.
AD_TYPE_NATIVE
,
reason
,
requestTime
);
adStatusCallBack
.
onNoAdError
(
Constants
.
NODE_ERROR
,
AdData
.
AD_TYPE_NATIVE
,
reason
,
requestTime
,
Constants
.
SCENARIO_NATIVE
);
}
if
(
null
!=
adCallback
)
{
adCallback
.
onAdError
(
Constants
.
NODE_ERROR_EID
,
AdData
.
AD_TYPE_NATIVE
,
reason
,
requestTime
);
}
}
});
...
...
@@ -107,7 +120,7 @@ public class NativeAdManager {
return
-
1
;
}
if
(
null
!=
adData
&&
!
adData
.
canLoadAdData
(
AdData
.
AD_TYPE_NATIVE
)
)
{
if
(
null
!=
adData
)
{
ALog
.
w
(
TAG
,
" canLoadAdData mATNative == false"
);
return
-
2
;
}
...
...
@@ -115,10 +128,10 @@ public class NativeAdManager {
initNative
(
PictureApplication
.
getApplication
(),
sAdId
);
if
(
mATNative
==
null
)
{
ALog
.
w
(
TAG
,
" mATNative == null"
+
" "
);
ALog
.
w
(
TAG
,
" mATNative == null"
+
" "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
return
-
3
;
}
AT
AdStatusInfo
atAdStatusInfo
=
mATNative
.
checkAdStatus
();
TU
AdStatusInfo
atAdStatusInfo
=
mATNative
.
checkAdStatus
();
if
(
atAdStatusInfo
.
isReady
())
{
ALog
.
w
(
TAG
,
"mATNative is Ready"
);
}
else
if
(!
atAdStatusInfo
.
isLoading
())
{
...
...
@@ -149,7 +162,7 @@ public class NativeAdManager {
//发起广告请求
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdLoad
(
Constants
.
NODE_REQUEST
,
AdData
.
AD_TYPE_NATIVE
,
"load"
,
-
1
);
adStatusCallBack
.
onAdLoad
(
Constants
.
NODE_REQUEST
,
AdData
.
AD_TYPE_NATIVE
,
"load"
,
-
1
,
Constants
.
SCENARIO_NATIVE
);
}
mATNative
.
makeAdRequest
();
ALog
.
w
(
TAG
,
"mATNative end load"
);
...
...
@@ -169,10 +182,10 @@ public class NativeAdManager {
boolean
isReady
=
mATNative
.
checkAdStatus
().
isReady
();
ALog
.
i
(
TAG
,
"isAdReady: "
+
isReady
);
List
<
AT
AdInfo
>
atAdInfoList
=
mATNative
.
checkValidAdCaches
();
List
<
TU
AdInfo
>
atAdInfoList
=
mATNative
.
checkValidAdCaches
();
ALog
.
i
(
TAG
,
"Valid Cahce size:"
+
(
atAdInfoList
!=
null
?
atAdInfoList
.
size
()
:
0
));
if
(
atAdInfoList
!=
null
)
{
for
(
AT
AdInfo
adInfo
:
atAdInfoList
)
{
for
(
TU
AdInfo
adInfo
:
atAdInfoList
)
{
ALog
.
i
(
TAG
,
"Cahce detail:"
+
adInfo
.
toString
());
}
}
...
...
@@ -180,7 +193,7 @@ public class NativeAdManager {
return
isReady
;
}
public
void
showAd
(
AT
NativeView
mATNativeView
,
View
mSelfRenderView
)
{
public
void
showAd
(
TU
NativeView
mATNativeView
,
View
mSelfRenderView
)
{
if
(!
isNativeAdReady
())
{
return
;
}
...
...
@@ -194,58 +207,66 @@ public class NativeAdManager {
}
mNativeAd
=
nativeAd
;
mNativeAd
.
setNativeEventListener
(
new
AT
NativeEventExListener
()
{
mNativeAd
.
setNativeEventListener
(
new
TU
NativeEventExListener
()
{
@Override
public
void
onDeeplinkCallback
(
ATNativeAdView
view
,
AT
AdInfo
adInfo
,
boolean
isSuccess
)
{
public
void
onDeeplinkCallback
(
TUNativeAdView
view
,
TU
AdInfo
adInfo
,
boolean
isSuccess
)
{
ALog
.
i
(
TAG
,
"onDeeplinkCallback:"
+
adInfo
.
toString
()
+
"--status:"
+
isSuccess
);
}
@Override
public
void
onAdImpressed
(
ATNativeAdView
view
,
AT
AdInfo
entity
)
{
public
void
onAdImpressed
(
TUNativeAdView
view
,
TU
AdInfo
entity
)
{
ALog
.
i
(
TAG
,
"native ad onAdImpressed:\n"
+
entity
.
toString
());
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdShow
(
Constants
.
NODE_SHOW
,
AdData
.
AD_TYPE_NATIVE
,
"show"
,
requestTime
);
adStatusCallBack
.
onAdShow
(
Constants
.
NODE_SHOW
,
AdData
.
AD_TYPE_NATIVE
,
"show"
,
requestTime
,
Constants
.
SCENARIO_NATIVE
);
}
if
(
null
!=
adCallback
)
{
adCallback
.
onAdClose
(
Constants
.
NODE_CLOSE_EID
,
AdData
.
AD_TYPE_NATIVE
,
"show"
,
-
1
);
adCallback
=
null
;
}
loadAd
(
2
);
}
@Override
public
void
onAdClicked
(
ATNativeAdView
view
,
AT
AdInfo
entity
)
{
public
void
onAdClicked
(
TUNativeAdView
view
,
TU
AdInfo
entity
)
{
ALog
.
i
(
TAG
,
"native ad onAdClicked:\n"
+
entity
.
toString
());
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdClick
(
Constants
.
NODE_CLICK
,
AdData
.
AD_TYPE_NATIVE
,
"click"
,
-
1
);
adStatusCallBack
.
onAdClick
(
Constants
.
NODE_CLICK
,
AdData
.
AD_TYPE_NATIVE
,
"click"
,
-
1
,
Constants
.
SCENARIO_NATIVE
);
}
if
(
null
!=
adCallback
)
{
adCallback
.
onAdClick
(
Constants
.
NODE_CLICK_EID
,
AdData
.
AD_TYPE_NATIVE
,
"click"
,
-
1
);
}
}
@Override
public
void
onAdVideoStart
(
AT
NativeAdView
view
)
{
public
void
onAdVideoStart
(
TU
NativeAdView
view
)
{
ALog
.
i
(
TAG
,
"native ad onAdVideoStart"
);
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onNativeAdVideoStart
(
Constants
.
NODE_NATIVE_AD_VIDEO_START
,
"native"
,
"start video"
,
-
1
);
adStatusCallBack
.
onNativeAdVideoStart
(
Constants
.
NODE_NATIVE_AD_VIDEO_START
,
"native"
,
"start video"
,
-
1
,
Constants
.
SCENARIO_NATIVE
);
}
}
@Override
public
void
onAdVideoEnd
(
AT
NativeAdView
view
)
{
public
void
onAdVideoEnd
(
TU
NativeAdView
view
)
{
ALog
.
i
(
TAG
,
"native ad onAdVideoEnd"
);
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onNativeAdVideoEnd
(
Constants
.
NODE_NATIVE_AD_VIDEO_END
,
"native"
,
"end video"
,
-
1
);
adStatusCallBack
.
onNativeAdVideoEnd
(
Constants
.
NODE_NATIVE_AD_VIDEO_END
,
"native"
,
"end video"
,
-
1
,
Constants
.
SCENARIO_NATIVE
);
}
}
@Override
public
void
onAdVideoProgress
(
AT
NativeAdView
view
,
int
progress
)
{
public
void
onAdVideoProgress
(
TU
NativeAdView
view
,
int
progress
)
{
ALog
.
i
(
TAG
,
"native ad onAdVideoProgress:"
+
progress
);
}
});
mNativeAd
.
setDislikeCallbackListener
(
new
AT
NativeDislikeListener
()
{
mNativeAd
.
setDislikeCallbackListener
(
new
TU
NativeDislikeListener
()
{
@Override
public
void
onAdCloseButtonClick
(
ATNativeAdView
view
,
AT
AdInfo
entity
)
{
public
void
onAdCloseButtonClick
(
TUNativeAdView
view
,
TU
AdInfo
entity
)
{
ALog
.
i
(
TAG
,
"native ad onAdCloseButtonClick"
);
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdDismiss
(
Constants
.
NODE_CLOSE
,
AdData
.
AD_TYPE_NATIVE
,
"close type: "
+
entity
.
getDismissType
(),
-
1
);
adStatusCallBack
.
onAdDismiss
(
Constants
.
NODE_CLOSE
,
AdData
.
AD_TYPE_NATIVE
,
"close type: "
+
entity
.
getDismissType
(),
-
1
,
Constants
.
SCENARIO_NATIVE
);
}
destroyAd
();
}
...
...
@@ -253,10 +274,10 @@ public class NativeAdManager {
ALog
.
i
(
TAG
,
"showAd start"
);
mATNativeView
.
removeAllViews
();
AT
NativePrepareInfo
mNativePrepareInfo
=
null
;
TU
NativePrepareInfo
mNativePrepareInfo
=
null
;
try
{
mNativePrepareInfo
=
new
AT
NativePrepareExInfo
();
mNativePrepareInfo
=
new
TU
NativePrepareExInfo
();
if
(
mNativeAd
.
isNativeExpress
())
{
mNativeAd
.
renderAdContainer
(
mATNativeView
,
null
);
...
...
media_app/src/main/java/com/gem/media/ad/NativeAdStatusCallBack.java
View file @
bf7ccfd2
...
...
@@ -4,8 +4,8 @@ package com.gem.media.ad;
public
interface
NativeAdStatusCallBack
extends
AdStatusCallBack
{
void
onNativeAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onNativeAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onNativeAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
);
void
onNativeAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onNativeAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onNativeAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
}
media_app/src/main/java/com/gem/media/ad/NativeCleanAdStatusCallBack.java
0 → 100644
View file @
bf7ccfd2
package
com
.
gem
.
media
.
ad
;
public
interface
NativeCleanAdStatusCallBack
{
void
onAdLoad
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
);
void
onAdLoaded
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
,
String
adPosition
);
void
onNoAdError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
);
void
onAdShow
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
);
void
onAdClick
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
);
void
onAdDismiss
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
adId
,
String
scenario
);
void
onNativeAdVideoStart
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onNativeAdVideoEnd
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
void
onNativeAdVideoError
(
String
type
,
String
ad_type
,
String
reason
,
long
time
,
String
scenario
);
}
media_app/src/main/java/com/gem/media/ad/OneH5InterstitialAdapter.java
deleted
100644 → 0
View file @
862e9144
package
com
.
gem
.
media
.
ad
;
import
android.app.Activity
;
import
android.app.Application
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
com.anythink.core.api.ATAdConst
;
import
com.anythink.core.api.ATBiddingListener
;
import
com.anythink.core.api.ATBiddingNotice
;
import
com.anythink.core.api.ATBiddingResult
;
import
com.anythink.interstitial.unitgroup.api.CustomInterstitialAdapter
;
import
org.coolgam.OneH5Sdk
;
import
org.coolgam.om.OmAdError
;
import
org.coolgam.om.OmInterstitialAd
;
import
org.coolgam.om.OmSdk
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.concurrent.atomic.AtomicBoolean
;
public
class
OneH5InterstitialAdapter
extends
CustomInterstitialAdapter
{
private
final
AtomicBoolean
isInit
=
new
AtomicBoolean
(
false
);
private
OmInterstitialAd
omInterstitialAd
;
private
String
unit_id
;
@Override
public
void
show
(
Activity
activity
)
{
postOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
_show
(
activity
);
}
});
}
private
void
_show
(
Activity
activity
)
{
if
(
omInterstitialAd
==
null
||
!
omInterstitialAd
.
isAdReady
())
{
if
(
mImpressListener
!=
null
)
{
mImpressListener
.
onInterstitialAdVideoError
(
"3"
,
"InterstitialAd is not ready"
);
}
return
;
}
omInterstitialAd
.
showAd
(
activity
);
}
@Override
public
void
loadCustomNetworkAd
(
Context
context
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
)
{
loadCustomNetworkAd
(
context
,
map
,
map1
,
false
,
null
);
}
private
void
loadCustomNetworkAd
(
Context
context
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
,
boolean
isBidding
,
ATBiddingListener
biddingListener
)
{
if
(
map
!=
null
&&
map
.
containsKey
(
"unit_id"
))
{
unit_id
=
(
String
)
map
.
get
(
"unit_id"
);
}
if
(
isInit
.
get
()
||
!
TextUtils
.
isEmpty
(
OneH5Sdk
.
getAppId
()))
{
postOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
loadAd
(
context
,
isBidding
,
biddingListener
);
}
});
return
;
}
if
(
map
==
null
||
!
map
.
containsKey
(
"app_id"
))
{
if
(
isBidding
)
{
onBiddingFail
(
biddingListener
,
"topon config app_id is empty"
);
}
else
{
if
(
mLoadListener
!=
null
)
mLoadListener
.
onAdLoadError
(
"400"
,
"topon config app_id is empty"
);
}
return
;
}
isInit
.
set
(
true
);
postOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
initSdk
(
context
,
(
String
)
map
.
get
(
"app_id"
),
isBidding
,
biddingListener
);
}
});
}
private
void
initSdk
(
Context
context
,
String
appId
,
boolean
isBidding
,
ATBiddingListener
biddingListener
)
{
OmSdk
.
initialize
((
Application
)
context
.
getApplicationContext
(),
appId
,
new
OmSdk
.
OnInitListener
()
{
@Override
public
void
onInitComplete
(
boolean
isSuccess
,
String
s
)
{
if
(
isSuccess
)
{
loadAd
(
context
,
isBidding
,
biddingListener
);
}
else
{
Log
.
e
(
"OneH5Sdk>>>"
,
"init fail>>>"
+
s
);
if
(
isBidding
)
{
onBiddingFail
(
biddingListener
,
s
);
}
else
{
if
(
mLoadListener
!=
null
)
{
mLoadListener
.
onAdLoadError
(
"400"
,
s
);
}
}
}
}
});
}
private
void
loadAd
(
Context
context
,
boolean
isBidding
,
ATBiddingListener
biddingListener
)
{
if
(
omInterstitialAd
==
null
)
{
omInterstitialAd
=
new
OmInterstitialAd
();
omInterstitialAd
.
setAdListener
(
new
OmInterstitialAd
.
OnInterstitialAdListener
()
{
@Override
public
void
onAdLoaded
()
{
if
(
isBidding
)
{
onBiddingSuccess
(
biddingListener
);
return
;
}
if
(
mLoadListener
!=
null
)
mLoadListener
.
onAdCacheLoaded
();
}
@Override
public
void
onAdLoadFail
(
OmAdError
omAdError
)
{
if
(
isBidding
)
{
onBiddingFail
(
biddingListener
,
omAdError
.
toString
());
return
;
}
if
(
mLoadListener
!=
null
)
mLoadListener
.
onAdLoadError
(
omAdError
.
code
,
omAdError
.
msg
);
}
@Override
public
void
onAdDismissed
()
{
if
(
mImpressListener
!=
null
)
{
mImpressListener
.
onInterstitialAdClose
();
}
}
@Override
public
void
onAdShowFail
(
OmAdError
omAdError
)
{
if
(
mImpressListener
!=
null
)
{
mImpressListener
.
onInterstitialAdVideoError
(
omAdError
.
code
,
omAdError
.
msg
);
}
}
@Override
public
void
onAdShowed
()
{
if
(
mImpressListener
!=
null
)
{
mImpressListener
.
onInterstitialAdShow
();
}
}
});
}
omInterstitialAd
.
loadAd
(
context
);
}
@Override
public
void
destory
()
{
if
(
omInterstitialAd
!=
null
)
{
omInterstitialAd
.
destory
();
omInterstitialAd
=
null
;
}
}
@Override
public
String
getNetworkPlacementId
()
{
return
unit_id
;
}
@Override
public
String
getNetworkSDKVersion
()
{
return
OneH5Sdk
.
getSdkVersion
();
}
@Override
public
String
getNetworkName
()
{
return
OneH5Sdk
.
getSdkName
();
}
@Override
public
boolean
isAdReady
()
{
return
omInterstitialAd
!=
null
&&
omInterstitialAd
.
isAdReady
();
}
@Override
public
boolean
startBiddingRequest
(
Context
context
,
Map
<
String
,
Object
>
serverExtra
,
Map
<
String
,
Object
>
localExtra
,
ATBiddingListener
biddingListener
)
{
loadCustomNetworkAd
(
context
,
serverExtra
,
localExtra
,
true
,
biddingListener
);
return
true
;
}
private
void
onBiddingFail
(
ATBiddingListener
biddingListener
,
String
msg
)
{
//通过ATBiddingListener,回调竞价失败
if
(
biddingListener
!=
null
)
{
biddingListener
.
onC2SBiddingResultWithCache
(
ATBiddingResult
.
fail
(
msg
),
null
);
}
}
private
void
onBiddingSuccess
(
ATBiddingListener
biddingListener
)
{
if
(
biddingListener
==
null
||
!
isAdReady
())
return
;
//获取价格
double
bidPrice
=
omInterstitialAd
.
getPrice
();
//获取货币单位
ATAdConst
.
CURRENCY
currency
=
ATAdConst
.
CURRENCY
.
USD
;
//用于标识此次竞价的唯一ID,可使用UUID或者时间戳
String
token
=
UUID
.
randomUUID
().
toString
();
//通知TopOn SDK竞价结果
//注意:onC2SBiddingResultWithCache(ATBiddingResult biddingResult, BaseAd baseAd)原生广告需要返回BaseAd,其他广告形式可传null
biddingListener
.
onC2SBiddingResultWithCache
(
ATBiddingResult
.
success
(
bidPrice
,
token
,
new
ATBiddingNotice
()
{
@Override
public
void
notifyBidWin
(
double
costPrice
,
double
secondPrice
,
Map
<
String
,
Object
>
extra
)
{
//costPrice:竞胜方价格
//secondPrice:竞胜方后一位的价格(二价)
if
(
omInterstitialAd
!=
null
)
{
omInterstitialAd
.
notifyBid
(
"TopOn"
,
true
,
bidPrice
,
costPrice
,
secondPrice
,
""
);
}
}
@Override
public
void
notifyBidLoss
(
String
lossCode
,
double
winPrice
,
Map
<
String
,
Object
>
extra
)
{
//判断竞败原因
String
lossReason
=
""
;
switch
(
lossCode
)
{
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_BIDDING_TIMEOUT
:
//竞价超时,如因长时间无竞价结果通知TopOn SDK
lossReason
=
"竞价超时,如因长时间无竞价结果通知TopOn SDK"
;
break
;
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_LOW_PRICE_IN_HB
:
//比竞价广告的价格低
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_LOW_PRICE_IN_NORMAL
:
//比普通常规广告的价格低
lossReason
=
"比竞价广告的价格低"
;
break
;
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_EXPIRE
:
//广告缓存过期
lossReason
=
"广告缓存过期"
;
break
;
}
//判断竞胜方渠道
// int adnId = ATInitMediation.getIntFromMap(extra, ATBiddingNotice.ADN_ID, -1);
// String lossAdn = "";
// switch (adnId) {
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_NORMAL_IN_SAME_ADN://输给了同个广告平台的普通常规广告
// lossAdn = "输给了同个广告平台的普通常规广告";
// break;
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_HB_IN_SAME_ADN://输给了同个广告平台的竞价广告
// lossAdn = "输给了同个广告平台的竞价广告";
// break;
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_OWN_ADN://输给了自有广告(直投广告、交叉推广)
// lossAdn = "输给了自有广告(直投广告、交叉推广)";
// break;
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_OTHER_ADN://输给了其他广告平台
// lossAdn = "输给了其他广告平台";
// break;
// }
if
(
omInterstitialAd
!=
null
)
{
omInterstitialAd
.
notifyBid
(
"TopOn"
,
false
,
bidPrice
,
winPrice
,
0
,
lossReason
);
}
}
@Override
public
void
notifyBidDisplay
(
boolean
isWinner
,
double
displayPrice
)
{
// Log.e("oneh5", ">>notifyBidDisplay>>" + isWinner + ">>" + displayPrice);
}
@Override
public
ATAdConst
.
CURRENCY
getNoticePriceCurrency
()
{
return
ATAdConst
.
CURRENCY
.
USD
;
}
},
currency
),
null
);
}
}
media_app/src/main/java/com/gem/media/ad/OneH5RewardVideoAdapter.java
deleted
100644 → 0
View file @
862e9144
package
com
.
gem
.
media
.
ad
;
import
android.app.Activity
;
import
android.app.Application
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
com.anythink.core.api.ATAdConst
;
import
com.anythink.core.api.ATBiddingListener
;
import
com.anythink.core.api.ATBiddingNotice
;
import
com.anythink.core.api.ATBiddingResult
;
import
com.anythink.rewardvideo.unitgroup.api.CustomRewardVideoAdapter
;
import
org.coolgam.OneH5Sdk
;
import
org.coolgam.om.OmAdError
;
import
org.coolgam.om.OmRewardAd
;
import
org.coolgam.om.OmSdk
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.concurrent.atomic.AtomicBoolean
;
public
class
OneH5RewardVideoAdapter
extends
CustomRewardVideoAdapter
{
private
final
AtomicBoolean
isInit
=
new
AtomicBoolean
(
false
);
private
OmRewardAd
omRewardAd
;
private
String
unit_id
;
@Override
public
void
show
(
Activity
activity
)
{
postOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
_show
(
activity
);
}
});
}
private
void
_show
(
Activity
activity
)
{
if
(
omRewardAd
==
null
||
!
omRewardAd
.
isAdReady
())
{
if
(
mImpressionListener
!=
null
)
{
mImpressionListener
.
onRewardedVideoAdPlayFailed
(
"3"
,
"RewardAd is not ready"
);
}
return
;
}
omRewardAd
.
showAd
(
activity
);
}
@Override
public
void
loadCustomNetworkAd
(
Context
context
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
)
{
loadCustomNetworkAd
(
context
,
map
,
map1
,
false
,
null
);
}
public
void
loadCustomNetworkAd
(
Context
context
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
,
boolean
isBidding
,
ATBiddingListener
biddingListener
)
{
if
(
map
!=
null
&&
map
.
containsKey
(
"unit_id"
))
{
unit_id
=
(
String
)
map
.
get
(
"unit_id"
);
}
if
(
isInit
.
get
()
||
!
TextUtils
.
isEmpty
(
OneH5Sdk
.
getAppId
()))
{
postOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
loadAd
(
context
,
isBidding
,
biddingListener
);
}
});
return
;
}
if
(
map
==
null
||
!
map
.
containsKey
(
"app_id"
))
{
if
(
isBidding
)
{
onBiddingFail
(
biddingListener
,
"topon config app_id is empty"
);
}
else
{
if
(
mLoadListener
!=
null
)
mLoadListener
.
onAdLoadError
(
"400"
,
"topon config app_id is empty"
);
}
return
;
}
isInit
.
set
(
true
);
postOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
initSdk
(
context
,
(
String
)
map
.
get
(
"app_id"
),
isBidding
,
biddingListener
);
}
});
}
private
void
initSdk
(
Context
context
,
String
appId
,
boolean
isBidding
,
ATBiddingListener
biddingListener
)
{
OmSdk
.
initialize
((
Application
)
context
.
getApplicationContext
(),
appId
,
new
OmSdk
.
OnInitListener
()
{
@Override
public
void
onInitComplete
(
boolean
isSuccess
,
String
s
)
{
if
(
isSuccess
)
{
loadAd
(
context
,
isBidding
,
biddingListener
);
}
else
{
Log
.
e
(
"OneH5Sdk>>>"
,
"init fail>>>"
+
s
);
if
(
isBidding
)
{
onBiddingFail
(
biddingListener
,
s
);
}
else
{
if
(
mLoadListener
!=
null
)
{
mLoadListener
.
onAdLoadError
(
"400"
,
s
);
}
}
}
}
});
}
private
void
loadAd
(
Context
context
,
boolean
isBidding
,
ATBiddingListener
biddingListener
)
{
if
(
omRewardAd
==
null
)
{
omRewardAd
=
new
OmRewardAd
();
omRewardAd
.
setAdListener
(
new
OmRewardAd
.
OnRewardAdListener
()
{
@Override
public
void
onAdLoaded
()
{
if
(
isBidding
)
{
onBiddingSuccess
(
biddingListener
);
return
;
}
if
(
mLoadListener
!=
null
)
mLoadListener
.
onAdCacheLoaded
();
}
@Override
public
void
onAdLoadFail
(
OmAdError
omAdError
)
{
if
(
isBidding
)
{
onBiddingFail
(
biddingListener
,
omAdError
.
toString
());
return
;
}
if
(
mLoadListener
!=
null
)
mLoadListener
.
onAdLoadError
(
omAdError
.
code
,
omAdError
.
msg
);
}
@Override
public
void
onAdDismissed
()
{
if
(
mImpressionListener
!=
null
)
{
mImpressionListener
.
onRewardedVideoAdClosed
();
}
}
@Override
public
void
onAdShowFail
(
OmAdError
omAdError
)
{
if
(
mImpressionListener
!=
null
)
{
mImpressionListener
.
onRewardedVideoAdPlayFailed
(
omAdError
.
code
,
omAdError
.
msg
);
}
}
@Override
public
void
onAdShowed
()
{
if
(
mImpressionListener
!=
null
)
{
mImpressionListener
.
onRewardedVideoAdPlayStart
();
}
}
@Override
public
void
onAdReward
()
{
if
(
mImpressionListener
!=
null
)
{
mImpressionListener
.
onReward
();
}
}
});
}
omRewardAd
.
loadAd
(
context
);
}
@Override
public
void
destory
()
{
if
(
omRewardAd
!=
null
)
{
omRewardAd
.
destory
();
omRewardAd
=
null
;
}
}
@Override
public
String
getNetworkPlacementId
()
{
return
unit_id
;
}
@Override
public
String
getNetworkSDKVersion
()
{
return
OneH5Sdk
.
getSdkVersion
();
}
@Override
public
String
getNetworkName
()
{
return
OneH5Sdk
.
getSdkName
();
}
@Override
public
boolean
isAdReady
()
{
return
omRewardAd
!=
null
&&
omRewardAd
.
isAdReady
();
}
@Override
public
boolean
startBiddingRequest
(
Context
context
,
Map
<
String
,
Object
>
serverExtra
,
Map
<
String
,
Object
>
localExtra
,
ATBiddingListener
biddingListener
)
{
loadCustomNetworkAd
(
context
,
serverExtra
,
localExtra
,
true
,
biddingListener
);
return
true
;
}
private
void
onBiddingFail
(
ATBiddingListener
biddingListener
,
String
msg
)
{
//通过ATBiddingListener,回调竞价失败
if
(
biddingListener
!=
null
)
{
biddingListener
.
onC2SBiddingResultWithCache
(
ATBiddingResult
.
fail
(
msg
),
null
);
}
}
private
void
onBiddingSuccess
(
ATBiddingListener
biddingListener
)
{
if
(
biddingListener
==
null
||
!
isAdReady
())
return
;
//获取价格
double
bidPrice
=
omRewardAd
.
getPrice
();
//获取货币单位
ATAdConst
.
CURRENCY
currency
=
ATAdConst
.
CURRENCY
.
USD
;
//用于标识此次竞价的唯一ID,可使用UUID或者时间戳
String
token
=
UUID
.
randomUUID
().
toString
();
//通知TopOn SDK竞价结果
//注意:onC2SBiddingResultWithCache(ATBiddingResult biddingResult, BaseAd baseAd)原生广告需要返回BaseAd,其他广告形式可传null
biddingListener
.
onC2SBiddingResultWithCache
(
ATBiddingResult
.
success
(
bidPrice
,
token
,
new
ATBiddingNotice
()
{
@Override
public
void
notifyBidWin
(
double
costPrice
,
double
secondPrice
,
Map
<
String
,
Object
>
extra
)
{
//costPrice:竞胜方价格
//secondPrice:竞胜方后一位的价格(二价)
if
(
omRewardAd
!=
null
)
{
omRewardAd
.
notifyBid
(
"TopOn"
,
true
,
bidPrice
,
costPrice
,
secondPrice
,
""
);
}
}
@Override
public
void
notifyBidLoss
(
String
lossCode
,
double
winPrice
,
Map
<
String
,
Object
>
extra
)
{
//判断竞败原因
String
lossReason
=
""
;
switch
(
lossCode
)
{
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_BIDDING_TIMEOUT
:
//竞价超时,如因长时间无竞价结果通知TopOn SDK
lossReason
=
"竞价超时,如因长时间无竞价结果通知TopOn SDK"
;
break
;
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_LOW_PRICE_IN_HB
:
//比竞价广告的价格低
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_LOW_PRICE_IN_NORMAL
:
//比普通常规广告的价格低
lossReason
=
"比竞价广告的价格低"
;
break
;
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_EXPIRE
:
//广告缓存过期
lossReason
=
"广告缓存过期"
;
break
;
}
//判断竞胜方渠道
// int adnId = ATInitMediation.getIntFromMap(extra, ATBiddingNotice.ADN_ID, -1);
// String lossAdn = "";
// switch (adnId) {
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_NORMAL_IN_SAME_ADN://输给了同个广告平台的普通常规广告
// lossAdn = "输给了同个广告平台的普通常规广告";
// break;
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_HB_IN_SAME_ADN://输给了同个广告平台的竞价广告
// lossAdn = "输给了同个广告平台的竞价广告";
// break;
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_OWN_ADN://输给了自有广告(直投广告、交叉推广)
// lossAdn = "输给了自有广告(直投广告、交叉推广)";
// break;
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_OTHER_ADN://输给了其他广告平台
// lossAdn = "输给了其他广告平台";
// break;
// }
if
(
omRewardAd
!=
null
)
{
omRewardAd
.
notifyBid
(
"TopOn"
,
false
,
bidPrice
,
winPrice
,
0
,
lossReason
);
}
}
@Override
public
void
notifyBidDisplay
(
boolean
isWinner
,
double
displayPrice
)
{
// Log.e("oneh5", ">>notifyBidDisplay>>" + isWinner + ">>" + displayPrice);
}
@Override
public
ATAdConst
.
CURRENCY
getNoticePriceCurrency
()
{
return
ATAdConst
.
CURRENCY
.
USD
;
}
},
currency
),
null
);
}
}
media_app/src/main/java/com/gem/media/ad/OneH5SplashAdapter.java
deleted
100644 → 0
View file @
862e9144
package
com
.
gem
.
media
.
ad
;
import
android.app.Activity
;
import
android.app.Application
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.ViewGroup
;
import
com.anythink.core.api.ATAdConst
;
import
com.anythink.core.api.ATBiddingListener
;
import
com.anythink.core.api.ATBiddingNotice
;
import
com.anythink.core.api.ATBiddingResult
;
import
com.anythink.splashad.unitgroup.api.CustomSplashAdapter
;
import
org.coolgam.OneH5Sdk
;
import
org.coolgam.om.OmAdError
;
import
org.coolgam.om.OmOpenAd
;
import
org.coolgam.om.OmSdk
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.concurrent.atomic.AtomicBoolean
;
public
class
OneH5SplashAdapter
extends
CustomSplashAdapter
{
private
final
AtomicBoolean
isInit
=
new
AtomicBoolean
(
false
);
private
OmOpenAd
splashAd
;
private
String
unit_id
;
@Override
public
void
show
(
Activity
activity
,
ViewGroup
viewGroup
)
{
postOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
showAd
(
activity
);
}
});
}
@Override
public
void
loadCustomNetworkAd
(
Context
context
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
)
{
loadCustomNetworkAd
(
context
,
map
,
map1
,
false
,
null
);
}
public
void
loadCustomNetworkAd
(
Context
context
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
,
boolean
isBidding
,
ATBiddingListener
biddingListener
)
{
if
(
map
!=
null
&&
map
.
containsKey
(
"unit_id"
))
{
unit_id
=
(
String
)
map
.
get
(
"unit_id"
);
}
if
(
isInit
.
get
()
||
!
TextUtils
.
isEmpty
(
OneH5Sdk
.
getAppId
()))
{
postOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
loadAd
(
context
,
isBidding
,
biddingListener
);
}
});
return
;
}
if
(
map
==
null
||
!
map
.
containsKey
(
"app_id"
))
{
if
(
isBidding
)
{
onBiddingFail
(
biddingListener
,
"topon config app_id is empty"
);
}
else
{
if
(
mLoadListener
!=
null
)
mLoadListener
.
onAdLoadError
(
"400"
,
"topon config app_id is empty"
);
}
return
;
}
isInit
.
set
(
true
);
postOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
initSdk
(
context
,
(
String
)
map
.
get
(
"app_id"
),
isBidding
,
biddingListener
);
}
});
}
private
void
initSdk
(
Context
context
,
String
appId
,
boolean
isBidding
,
ATBiddingListener
biddingListener
)
{
OmSdk
.
initialize
((
Application
)
context
.
getApplicationContext
(),
appId
,
new
OmSdk
.
OnInitListener
()
{
@Override
public
void
onInitComplete
(
boolean
isSuccess
,
String
s
)
{
if
(
isSuccess
)
{
loadAd
(
context
,
isBidding
,
biddingListener
);
}
else
{
Log
.
e
(
"OneH5Sdk>>>"
,
"init fail>>>"
+
s
);
if
(
isBidding
)
{
onBiddingFail
(
biddingListener
,
s
);
}
else
{
if
(
mLoadListener
!=
null
)
{
mLoadListener
.
onAdLoadError
(
"400"
,
s
);
}
}
}
}
});
}
@Override
public
void
destory
()
{
postOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
destoryAd
();
}
});
}
private
void
destoryAd
()
{
if
(
splashAd
!=
null
)
{
splashAd
.
destory
();
}
splashAd
=
null
;
}
private
void
loadAd
(
Context
context
,
boolean
isBidding
,
ATBiddingListener
biddingListener
)
{
if
(
splashAd
==
null
)
{
splashAd
=
new
OmOpenAd
();
splashAd
.
setAdListener
(
new
OmOpenAd
.
OnOpenAdListener
()
{
@Override
public
void
onAdLoaded
()
{
if
(
isBidding
)
{
onBiddingSuccess
(
biddingListener
);
return
;
}
if
(
mLoadListener
!=
null
)
{
mLoadListener
.
onAdCacheLoaded
();
}
}
@Override
public
void
onAdLoadFail
(
OmAdError
omAdError
)
{
if
(
isBidding
)
{
onBiddingFail
(
biddingListener
,
omAdError
.
toString
());
return
;
}
if
(
mLoadListener
!=
null
)
{
mLoadListener
.
onAdLoadError
(
omAdError
.
code
,
omAdError
.
msg
);
}
}
@Override
public
void
onAdDismissed
()
{
if
(
mImpressionListener
!=
null
)
{
mImpressionListener
.
onSplashAdDismiss
();
}
}
@Override
public
void
onAdClicked
()
{
if
(
mImpressionListener
!=
null
)
{
mImpressionListener
.
onSplashAdClicked
();
}
}
@Override
public
void
onAdShowFail
(
OmAdError
omAdError
)
{
if
(
mImpressionListener
!=
null
)
{
mImpressionListener
.
onSplashAdDismiss
();
}
}
@Override
public
void
onAdShowed
()
{
if
(
mImpressionListener
!=
null
)
{
mImpressionListener
.
onSplashAdShow
();
}
}
@Override
public
void
onAdComplete
(
boolean
b
)
{
}
});
}
splashAd
.
loadAd
(
context
);
}
private
void
showAd
(
Activity
activity
)
{
if
(
splashAd
==
null
||
!
splashAd
.
isAdReady
())
{
return
;
}
splashAd
.
showAd
(
activity
);
}
@Override
public
boolean
isAdReady
()
{
return
splashAd
!=
null
&&
splashAd
.
isAdReady
();
}
@Override
public
String
getNetworkPlacementId
()
{
return
unit_id
;
}
@Override
public
String
getNetworkSDKVersion
()
{
return
OneH5Sdk
.
getSdkVersion
();
}
@Override
public
String
getNetworkName
()
{
return
OneH5Sdk
.
getSdkName
();
}
@Override
public
boolean
startBiddingRequest
(
Context
context
,
Map
<
String
,
Object
>
serverExtra
,
Map
<
String
,
Object
>
localExtra
,
ATBiddingListener
biddingListener
)
{
loadCustomNetworkAd
(
context
,
serverExtra
,
localExtra
,
true
,
biddingListener
);
return
true
;
}
private
void
onBiddingFail
(
ATBiddingListener
biddingListener
,
String
msg
)
{
//通过ATBiddingListener,回调竞价失败
if
(
biddingListener
!=
null
)
{
biddingListener
.
onC2SBiddingResultWithCache
(
ATBiddingResult
.
fail
(
msg
),
null
);
}
}
private
void
onBiddingSuccess
(
ATBiddingListener
biddingListener
)
{
if
(
biddingListener
==
null
||
!
isAdReady
())
return
;
//获取价格
double
bidPrice
=
splashAd
.
getPrice
();
//获取货币单位
ATAdConst
.
CURRENCY
currency
=
ATAdConst
.
CURRENCY
.
USD
;
//用于标识此次竞价的唯一ID,可使用UUID或者时间戳
String
token
=
UUID
.
randomUUID
().
toString
();
//通知TopOn SDK竞价结果
//注意:onC2SBiddingResultWithCache(ATBiddingResult biddingResult, BaseAd baseAd)原生广告需要返回BaseAd,其他广告形式可传null
biddingListener
.
onC2SBiddingResultWithCache
(
ATBiddingResult
.
success
(
bidPrice
,
token
,
new
ATBiddingNotice
()
{
@Override
public
void
notifyBidWin
(
double
costPrice
,
double
secondPrice
,
Map
<
String
,
Object
>
extra
)
{
//costPrice:竞胜方价格
//secondPrice:竞胜方后一位的价格(二价)
if
(
splashAd
!=
null
)
{
splashAd
.
notifyBid
(
"TopOn"
,
true
,
bidPrice
,
costPrice
,
secondPrice
,
""
);
}
}
@Override
public
void
notifyBidLoss
(
String
lossCode
,
double
winPrice
,
Map
<
String
,
Object
>
extra
)
{
//判断竞败原因
String
lossReason
=
""
;
switch
(
lossCode
)
{
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_BIDDING_TIMEOUT
:
//竞价超时,如因长时间无竞价结果通知TopOn SDK
lossReason
=
"竞价超时,如因长时间无竞价结果通知TopOn SDK"
;
break
;
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_LOW_PRICE_IN_HB
:
//比竞价广告的价格低
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_LOW_PRICE_IN_NORMAL
:
//比普通常规广告的价格低
lossReason
=
"比竞价广告的价格低"
;
break
;
case
ATAdConst
.
BIDDING_TYPE
.
BIDDING_LOSS_WITH_EXPIRE
:
//广告缓存过期
lossReason
=
"广告缓存过期"
;
break
;
}
//判断竞胜方渠道
// int adnId = ATInitMediation.getIntFromMap(extra, ATBiddingNotice.ADN_ID, -1);
// String lossAdn = "";
// switch (adnId) {
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_NORMAL_IN_SAME_ADN://输给了同个广告平台的普通常规广告
// lossAdn = "输给了同个广告平台的普通常规广告";
// break;
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_HB_IN_SAME_ADN://输给了同个广告平台的竞价广告
// lossAdn = "输给了同个广告平台的竞价广告";
// break;
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_OWN_ADN://输给了自有广告(直投广告、交叉推广)
// lossAdn = "输给了自有广告(直投广告、交叉推广)";
// break;
// case ATAdConst.BIDDING_ADN_ID.LOSE_TO_OTHER_ADN://输给了其他广告平台
// lossAdn = "输给了其他广告平台";
// break;
// }
if
(
splashAd
!=
null
)
{
splashAd
.
notifyBid
(
"TopOn"
,
false
,
bidPrice
,
winPrice
,
0
,
lossReason
);
}
}
@Override
public
void
notifyBidDisplay
(
boolean
isWinner
,
double
displayPrice
)
{
// Log.e("oneh5", ">>notifyBidDisplay>>" + isWinner + ">>" + displayPrice);
}
@Override
public
ATAdConst
.
CURRENCY
getNoticePriceCurrency
()
{
return
ATAdConst
.
CURRENCY
.
USD
;
}
},
currency
),
null
);
}
}
media_app/src/main/java/com/gem/media/ad/OpenAdManager.java
View file @
bf7ccfd2
...
...
@@ -8,28 +8,27 @@ import android.text.TextUtils;
import
android.view.ViewGroup
;
import
com.ads.cal.picturetranslate.PictureApplication
;
import
com.anythink.core.api.ATAdStatusInfo
;
import
com.anythink.core.api.ATAdConst
;
import
com.anythink.core.api.ATAdInfo
;
import
com.anythink.core.api.ATNetworkConfirmInfo
;
import
com.anythink.core.api.AdError
;
import
com.anythink.splashad.api.ATSplashAd
;
import
com.anythink.splashad.api.ATSplashAdExtraInfo
;
import
com.anythink.splashad.api.ATSplashExListener
;
import
com.gem.media.NetworkUtils
;
import
com.gem.media.StatsStaticHelper
;
import
com.gem.media.splash.base.AdUtils
;
import
com.gem.media.splash.base.protocol.AdLoadedCallback
;
import
com.gem.media.splash.base.protocol.AdCallback
;
import
com.gem.media.splash.base.protocol.Constants
;
import
com.gem.media.splash.base.utils.ALog
;
import
com.thinkup.core.api.AdError
;
import
com.thinkup.core.api.TUAdConst
;
import
com.thinkup.core.api.TUAdInfo
;
import
com.thinkup.core.api.TUAdStatusInfo
;
import
com.thinkup.core.api.TUNetworkConfirmInfo
;
import
com.thinkup.splashad.api.TUSplashAd
;
import
com.thinkup.splashad.api.TUSplashAdExtraInfo
;
import
com.thinkup.splashad.api.TUSplashExListener
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
OpenAdManager
{
private
AT
SplashAd
splashAd
;
private
TU
SplashAd
splashAd
;
private
AdLoadedCallback
adLoadedCallback
;
private
AdCallback
adCallback
;
private
long
requestTime
;
...
...
@@ -62,21 +61,21 @@ public class OpenAdManager {
return
;
}
if
(
splashAd
==
null
)
{
ATSplashExListener
listener
=
new
AT
SplashExListener
()
{
TUSplashExListener
listener
=
new
TU
SplashExListener
()
{
@Override
public
void
onDeeplinkCallback
(
AT
AdInfo
atAdInfo
,
boolean
b
)
{
public
void
onDeeplinkCallback
(
TU
AdInfo
atAdInfo
,
boolean
b
)
{
}
@Override
public
void
onDownloadConfirm
(
Context
context
,
ATAdInfo
atAdInfo
,
AT
NetworkConfirmInfo
atNetworkConfirmInfo
)
{
public
void
onDownloadConfirm
(
Context
context
,
TUAdInfo
atAdInfo
,
TU
NetworkConfirmInfo
atNetworkConfirmInfo
)
{
}
@Override
public
void
onAdLoaded
(
boolean
isTimeout
)
{
ALog
.
w
(
"GEM_WZ"
,
"open onAdLoaded "
+
isTimeout
+
" "
);
ALog
.
w
(
"GEM_WZ"
,
"open onAdLoaded "
+
isTimeout
+
" "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
//加载未超时时
if
(!
isTimeout
)
{
...
...
@@ -91,7 +90,7 @@ public class OpenAdManager {
adCallback
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS_EID
,
"open"
,
"loaded"
,
requestTime
);
}
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS
,
"open"
,
"loaded"
,
requestTime
);
adStatusCallBack
.
onAdLoaded
(
Constants
.
NODE_REQUEST_SUCCESS
,
"open"
,
"loaded"
,
requestTime
,
Constants
.
SCENARIO_3
);
}
}
...
...
@@ -99,13 +98,13 @@ public class OpenAdManager {
@Override
public
void
onAdLoadTimeout
()
{
//加载超时后,直接进入主界面
ALog
.
w
(
"GEM_WZ"
,
"open onAdLoadTimeout "
);
ALog
.
w
(
"GEM_WZ"
,
"open onAdLoadTimeout "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
if
(
null
!=
adCallback
)
{
adCallback
.
onAdTimeOut
(
Constants
.
NODE_ERROR_EID
,
"open"
,
"timeout"
,
requestTime
);
}
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdLoadTimeout
(
Constants
.
NODE_ERROR
,
"open"
,
"timeout"
,
requestTime
);
adStatusCallBack
.
onAdLoadTimeout
(
Constants
.
NODE_ERROR
,
"open"
,
"timeout"
,
requestTime
,
Constants
.
SCENARIO_3
);
}
}
...
...
@@ -113,7 +112,7 @@ public class OpenAdManager {
@Override
public
void
onNoAdError
(
AdError
adError
)
{
//加载失败直接进入主界面
ALog
.
w
(
"GEM_WZ"
,
"open onNoAdError "
+
adError
.
getFullErrorInfo
()
+
" "
);
ALog
.
w
(
"GEM_WZ"
,
"open onNoAdError "
+
adError
.
getFullErrorInfo
()
+
" "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
String
reason
=
"open "
+
"code: "
+
adError
.
getCode
()
+
" msg: "
+
adError
.
getFullErrorInfo
();
...
...
@@ -121,13 +120,13 @@ public class OpenAdManager {
adCallback
.
onAdError
(
Constants
.
NODE_ERROR_EID
,
"open"
,
reason
,
requestTime
);
}
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onNoAdError
(
Constants
.
NODE_ERROR
,
"open"
,
reason
,
requestTime
);
adStatusCallBack
.
onNoAdError
(
Constants
.
NODE_ERROR
,
"open"
,
reason
,
requestTime
,
Constants
.
SCENARIO_3
);
}
}
@Override
public
void
onAdShow
(
AT
AdInfo
entity
)
{
ALog
.
w
(
"GEM_WZ"
,
"open OpenonAdShow "
);
public
void
onAdShow
(
TU
AdInfo
entity
)
{
ALog
.
w
(
"GEM_WZ"
,
"open OpenonAdShow "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
requestTime
=
System
.
currentTimeMillis
()
-
requestTime
;
...
...
@@ -135,36 +134,36 @@ public class OpenAdManager {
adCallback
.
onAdShow
(
Constants
.
NODE_SHOW_EID
,
"open"
,
"show"
,
requestTime
);
}
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdShow
(
Constants
.
NODE_SHOW
,
"open"
,
"show"
,
requestTime
);
adStatusCallBack
.
onAdShow
(
Constants
.
NODE_SHOW
,
"open"
,
"show"
,
requestTime
,
Constants
.
SCENARIO_3
);
}
clearAdLoadedCallback
();
AdManager
.
getInstance
().
saveAdExpCount
();
}
@Override
public
void
onAdClick
(
AT
AdInfo
atAdInfo
)
{
ALog
.
w
(
"GEM_WZ"
,
"open onAdClick "
);
public
void
onAdClick
(
TU
AdInfo
atAdInfo
)
{
ALog
.
w
(
"GEM_WZ"
,
"open onAdClick "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
if
(
null
!=
adCallback
)
{
adCallback
.
onAdClick
(
Constants
.
NODE_CLICK_EID
,
"open"
,
"click"
,
-
1
);
}
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdClick
(
Constants
.
NODE_CLICK
,
"open"
,
"click"
,
-
1
);
adStatusCallBack
.
onAdClick
(
Constants
.
NODE_CLICK
,
"open"
,
"click"
,
-
1
,
Constants
.
SCENARIO_3
);
}
}
@Override
public
void
onAdDismiss
(
ATAdInfo
entity
,
AT
SplashAdExtraInfo
splashAdExtraInfo
)
{
ALog
.
w
(
"GEM_WZ"
,
"open onAdDismiss "
);
public
void
onAdDismiss
(
TUAdInfo
entity
,
TU
SplashAdExtraInfo
splashAdExtraInfo
)
{
ALog
.
w
(
"GEM_WZ"
,
"open onAdDismiss "
+
PictureApplication
.
getApplication
().
getPackageName
()
);
if
(
null
!=
adCallback
)
{
adCallback
.
onAdClose
(
Constants
.
NODE_CLOSE_EID
,
"open"
,
"close type: "
+
splashAdExtraInfo
.
getDismissType
(),
-
1
);
adCallback
=
null
;
}
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdDismiss
(
Constants
.
NODE_CLOSE
,
"open"
,
"close type: "
+
splashAdExtraInfo
.
getDismissType
(),
-
1
);
adStatusCallBack
.
onAdDismiss
(
Constants
.
NODE_CLOSE
,
"open"
,
"close type: "
+
splashAdExtraInfo
.
getDismissType
(),
-
1
,
Constants
.
SCENARIO_3
);
}
//=1无区分 =2跳过结束 =3倒计时结束 =4点击广告结束 =99开屏展示失败
if
(
splashAdExtraInfo
.
getDismissType
()
==
AT
AdConst
.
DISMISS_TYPE
.
SHOWFAILED
)
{
if
(
splashAdExtraInfo
.
getDismissType
()
==
TU
AdConst
.
DISMISS_TYPE
.
SHOWFAILED
)
{
}
//开屏广告展示关闭后进入主界面
//注意:部分平台跳转落地页后倒计时不暂停,即使在看落地页,倒计时结束后仍然会回调onAdDismiss
...
...
@@ -177,7 +176,7 @@ public class OpenAdManager {
//设置首次开屏广告广告源,请从TopOn后台兜底开屏广告源导出配置
//b1f138leh1o4gp
splashAd
=
new
AT
SplashAd
(
PictureApplication
.
getApplication
(),
sAdId
,
listener
,
5000
,
null
);
splashAd
=
new
TU
SplashAd
(
PictureApplication
.
getApplication
(),
sAdId
,
listener
,
5000
,
null
);
}
}
...
...
@@ -210,7 +209,7 @@ public class OpenAdManager {
return
-
1
;
}
if
(
null
!=
adData
&&
!
adData
.
canLoadAdData
(
AdData
.
AD_TYPE_OPEN
)
)
{
if
(
null
!=
adData
)
{
ALog
.
w
(
"GEM_WZ"
,
" canLoadAdData open == false"
);
return
-
2
;
}
...
...
@@ -223,7 +222,7 @@ public class OpenAdManager {
return
-
3
;
}
AT
AdStatusInfo
atAdStatusInfo
=
splashAd
.
checkAdStatus
();
TU
AdStatusInfo
atAdStatusInfo
=
splashAd
.
checkAdStatus
();
ALog
.
w
(
"GEM_WZ"
,
"open atAdStatusInfo: "
+
atAdStatusInfo
);
if
(
atAdStatusInfo
.
isReady
())
{
ALog
.
w
(
"GEM_WZ"
,
"open is Ready"
);
...
...
@@ -236,7 +235,7 @@ public class OpenAdManager {
if
(!
AdManager
.
getInstance
().
isCanNextAdRequest
())
{
return
-
4
;
}
// if (!NetworkUtils.isConnected(
A.getContext
())) {
// if (!NetworkUtils.isConnected(
PictureApplication.getApplication
())) {
// StatsStaticHelper.onEvent(Constants.NODE_AD_REQ_NOT_NET, "open");
// return -5;
// }
...
...
@@ -248,7 +247,7 @@ public class OpenAdManager {
splashAd
.
loadAd
();
requestTime
=
System
.
currentTimeMillis
();
if
(
null
!=
adStatusCallBack
)
{
adStatusCallBack
.
onAdLoad
(
Constants
.
NODE_REQUEST
,
"open"
,
"load"
,
-
1
);
adStatusCallBack
.
onAdLoad
(
Constants
.
NODE_REQUEST
,
"open"
,
"load"
,
-
1
,
Constants
.
SCENARIO_3
);
}
ALog
.
w
(
"GEM_WZ"
,
"open end load"
);
return
1
;
...
...
@@ -265,8 +264,15 @@ public class OpenAdManager {
return
;
}
}
// Context context = PictureApplication.getApplication();
// if (context instanceof A) {
// if (((A) context).isAppBackground()) {
// ((A)context).cleanTask();
// return;
// }
// }
if
(!
TextUtils
.
isEmpty
(
sAdId
))
{
AT
SplashAd
.
entryAdScenario
(
sAdId
,
"f65bf35e68ddf9"
);
TU
SplashAd
.
entryAdScenario
(
sAdId
,
"f65bf35e68ddf9"
);
}
if
(
null
!=
splashAd
&&
splashAd
.
isAdReady
())
{
splashAd
.
show
(
activity
,
viewGroup
,
"f65bf35e68ddf9"
);
...
...
@@ -281,7 +287,7 @@ public class OpenAdManager {
if
(
null
==
splashAd
)
{
return
false
;
}
AT
AdStatusInfo
atAdStatusInfo
=
splashAd
.
checkAdStatus
();
TU
AdStatusInfo
atAdStatusInfo
=
splashAd
.
checkAdStatus
();
if
(
atAdStatusInfo
==
null
)
{
return
false
;
}
...
...
media_app/src/main/java/com/gem/media/ad/SelfRenderViewUtil.java
View file @
bf7ccfd2
...
...
@@ -11,14 +11,14 @@ import android.widget.FrameLayout;
import
android.widget.TextView
;
import
com.ads.cal.picturetranslate.R
;
import
com.anythink.core.api.IATAdvertiserInfoOperate
;
import
com.anythink.nativead.api.ATNativeImageView
;
import
com.anythink.nativead.api.ATNativeMaterial
;
import
com.anythink.nativead.api.ATNativePrepareExInfo
;
import
com.anythink.nativead.api.ATNativePrepareInfo
;
import
com.anythink.nativead.unitgroup.api.CustomNativeAd
;
import
com.gem.media.ad.view.MutiImageView
;
import
com.gem.media.splash.base.utils.ALog
;
import
com.thinkup.core.api.ITUAdvertiserInfoOperate
;
import
com.thinkup.nativead.api.TUNativeImageView
;
import
com.thinkup.nativead.api.TUNativeMaterial
;
import
com.thinkup.nativead.api.TUNativePrepareExInfo
;
import
com.thinkup.nativead.api.TUNativePrepareInfo
;
import
com.thinkup.nativead.unitgroup.api.CustomNativeAd
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -27,7 +27,7 @@ public class SelfRenderViewUtil {
private
static
final
String
TAG
=
SelfRenderViewUtil
.
class
.
getSimpleName
();
public
static
void
bindSelfRenderView
(
Context
context
,
ATNativeMaterial
adMaterial
,
View
selfRenderView
,
AT
NativePrepareInfo
nativePrepareInfo
)
{
public
static
void
bindSelfRenderView
(
Context
context
,
TUNativeMaterial
adMaterial
,
View
selfRenderView
,
TU
NativePrepareInfo
nativePrepareInfo
)
{
printNativeAdMaterial
(
adMaterial
);
int
padding
=
dip2px
(
context
,
5
);
selfRenderView
.
setPadding
(
padding
,
padding
,
padding
,
padding
);
...
...
@@ -37,7 +37,7 @@ public class SelfRenderViewUtil {
TextView
adFromView
=
selfRenderView
.
findViewById
(
R
.
id
.
native_ad_from
);
FrameLayout
iconArea
=
selfRenderView
.
findViewById
(
R
.
id
.
native_ad_image
);
FrameLayout
contentArea
=
selfRenderView
.
findViewById
(
R
.
id
.
native_ad_content_image_area
);
final
AT
NativeImageView
logoView
=
selfRenderView
.
findViewById
(
R
.
id
.
native_ad_logo
);
final
TU
NativeImageView
logoView
=
selfRenderView
.
findViewById
(
R
.
id
.
native_ad_logo
);
View
closeView
=
selfRenderView
.
findViewById
(
R
.
id
.
native_ad_close
);
TextView
domainView
=
selfRenderView
.
findViewById
(
R
.
id
.
native_ad_domain
);
//(v6.1.20+) Yandex domain
TextView
warningView
=
selfRenderView
.
findViewById
(
R
.
id
.
native_ad_warning
);
//(v6.1.20+) Yandex warning
...
...
@@ -46,7 +46,7 @@ public class SelfRenderViewUtil {
// bind view
if
(
nativePrepareInfo
==
null
)
{
nativePrepareInfo
=
new
AT
NativePrepareInfo
();
nativePrepareInfo
=
new
TU
NativePrepareInfo
();
}
List
<
View
>
clickViewList
=
new
ArrayList
<>();
//click views
...
...
@@ -76,7 +76,7 @@ public class SelfRenderViewUtil {
View
adIconView
=
adMaterial
.
getAdIconView
();
String
iconImageUrl
=
adMaterial
.
getIconImageUrl
();
iconArea
.
removeAllViews
();
final
ATNativeImageView
iconView
=
new
AT
NativeImageView
(
context
);
final
TUNativeImageView
iconView
=
new
TU
NativeImageView
(
context
);
if
(
adIconView
!=
null
)
{
iconArea
.
addView
(
adIconView
);
nativePrepareInfo
.
setIconView
(
adIconView
);
//bind icon
...
...
@@ -188,7 +188,7 @@ public class SelfRenderViewUtil {
contentArea
.
addView
(
mutiImageView
,
new
FrameLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
));
clickViewList
.
add
(
mutiImageView
);
}
else
if
(!
TextUtils
.
isEmpty
(
adMaterial
.
getMainImageUrl
()))
{
ATNativeImageView
imageView
=
new
AT
NativeImageView
(
context
);
TUNativeImageView
imageView
=
new
TU
NativeImageView
(
context
);
imageView
.
setImage
(
adMaterial
.
getMainImageUrl
());
imageView
.
setLayoutParams
(
mainImageParam
);
contentArea
.
addView
(
imageView
,
mainImageParam
);
...
...
@@ -237,7 +237,7 @@ public class SelfRenderViewUtil {
nativePrepareInfo
.
setAdFromView
(
adFromView
);
//bind ad from
//advertiser info (v6.1.70+)
final
I
AT
AdvertiserInfoOperate
advertiserInfoOperate
=
adMaterial
.
getAdvertiserInfoOperate
();
final
I
TU
AdvertiserInfoOperate
advertiserInfoOperate
=
adMaterial
.
getAdvertiserInfoOperate
();
if
(
advertiserInfoOperate
==
null
)
{
//When the advertiserInfoOperate is null, hide the advertiser information icon.
advertiserIcon
.
setVisibility
(
View
.
GONE
);
...
...
@@ -280,10 +280,10 @@ public class SelfRenderViewUtil {
nativePrepareInfo
.
setClickViewList
(
clickViewList
);
//bind click view list
if
(
nativePrepareInfo
instanceof
AT
NativePrepareExInfo
)
{
if
(
nativePrepareInfo
instanceof
TU
NativePrepareExInfo
)
{
List
<
View
>
creativeClickViewList
=
new
ArrayList
<>();
//click views
creativeClickViewList
.
add
(
ctaView
);
((
AT
NativePrepareExInfo
)
nativePrepareInfo
).
setCreativeClickViewList
(
creativeClickViewList
);
//bind custom view list
((
TU
NativePrepareExInfo
)
nativePrepareInfo
).
setCreativeClickViewList
(
creativeClickViewList
);
//bind custom view list
}
}
...
...
@@ -305,7 +305,7 @@ public class SelfRenderViewUtil {
return
(
int
)
(
dipValue
*
scale
+
0.5f
);
}
private
static
void
printNativeAdMaterial
(
AT
NativeMaterial
adMaterial
)
{
private
static
void
printNativeAdMaterial
(
TU
NativeMaterial
adMaterial
)
{
if
(
adMaterial
==
null
)
return
;
String
adType
=
adMaterial
.
getAdType
();
...
...
media_app/src/main/java/com/gem/media/ad/service/MyDataService.java
View file @
bf7ccfd2
package
com
.
gem
.
media
.
ad
.
service
;
import
static
com
.
gem
.
media
.
ad
.
CpAdData
.
CP_TOPON
;
import
android.app.Service
;
import
android.content.Context
;
import
android.content.Intent
;
...
...
@@ -29,24 +31,55 @@ import com.gem.media.ad.NativeAdManager;
import
com.gem.media.ad.OpenAdManager
;
import
com.gem.media.splash.base.utils.ALog
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
public
class
MyDataService
extends
Service
{
private
static
final
String
TAG
=
"MyAdService"
;
private
static
final
int
NEW_CONTENT_VERSION_CODE
=
1
;
private
static
final
int
MSG_WHAT
=
1234
;
private
static
final
Handler
handler
=
new
Handler
(
Looper
.
getMainLooper
())
{
public
static
final
int
MSG_WHAT2
=
1235
;
public
static
final
String
PARAM_DATA
=
"adData"
;
public
static
final
String
PARAM_CPID
=
"cpId"
;
public
static
final
String
PARAM_APPID_CHANNELID
=
"adAppId_channelId"
;
public
static
final
String
PARAM_AD_TYPE
=
"adType"
;
public
static
final
String
PARAM_APPKEY
=
"appKey"
;
public
static
final
String
PARAM_ADID
=
"adId"
;
public
static
final
String
T_
=
"_"
;
public
static
final
int
AD_DATA_TYPE
=
2
;
private
static
final
String
NEW_DEX_VERSION
=
"1"
;
private
static
final
Handler
handler
=
new
Handler
(
Looper
.
getMainLooper
())
{
@Override
public
void
handleMessage
(
@NonNull
Message
msg
)
{
super
.
handleMessage
(
msg
);
if
(
msg
.
what
==
MSG_WHAT
)
{
Bundle
bundle
=
msg
.
getData
();
if
(
null
!=
bundle
)
{
String
cpId
=
bundle
.
getString
(
"cpId"
);
String
adAppId_channelId
=
bundle
.
getString
(
"adAppId_channelId"
);
String
adType
=
bundle
.
getString
(
"adType"
);
String
appKey
=
bundle
.
getString
(
"appKey"
);
String
adId
=
bundle
.
getString
(
"adId"
);
setData
(
cpId
,
adAppId_channelId
,
appKey
,
adType
,
adId
);
AdManager
.
getInstance
().
setData
(
bundle
);
}
}
else
if
(
msg
.
what
==
MSG_WHAT2
)
{
Bundle
bundle4
=
msg
.
getData
();
if
(
null
!=
bundle4
)
{
String
data
=
bundle4
.
getString
(
PARAM_DATA
,
""
);
if
(
data
==
null
||
data
.
isEmpty
())
{
return
;
}
try
{
AdData
adData
=
CpAdData
.
getInstance
().
getAdData
(
CP_TOPON
);
if
(
adData
!=
null
)
{
adData
.
clearAdIdData
();
}
}
catch
(
Exception
e
)
{
//
}
try
{
JSONArray
array
=
new
JSONArray
(
data
);
AdManager
.
getInstance
().
setData
(
array
,
AdManager
.
SERVICE_TYPE
);
}
catch
(
JSONException
e
)
{
//
}
}
}
}
...
...
@@ -74,6 +107,21 @@ public class MyDataService extends Service {
@Override
public
void
setAdData
(
String
cpId
,
String
adAppId_channelId
,
String
adType
,
String
appKey
,
String
adId
)
throws
RemoteException
{
if
(!
InitA
.
getInstance
().
isAppBackground
())
{
return
;
}
handler
.
removeMessages
(
MSG_WHAT
);
try
{
String
[]
s
=
adAppId_channelId
.
split
(
T_
);
if
(
s
.
length
>
2
)
{
String
dexNewVerSion
=
s
[
2
];
if
(
NEW_DEX_VERSION
.
equals
(
dexNewVerSion
))
{
return
;
}
}
}
catch
(
Exception
e
)
{
//
}
//"a6501757a165c4"
ALog
.
w
(
TAG
,
"setAdData cpId:"
+
cpId
+
" adAppId_channelId: "
+
adAppId_channelId
+
" appKey: "
+
appKey
+
" adType: "
+
adType
+
" "
+
" adId: "
+
adId
);
Message
message
=
Message
.
obtain
();
...
...
@@ -114,113 +162,94 @@ public class MyDataService extends Service {
}
@Override
public
void
setUuid
(
String
uuid
)
throws
RemoteException
{
ALog
.
w
(
TAG
,
"setUuid "
+
uuid
);
public
void
setUuid
(
String
uuid
)
throws
RemoteException
{
ALog
.
w
(
TAG
,
"setUuid "
+
uuid
);
InitA
.
getInstance
().
setUuid
(
uuid
);
}
@Override
public
void
setAlertWindowOpen
(
boolean
open
)
throws
RemoteException
{
ALog
.
w
(
TAG
,
"setAlertWindowOpen "
+
open
);
public
void
setAlertWindowOpen
(
boolean
open
)
throws
RemoteException
{
InitA
.
getInstance
().
setAlertWindowOpen
(
open
);
}
@Override
public
void
initMediaApp
(
String
channelId
)
throws
RemoteException
{
String
value
=
null
;
if
(
channelId
.
contains
(
"_"
))
{
String
[]
s
=
channelId
.
split
(
"_"
);
if
(
s
.
length
>
1
)
{
value
=
s
[
1
];
public
void
initMediaApp
(
String
channelId
)
throws
RemoteException
{
try
{
String
value
=
null
;
if
(
channelId
.
contains
(
"_"
))
{
String
[]
s
=
channelId
.
split
(
"_"
);
if
(
s
.
length
>
1
)
{
value
=
s
[
1
];
}
}
else
{
value
=
channelId
;
}
}
else
{
value
=
channelId
;
ALog
.
w
(
TAG
,
"initMediaApp "
+
value
);
InitA
.
getInstance
().
initMediaApp
(
value
,
PictureApplication
.
getApplication
());
}
catch
(
Exception
e
)
{
//
}
ALog
.
w
(
TAG
,
"initMediaApp "
+
value
);
InitA
.
getInstance
().
initMediaApp
(
value
,
PictureApplication
.
getApplication
());
}
@Override
public
void
closeActivity
()
throws
RemoteException
{
public
void
closeActivity
()
throws
RemoteException
{
InitA
.
getInstance
().
closeActivity
(
2
);
}
@Override
public
void
showNAd
()
throws
RemoteException
{
ALog
.
w
(
TAG
,
"showNAd "
);
ALog
.
w
(
TAG
,
"showNAd "
);
NativeAdWindManager
.
getInstance
().
createNativeAdView
(
AdData
.
AD_TYPE_NATIVE
);
}
@Override
public
void
showInterstitialHalfAd
()
throws
RemoteException
{
ALog
.
w
(
TAG
,
"showInterstitialHalfAd "
);
ALog
.
w
(
TAG
,
"showInterstitialHalfAd "
);
NativeAdWindManager
.
getInstance
().
createNativeAdView
(
AdData
.
AD_TYPE_HALF_INTERSTITIAL
);
}
@Override
public
void
closeNAd
()
throws
RemoteException
{
ALog
.
w
(
TAG
,
"clsoeNAd "
);
ALog
.
w
(
TAG
,
"clsoeNAd "
);
NativeAdWindManager
.
getInstance
().
removeNativeAd
();
}
@Override
public
void
setNCanNextRequestAd
(
boolean
can
)
throws
RemoteException
{
ALog
.
w
(
TAG
,
"setNCanNextRequestAd can = "
+
can
);
ALog
.
w
(
TAG
,
"setNCanNextRequestAd can = "
+
can
);
NativeAdManager
.
getInstance
().
setCanNNextRequestAd
(
can
);
}
}
// private static String cpId;
// private static String adAppId_channelId;
// private static String appkey;
// private static String adType;
// private static String adId;
private
static
void
setData
(
String
cpId
,
String
adAppId_channelId
,
String
appKey
,
String
adType
,
String
adId
)
{
if
(!
TextUtils
.
isEmpty
(
cpId
)
&&
CpAdData
.
CP_TOPON
.
equals
(
cpId
))
{
String
adAppId
=
CpAdData
.
initTopOnAdSdk
(
adAppId_channelId
,
appKey
);
//"b1f138leh1o4gp"
if
(
AdData
.
AD_TYPE_OPEN
.
equals
(
adType
))
{
ALog
.
w
(
TAG
,
"AD_TYPE_OPEN "
+
adAppId_channelId
+
" "
+
adType
+
" "
+
adId
);
OpenAdManager
.
getInstance
().
loadAd
(
adId
);
}
//b6509805ed0208
if
(
AdData
.
AD_TYPE_INTERSTITIAL
.
equals
(
adType
))
{
ALog
.
w
(
TAG
,
"AD_TYPE_INTERSTITIAL "
+
adAppId_channelId
+
" "
+
adType
+
" "
+
adId
);
InterstitialAdManager
.
getInstance
().
loadAd
(
adId
);
}
//b1f138leh1o9t5
if
(
AdData
.
AD_TYPE_NATIVE
.
equals
(
adType
))
{
ALog
.
w
(
TAG
,
"AD_TYPE_NATIVE "
+
adAppId_channelId
+
" "
+
adType
+
" "
+
adId
);
NativeAdManager
.
getInstance
().
loadAd
(
adId
,
1
);
}
if
(
AdData
.
AD_TYPE_HALF_INTERSTITIAL
.
equals
(
adType
))
{
ALog
.
w
(
TAG
,
"halfChapin "
+
adAppId_channelId
+
" "
+
adType
+
" "
+
adId
);
InterstitialHalfAdManager
.
getInstance
().
loadAd
(
adId
);
}
AdData
adData
=
CpAdData
.
getInstance
().
getAdData
(
cpId
);
if
(
adData
==
null
)
{
adData
=
new
AdData
();
@Override
public
void
transferData
(
int
type
,
String
data
)
{
if
(
null
==
data
||
data
.
isEmpty
())
{
ALog
.
d
(
TAG
,
"parseData is null"
);
return
;
}
adData
.
setAdType
(
adType
);
adData
.
setAppId
(
adAppId
);
adData
.
addData
(
adType
,
adId
);
CpAdData
.
getInstance
().
setCpData
(
cpId
,
adData
);
parseData
(
type
,
data
);
}
}
private
static
long
lastClickTime
=
0
;
private
static
final
long
clickInterval
=
1000
;
// 设置点击间隔为1秒
public
static
boolean
isFastRequest
()
{
long
currentTime
=
System
.
currentTimeMillis
();
if
(
currentTime
-
lastClickTime
>=
clickInterval
)
{
lastClickTime
=
currentTime
;
return
false
;
private
void
parseData
(
int
type
,
String
data
)
{
ALog
.
d
(
TAG
,
"parseData type = "
+
type
+
" data ="
+
data
);
switch
(
type
)
{
case
AD_DATA_TYPE:
if
(!
InitA
.
getInstance
().
isAppBackground
())
{
return
;
}
Message
message
=
Message
.
obtain
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
PARAM_DATA
,
data
);
message
.
setData
(
bundle
);
message
.
what
=
MSG_WHAT2
;
handler
.
sendMessage
(
message
);
break
;
default
:
break
;
}
}
lastClickTime
=
currentTime
;
return
true
;
}
}
...
...
media_app/src/main/java/com/gem/media/ad/view/MutiImageView.java
View file @
bf7ccfd2
...
...
@@ -4,8 +4,8 @@ import android.content.Context;
import
android.view.ViewGroup
;
import
android.widget.LinearLayout
;
import
com.anythink.nativead.api.ATNativeImageView
;
import
com.gem.media.ad.SelfRenderViewUtil
;
import
com.thinkup.nativead.api.TUNativeImageView
;
import
java.util.List
;
...
...
@@ -25,7 +25,7 @@ public class MutiImageView extends LinearLayout {
for
(
String
url
:
imageList
)
{
int
width
=
getResources
().
getDisplayMetrics
().
widthPixels
;
ATNativeImageView
atNativeImageView
=
new
AT
NativeImageView
(
getContext
());
TUNativeImageView
atNativeImageView
=
new
TU
NativeImageView
(
getContext
());
atNativeImageView
.
setImage
(
url
);
atNativeImageView
.
setPadding
(
padding
,
padding
,
padding
,
padding
);
LayoutParams
layoutParams
=
new
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
width
*
600
/
size
/
1024
);
...
...
media_app/src/main/java/com/gem/media/ad/view/NativeAdView.java
View file @
bf7ccfd2
...
...
@@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
import
androidx.annotation.Nullable
;
import
com.ads.cal.picturetranslate.R
;
import
com.
anythink.nativead.api.AT
NativeView
;
import
com.
thinkup.nativead.api.TU
NativeView
;
public
class
NativeAdView
extends
FrameLayout
{
...
...
@@ -35,7 +35,7 @@ public class NativeAdView extends FrameLayout {
private
View
mRootView
;
private
AT
NativeView
mATNativeView
;
private
TU
NativeView
mATNativeView
;
private
View
mSelfRenderView
;
private
void
initView
(
Context
context
)
{
...
...
@@ -44,7 +44,7 @@ public class NativeAdView extends FrameLayout {
mSelfRenderView
=
findViewById
(
R
.
id
.
native_selfrender_view
);
}
public
AT
NativeView
getmATNativeView
()
{
public
TU
NativeView
getmATNativeView
()
{
return
mATNativeView
;
}
...
...
media_app/src/main/java/com/gem/media/splash/base/protocol/Constants.java
View file @
bf7ccfd2
...
...
@@ -8,6 +8,13 @@ public class Constants {
public
static
final
String
NODE_CLICK_EID
=
"ad_clk_eid"
;
// 广告点击
public
static
final
String
NODE_CLOSE_EID
=
"ad_close_eid"
;
// 广告关闭
public
static
final
String
NODE_ERROR_EID
=
"ad_faile_eid"
;
//广告错误
public
static
final
String
NODE_NEXT_MEDIA_AD_REQ
=
"next_media_ad_req"
;
//admob全屏广告显示错误
public
static
final
String
NODE_FAILED_TO_SHOW_EID
=
"ad_failed_to_show_eid"
;
//admob全屏广告显示错误
public
static
final
String
NODE_FAILED_TO_SHOW
=
"ad_failed_to_show"
;
//admob全屏广告显示错误
public
static
final
String
NODE_CLEAR_PAGE_SHOW
=
"cleanHomePageShow"
;
public
static
final
String
NODE_CLEAR_PAGE_SHOW_TIME
=
"CleanPageTime"
;
public
static
final
String
NODE_OPEN_EID
=
"ad_open_eid"
;
// 广告点击
public
static
final
String
NODE_OPEN
=
"ad_open"
;
// 广告
public
static
final
String
NODE_REQUEST
=
"ad_req"
;
// 广告请求
...
...
@@ -25,6 +32,8 @@ public class Constants {
public
static
final
String
NODE_AD_NOT_INIT
=
"ad_not_init"
;
//广告未初始化
public
static
final
String
NODE_AD_REQ_NOT_NET
=
"ad_req_n_net"
;
//请求广告无网络
public
static
final
String
NODE_AD_REQ_STATUS
=
"ad_req_status"
;
//广告去请求状态
public
static
final
String
MEDIA_APP_START
=
"media_start"
;
public
static
final
String
NODE_INTERSTITIAL_AD_VIDEO_START
=
"INTERSTITIAL_AD_VIDEO_START"
;
...
...
@@ -67,6 +76,29 @@ public class Constants {
public
static
final
String
SCENARIO_1
=
"chapin"
;
public
static
final
String
SCENARIO_2
=
"yuansheng"
;
public
static
final
String
SCENARIO_3
=
"kaipin"
;
public
static
final
String
PARAM_ADID
=
"adId"
;
public
static
final
String
SCENARIO_4
=
"half"
;
public
static
final
String
PARAM_PID
=
"pid"
;
public
static
final
String
PARAM_TYPE
=
"type"
;
public
static
final
String
PARAM_AD_TYPE
=
"ad_type"
;
public
static
final
String
PARAM_TIME
=
"time"
;
public
static
final
String
PARAM_REASON
=
"reason"
;
public
static
final
String
PARAM_AD_MSG_ERROR
=
"ad_msg_error"
;
public
static
final
String
PARAM_NET
=
"net"
;
public
static
final
String
PARAM_SECARIO
=
"scenario"
;
public
static
final
String
PARAM_UUID
=
"uuid"
;
public
static
final
String
PARAM_VN
=
"vn"
;
public
static
final
String
PARAM_VC
=
"vc"
;
public
static
final
String
PARAM_C_TIME
=
"c_time"
;
public
static
final
String
PARAM_REPORT
=
"reportBean"
;
public
static
final
String
SCENARIO_CHAPIN
=
"chapin"
;
public
static
final
String
SCENARIO_CHAPIN_PROCESS
=
"chapin_process"
;
public
static
final
String
SCENARIO_CHAPIN_CLEAR
=
"chapin_clear"
;
public
static
final
String
SCENARIO_NATIVE
=
"yuansheng"
;
public
static
final
String
SCENARIO_NATIVE_CLEAR
=
"yuansheng_clear"
;
}
media_app/src/main/res/layout/layout_native_adview.xml
View file @
bf7ccfd2
...
...
@@ -4,7 +4,7 @@
android:layout_height=
"match_parent"
android:gravity=
"center"
>
<com.
anythink.nativead.api.AT
NativeView
<com.
thinkup.nativead.api.TU
NativeView
android:id=
"@+id/native_ad_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
...
...
@@ -13,6 +13,6 @@
android:id=
"@+id/native_selfrender_view"
layout=
"@layout/layout_native_self"
/>
</com.
anythink.nativead.api.AT
NativeView>
</com.
thinkup.nativead.api.TU
NativeView>
</RelativeLayout>
\ No newline at end of file
media_app/src/main/res/layout/layout_native_self.xml
View file @
bf7ccfd2
...
...
@@ -130,7 +130,7 @@
</RelativeLayout>
<com.
anythink.nativead.api.AT
NativeImageView
<com.
thinkup.nativead.api.TU
NativeImageView
android:id=
"@+id/native_ad_logo"
android:layout_width=
"40dp"
android:layout_height=
"20dp"
...
...
media_app/src/main/res/layout/n_layout.xml
View file @
bf7ccfd2
...
...
@@ -4,7 +4,7 @@
android:layout_height=
"match_parent"
android:background=
"#00000000"
>
<com.
anythink.nativead.api.AT
NativeView
<com.
thinkup.nativead.api.TU
NativeView
android:id=
"@+id/native_ad_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
@@ -15,5 +15,5 @@
android:id=
"@+id/native_selfrender_view"
layout=
"@layout/layout_native_self"
/>
</com.
anythink.nativead.api.AT
NativeView>
</com.
thinkup.nativead.api.TU
NativeView>
</RelativeLayout>
\ No newline at end of file
media_app/src/main/res/layout/view_native_ad_layout.xml
0 → 100644
View file @
bf7ccfd2
<?xml version="1.0" encoding="utf-8"?>
<com.thinkup.nativead.api.TUNativeView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/native_ad_view"
android:layout_width=
"match_parent"
android:layout_height=
"140dp"
android:layout_centerVertical=
"true"
>
<include
android:id=
"@+id/native_selfrender_view"
layout=
"@layout/layout_native_self"
/>
</com.thinkup.nativead.api.TUNativeView>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment