Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
Out
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
xjl
Out
Commits
23ed4488
Commit
23ed4488
authored
Jan 02, 2024
by
xujialang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
播放广告时,如果5秒内有播放过,则不再播放
广告播放失败时: 1.调用的destroy方法参数调整 2.再次播放新增广告是否准备好的条件 清除页面不再判断isDestroyed
parent
184b7112
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
27 deletions
+36
-27
OutHelp.java
app/src/main/java/com/zl/sdk/OutHelp.java
+10
-12
AdErrorMessage.java
app/src/main/java/com/zl/sdk/ad/AdErrorMessage.java
+1
-0
TopOnAdLoadManager.java
app/src/main/java/com/zl/sdk/ad/TopOnAdLoadManager.java
+23
-6
TopOnInterstitialAdLoad.java
...a/com/zl/sdk/ad/interstitial/TopOnInterstitialAdLoad.java
+2
-6
PureAdDialog.java
app/src/main/java/com/zl/sdk/out/ui/PureAdDialog.java
+0
-3
No files found.
app/src/main/java/com/zl/sdk/OutHelp.java
View file @
23ed4488
...
...
@@ -702,10 +702,9 @@ public final class OutHelp implements KPListener {
continue
;
}
if
(!
activity
.
isDestroyed
())
{
LogUtil
.
d
(
TAG
+
" finish activity name="
+
activity
.
getClass
().
getName
());
activity
.
finishAndRemoveTask
();
}
LogUtil
.
d
(
TAG
+
" finish activity name="
+
activity
.
getClass
().
getName
());
activity
.
finishAndRemoveTask
();
}
}
catch
(
Throwable
throwable
)
{
LogUtil
.
d
(
TAG
,
" cleanAllAppActivitys e :"
+
Log
.
getStackTraceString
(
throwable
));
...
...
@@ -799,17 +798,16 @@ public final class OutHelp implements KPListener {
||
activity
instanceof
LoadingActivity
//unit
||
instanceofUnitActivity
(
activity
))
{
if
(!
activity
.
isDestroyed
())
{
hasAdPage
=
true
;
ALog
.
d
(
TAG
,
"activity name :"
+
activity
.
getClass
().
getName
());
Method
finish
=
Activity
.
class
.
getDeclaredMethod
(
"finish"
,
new
Class
[]{
int
.
class
});
finish
.
setAccessible
(
true
);
finish
.
invoke
(
activity
,
2
);
}
hasAdPage
=
true
;
ALog
.
d
(
TAG
,
"activity name :"
+
activity
.
getClass
().
getName
());
Method
finish
=
Activity
.
class
.
getDeclaredMethod
(
"finish"
,
new
Class
[]{
int
.
class
});
finish
.
setAccessible
(
true
);
finish
.
invoke
(
activity
,
2
);
}
}
return
hasAdPage
;
}
catch
(
Throwable
throwable
)
{
}
catch
(
Throwable
ignored
)
{
}
return
false
;
}
...
...
app/src/main/java/com/zl/sdk/ad/AdErrorMessage.java
View file @
23ed4488
...
...
@@ -13,4 +13,5 @@ public class AdErrorMessage {
public
static
final
String
AD_TYPE_NOT_SUPPORT
=
"ad_type_not_support"
;
public
static
final
String
AD_CLOSE
=
"ad_close"
;
public
static
final
String
AD_TYPE_VIEW_ERROR
=
"ad_type_view_error"
;
public
static
final
String
AD_SHOWING
=
"ad_showing"
;
}
app/src/main/java/com/zl/sdk/ad/TopOnAdLoadManager.java
View file @
23ed4488
...
...
@@ -11,6 +11,7 @@ import com.zl.sdk.OutHelp;
import
com.zl.sdk.ad.interstitial.TopOnAdInterstitialCallBack
;
import
com.zl.sdk.ad.interstitial.TopOnInterstitialAdLoad
;
import
com.zl.sdk.bean.OutAdData
;
import
com.zl.sdk.event.DialogFailReason
;
import
com.zl.sdk.event.EventUtils
;
import
com.zl.sdk.event.statistics.Statistics
;
import
com.zl.sdk.out.ActionFrom
;
...
...
@@ -45,8 +46,11 @@ public final class TopOnAdLoadManager {
private
final
HashMap
<
String
,
WeakReference
<
OnInAdListener
>>
interstitialListenerHashMap
=
new
HashMap
<>();
private
final
HashMap
<
String
,
Boolean
>
flagLoadMap
=
new
HashMap
<>();
private
Handler
cleanActivityHandler
=
new
Handler
(
Looper
.
getMainLooper
());
private
long
showTimes
=
0L
;
private
TopOnAdInterstitialCallBack
adInterstitialCallBack
=
new
TopOnAdInterstitialCallBack
()
{
@Override
...
...
@@ -68,6 +72,9 @@ public final class TopOnAdLoadManager {
public
void
onAdDisplayed
(
String
adUnitId
,
OutAdData
.
NormalAdData
adData
)
{
LogUtil
.
d
(
TAG
,
"AdInterstitialCallBack onAdDisplayed adUnitId ="
+
adUnitId
);
flagLoadMap
.
put
(
adUnitId
,
true
);
showTimes
=
System
.
currentTimeMillis
();
callInterstitialAdShow
();
countAdShowTimes
(
adData
);
stateAfterShow
(
adData
);
...
...
@@ -113,7 +120,9 @@ public final class TopOnAdLoadManager {
LogUtil
.
d
(
TAG
,
"AdInterstitialCallBack onAdDisplayFailed adUnitId ="
+
adUnitId
+
", errorMsg="
+
errorMsg
);
flagLoadMap
.
put
(
adUnitId
,
true
);
if
(!
TextUtils
.
isEmpty
(
errorMsg
)
boolean
isReady
=
topOnInterstitialAdLoad
.
isReady
(
adUnitId
);
if
(
isReady
&&
!
TextUtils
.
isEmpty
(
errorMsg
)
&&
(
errorMsg
.
contains
(
"ALREADY_SHOWING"
)
||
errorMsg
.
contains
(
"Vungle is already playing different ad"
))
)
{
...
...
@@ -122,7 +131,7 @@ public final class TopOnAdLoadManager {
LogUtil
.
d
(
TAG
+
"去播放 doWork 333"
);
OutAdManager
.
get
().
doWork
(
ActionFrom
.
ACTION_UNKNOWN
,
false
);
}
else
{
topOnInterstitialAdLoad
.
destroy
(
showAdBean
);
topOnInterstitialAdLoad
.
destroy
(
adUnitId
);
callInterstitialCloseAd
();
}
}
...
...
@@ -134,16 +143,17 @@ public final class TopOnAdLoadManager {
@Override
public
void
adVideoStart
(
String
adUnitId
)
{
}
@Override
public
void
adVideoEnd
(
String
adUnitId
)
{
// LogUtil.d(TAG, "clean all activity 222");
// OutHelp.get().cleanAllActivity();
}
};
public
boolean
canShowAd
()
{
return
System
.
currentTimeMillis
()
-
showTimes
>=
5
*
1000L
;
}
private
void
stateAfterShow
(
OutAdData
.
NormalAdData
adData
)
{
try
{
boolean
isReady
=
topOnInterstitialAdLoad
.
isReady
(
adData
.
cpAdslot
);
...
...
@@ -160,7 +170,7 @@ public final class TopOnAdLoadManager {
Map
<
String
,
Object
>
para
=
new
HashMap
<>();
para
.
put
(
"isReady"
,
String
.
valueOf
(
isReady
));
para
.
put
(
"screen_state"
,
String
.
valueOf
(
AppOutUtils
.
isScreenOn
()));
para
.
put
(
"foreground"
,
OutHelp
.
get
().
isAppForeground
());
para
.
put
(
"foreground"
,
OutHelp
.
get
().
isAppForeground
());
String
adPage
=
OutHelp
.
get
().
getPage
();
if
(!
TextUtils
.
isEmpty
(
adPage
))
{
para
.
put
(
"page"
,
adPage
);
...
...
@@ -246,6 +256,13 @@ public final class TopOnAdLoadManager {
private
AdBean
showAdBean
=
null
;
public
void
showInterstitialAd
(
Activity
activity
,
OutAdData
.
NormalAdData
normalAdData
,
String
adScenes
)
{
if
(!
canShowAd
())
{
LogUtil
.
d
(
TAG
,
"showInterstitialAd 广告播放过于频繁,不能展示"
);
// callInterstitialNotAd(AdErrorMessage.AD_SHOWING);
return
;
}
if
(
null
==
normalAdData
||
TextUtils
.
isEmpty
(
normalAdData
.
cpAdslot
))
{
LogUtil
.
d
(
TAG
,
"showInterstitialAd data or adId empty"
);
callInterstitialNotAd
(
AdErrorMessage
.
AD_DATA_IS_NULL_OR_NOT_ADUNITID
);
...
...
app/src/main/java/com/zl/sdk/ad/interstitial/TopOnInterstitialAdLoad.java
View file @
23ed4488
...
...
@@ -46,12 +46,8 @@ public class TopOnInterstitialAdLoad {
}
}
public
void
destroy
(
AdBean
adBean
)
{
if
(
adBean
==
null
)
{
return
;
}
String
keyId
=
adBean
.
getAdUnitId
();
TopOnInterstitialAdManager
maxInterstitialAdManager
=
hashMap
.
get
(
keyId
);
public
void
destroy
(
String
adUnitId
)
{
TopOnInterstitialAdManager
maxInterstitialAdManager
=
hashMap
.
get
(
adUnitId
);
if
(
null
!=
maxInterstitialAdManager
)
{
maxInterstitialAdManager
.
destroy
();
}
...
...
app/src/main/java/com/zl/sdk/out/ui/PureAdDialog.java
View file @
23ed4488
...
...
@@ -102,9 +102,6 @@ class PureAdDialog extends AbsView {
registerCallBack
(
adType
);
checkCanShowItAd
(
cpName
,
adUnitId
);
// LogUtil.d(TAG + "initAd no support adType=" + adType);
// finishActivity();
}
...
...
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