Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
A
appzxhy
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
wanglei
appzxhy
Commits
e0070842
Commit
e0070842
authored
Jun 06, 2025
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[修改]将开屏和插页共用上次展示时间字段,避免开屏和插页连弹
parent
c058ff36
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
22 additions
and
12 deletions
+22
-12
AdConfigBean.kt
...rc/main/java/com/base/appzxhy/bean/config/AdConfigBean.kt
+1
-1
AdState.kt
app/src/main/java/com/base/appzxhy/business/ads/AdState.kt
+5
-3
LimitUtils.kt
...src/main/java/com/base/appzxhy/business/ads/LimitUtils.kt
+12
-4
AdInterMgr.kt
...in/java/com/base/appzxhy/business/ads/admob/AdInterMgr.kt
+1
-1
AdOpenMgr.kt
...ain/java/com/base/appzxhy/business/ads/admob/AdOpenMgr.kt
+1
-1
MaxInsertMgr.kt
...va/com/base/appzxhy/business/ads/applovin/MaxInsertMgr.kt
+1
-1
MaxOpenMgr.kt
...java/com/base/appzxhy/business/ads/applovin/MaxOpenMgr.kt
+1
-1
No files found.
app/src/main/java/com/base/appzxhy/bean/config/AdConfigBean.kt
View file @
e0070842
...
...
@@ -11,7 +11,7 @@ class AdConfigBean(
var
numDisplayLimit
:
Int
=
-
1
,
//展示次数限制
var
numRequestLimit
:
Int
=
-
1
,
//请求次数限制
var
numClickLimit
:
Int
=
-
1
,
//点击次数限制
var
timeInterval
:
Int
=
1
,
//广告间隔
var
timeInterval
:
Int
=
1
0
,
//广告间隔秒
var
openAdLoading
:
Int
=
15
,
//开屏广告拉取时间
var
fullNativeShow
:
Boolean
=
true
,
//显示全屏原生
...
...
app/src/main/java/com/base/appzxhy/business/ads/AdState.kt
View file @
e0070842
...
...
@@ -2,6 +2,8 @@ package com.base.appzxhy.business.ads
import
android.app.Activity
import
android.app.Dialog
import
com.base.appzxhy.business.ads.LimitUtils.openInterLastShowTime
import
com.base.appzxhy.utils.AppPreferences
import
java.lang.ref.WeakReference
...
...
@@ -34,7 +36,7 @@ class AdState<T>() {
/**
* 上次展示时间
*/
var
lastShowTime
:
Long
=
0
//
var lastShowTime: Long = 0
/**
...
...
@@ -47,13 +49,13 @@ class AdState<T>() {
adDialog
?.
dismiss
()
adDialog
=
null
l
astShowTime
=
System
.
currentTimeMillis
()
openInterL
astShowTime
=
System
.
currentTimeMillis
()
}
fun
onAdHidden
()
{
//重置下上次展示的时间,避免看广告的时间算入间隔
l
astShowTime
=
System
.
currentTimeMillis
()
openInterL
astShowTime
=
System
.
currentTimeMillis
()
}
...
...
app/src/main/java/com/base/appzxhy/business/ads/LimitUtils.kt
View file @
e0070842
...
...
@@ -145,14 +145,22 @@ object LimitUtils {
/**
* 开屏和插页广告的显示间隔限制
*
* @param lastTime 上一次显示的时间
*/
fun
isIntervalLimited
(
lastTime
:
Long
,
adEvent
:
AdEvent
):
Boolean
{
val
flag
=
((
System
.
currentTimeMillis
()
-
last
Time
)
/
1000
).
toInt
()
<
(
AdConfigBean
.
adsConfigBean
.
timeInterval
)
fun
isIntervalLimited
(
adEvent
:
AdEvent
):
Boolean
{
val
flag
=
((
System
.
currentTimeMillis
()
-
openInterLastShow
Time
)
/
1000
).
toInt
()
<
(
AdConfigBean
.
adsConfigBean
.
timeInterval
)
if
(
flag
)
{
adEvent
.
adShowError
(
"ad in timeInterval"
)
}
return
flag
}
//开屏和插页上一次展示时间共用,避免开屏插页连弹
var
openInterLastShowTime
=
0L
get
()
{
return
AppPreferences
.
getInstance
().
getLong
(
"openInterLastShowTime"
,
field
)
}
set
(
value
)
{
field
=
value
AppPreferences
.
getInstance
().
put
(
"openInterLastShowTime"
,
value
,
true
)
}
}
\ No newline at end of file
app/src/main/java/com/base/appzxhy/business/ads/admob/AdInterMgr.kt
View file @
e0070842
...
...
@@ -45,7 +45,7 @@ class AdInterMgr {
showCallBack
?.
failed
(
2
)
return
}
if
(
LimitUtils
.
isIntervalLimited
(
adState
.
lastShowTime
,
adEvent
))
{
if
(
LimitUtils
.
isIntervalLimited
(
adEvent
))
{
showCallBack
?.
failed
(
3
)
return
}
...
...
app/src/main/java/com/base/appzxhy/business/ads/admob/AdOpenMgr.kt
View file @
e0070842
...
...
@@ -36,7 +36,7 @@ class AdOpenMgr {
showCallBack
?.
failed
()
return
}
if
(
LimitUtils
.
isIntervalLimited
(
ad
State
.
lastShowTime
,
ad
Event
))
{
if
(
LimitUtils
.
isIntervalLimited
(
adEvent
))
{
showCallBack
?.
failed
()
return
}
...
...
app/src/main/java/com/base/appzxhy/business/ads/applovin/MaxInsertMgr.kt
View file @
e0070842
...
...
@@ -50,7 +50,7 @@ class MaxInsertMgr {
showCallBack
?.
failed
(
3
)
return
}
if
(
LimitUtils
.
isIntervalLimited
(
ad
State
.
lastShowTime
,
ad
Event
))
{
if
(
LimitUtils
.
isIntervalLimited
(
adEvent
))
{
showCallBack
?.
failed
(
4
)
return
}
...
...
app/src/main/java/com/base/appzxhy/business/ads/applovin/MaxOpenMgr.kt
View file @
e0070842
...
...
@@ -40,7 +40,7 @@ class MaxOpenMgr {
showCallBack
?.
failed
()
return
}
if
(
LimitUtils
.
isIntervalLimited
(
ad
State
.
lastShowTime
,
ad
Event
))
{
if
(
LimitUtils
.
isIntervalLimited
(
adEvent
))
{
showCallBack
?.
failed
()
return
}
...
...
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