Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
X
xxsq
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王雪伟
xxsq
Commits
4f793565
Commit
4f793565
authored
Jul 12, 2022
by
王雪伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[提交人]:王雪伟
[提交简述] :1.1.4 [实现方案] :修复未初始化,开屏广告无回调,导致无法进入app的问题。
parent
1e6fdf36
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
13 deletions
+52
-13
AdManager.kt
moduleZxAd/src/main/java/com/zx/ad/AdManager.kt
+24
-4
CSJAdManager.kt
...ZxAd/src/main/java/com/zx/ad/platform/csj/CSJAdManager.kt
+8
-3
TTAdManagerHolder.java
...c/main/java/com/zx/ad/platform/csj/TTAdManagerHolder.java
+20
-6
No files found.
moduleZxAd/src/main/java/com/zx/ad/AdManager.kt
View file @
4f793565
package
com.zx.ad
import
android.app.Activity
import
android.app.Application
import
android.content.Context
import
android.content.ContextWrapper
import
android.util.Log
import
android.widget.FrameLayout
import
com.bytedance.sdk.openadsdk.TTAdSdk
import
com.zx.ad.callback.AdLoadCallBack
import
com.zx.ad.callback.RewardVideoAdListener
import
com.zx.ad.callback.SplashAdListener
...
...
@@ -88,7 +88,7 @@ object AdManager {
for
(
i
in
result
.
indices
)
{
when
(
result
[
i
].
adPlatform
)
{
ADType
.
PLATFORM_AD_TT
->
{
CSJAdManager
.
adInit
(
context
,
result
[
i
].
codeAppId
?:
""
)
CSJAdManager
.
adInit
(
context
,
result
[
i
].
codeAppId
?:
""
,
null
)
}
ADType
.
PLATFORM_AD_KS
->
{
KsAdManager
.
adInit
(
context
,
result
[
i
].
codeAppId
?:
""
)
...
...
@@ -102,7 +102,7 @@ object AdManager {
fun
loadSplashAd
(
context
:
Activity
,
mSplashContainer
:
FrameLayout
,
listener
:
SplashAdListener
)
{
if
(
context
.
isFinishing
){
if
(
context
.
isFinishing
)
{
return
}
if
(
isLoadSplash
)
{
...
...
@@ -115,6 +115,25 @@ object AdManager {
.
compose
(
RxSchedulers
.
observableIO2Main
())
.
subscribe
(
object
:
BaseObserver
<
List
<
NewsEntity
>?>()
{
override
fun
onSuccess
(
result
:
List
<
NewsEntity
>?)
{
//本次针对穿山甲处理,当加入其它平台时需要测试未初始化的情况下,是否有error回调
if
(!
TTAdSdk
.
isInitSuccess
())
{
CSJAdManager
.
adInit
(
context
,
"5306826"
,
object
:
TTAdSdk
.
InitCallback
{
override
fun
success
()
{
if
(
result
.
isNullOrEmpty
())
{
isLoadSplash
=
false
listener
.
onError
(
"loadSplashAd IS NULL"
)
}
else
{
loadingSplashAd
(
context
,
result
,
mSplashContainer
,
listener
)
}
}
override
fun
fail
(
p0
:
Int
,
p1
:
String
?)
{
isLoadSplash
=
false
listener
.
onError
(
"AdSDK_NOT_INIT"
+
TTAdSdk
.
isInitSuccess
())
}
})
return
}
if
(
result
.
isNullOrEmpty
())
{
isLoadSplash
=
false
listener
.
onError
(
"loadSplashAd IS NULL"
)
...
...
@@ -177,6 +196,7 @@ object AdManager {
isLoadSplash
=
false
listener
.
onError
(
"loadFail end"
)
}
else
{
LogUtils
.
e
(
"errorMsg:${errorMsg}"
)
var
entity
=
totalEntity
[
0
];
totalEntity
.
removeAt
(
0
)
loadAdPlatform
(
context
,
entity
,
ADType
.
AD_SPLASH
,
this
)
...
...
@@ -189,7 +209,7 @@ object AdManager {
}
fun
loadRewardAd
(
context
:
Activity
,
listener
:
RewardVideoAdListener
)
{
if
(
context
.
isFinishing
){
if
(
context
.
isFinishing
)
{
return
}
if
(
isLoadReward
)
{
...
...
moduleZxAd/src/main/java/com/zx/ad/platform/csj/CSJAdManager.kt
View file @
4f793565
...
...
@@ -3,6 +3,7 @@ package com.zx.ad.platform.csj
import
android.app.Activity
import
android.content.Context
import
android.os.Bundle
import
android.util.Log
import
android.view.View
import
android.widget.FrameLayout
import
com.bytedance.sdk.openadsdk.*
...
...
@@ -23,8 +24,8 @@ import com.zx.ad.utils.UIUtils
*/
object
CSJAdManager
{
private
var
mTTAdNative
:
TTAdNative
?
=
null
fun
adInit
(
context
:
Context
,
appId
:
String
)
{
TTAdManagerHolder
.
init
(
context
,
appId
)
fun
adInit
(
context
:
Context
,
appId
:
String
,
initCallback
:
TTAdSdk
.
InitCallback
?
)
{
TTAdManagerHolder
.
init
(
context
,
appId
,
initCallback
)
// TTAdManagerHolder.init(context, "5001121")
}
...
...
@@ -35,6 +36,10 @@ object CSJAdManager {
*/
fun
loadSplashAd
(
context
:
Context
,
entity
:
NewsEntity
,
loadCallBack
:
AdLoadCallBack
)
{
mTTAdNative
=
TTAdManagerHolder
.
get
().
createAdNative
(
context
)
if
(
mTTAdNative
==
null
){
loadCallBack
.
OnAdLoadFail
(
"loadSplashAd mTTAdNative is null"
)
return
}
val
splashWidthPx
=
UIUtils
.
getScreenWidthInPx
(
context
)
val
screenHeightPx
=
UIUtils
.
getScreenHeight
(
context
)
val
splashWidthDp
=
UIUtils
.
getScreenWidthDp
(
context
)
...
...
@@ -44,9 +49,9 @@ object CSJAdManager {
.
setImageAcceptedSize
(
splashWidthPx
,
screenHeightPx
)
.
setExpressViewAcceptedSize
(
splashWidthDp
,
screenHeightDp
)
.
build
()
mTTAdNative
?.
loadSplashAd
(
adSlot
,
object
:
TTAdNative
.
SplashAdListener
{
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
Log
.
d
(
"AdManager"
,
"p0"
+
p0
)
AdEventUtils
.
onEventPullFail
(
entity
)
loadCallBack
.
OnAdLoadFail
(
"CSJ p0:${p0} p1:${p1}"
)
}
...
...
moduleZxAd/src/main/java/com/zx/ad/platform/csj/TTAdManagerHolder.java
View file @
4f793565
...
...
@@ -26,29 +26,43 @@ public class TTAdManagerHolder {
}
public
static
void
init
(
final
Context
context
,
String
appId
)
{
doInit
(
context
,
appId
);
public
static
void
init
(
final
Context
context
,
String
appId
,
TTAdSdk
.
InitCallback
initCallback
)
{
doInit
(
context
,
appId
,
initCallback
);
}
//step1:接入网盟广告sdk的初始化操作,详情见接入文档和穿山甲平台说明
private
static
void
doInit
(
Context
context
,
String
appId
)
{
private
static
void
doInit
(
Context
context
,
String
appId
,
TTAdSdk
.
InitCallback
initCallback
)
{
if
(!
sInit
)
{
//TTAdSdk.init(context, buildConfig(context));
TTAdSdk
.
init
(
context
,
buildConfig
(
context
,
appId
),
new
TTAdSdk
.
InitCallback
()
{
@Override
public
void
success
()
{
if
(
initCallback
!=
null
){
initCallback
.
success
();
}
sInit
=
true
;
Log
.
i
(
TAG
,
"success: "
+
TTAdSdk
.
isInitSuccess
());
}
@Override
public
void
fail
(
int
code
,
String
msg
)
{
Log
.
i
(
TAG
,
"fail: code = "
+
code
+
" msg = "
+
msg
);
if
(
initCallback
!=
null
){
initCallback
.
fail
(
code
,
msg
);
}
sInit
=
true
;
}
});
sInit
=
true
;
}
else
{
if
(
initCallback
!=
null
){
if
(
TTAdSdk
.
isInitSuccess
()){
initCallback
.
success
();
}
else
{
initCallback
.
fail
(-
1
,
"wxw initFail"
);
}
}
}
}
...
...
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