Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
SuperEasyClean
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
songjianyu
SuperEasyClean
Commits
34708c65
Commit
34708c65
authored
Jun 24, 2025
by
songjianyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加原生广告数量限制,添加广告是否显示的回调
parent
1dad641d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
18 deletions
+48
-18
AdsMgr.kt
app/src/main/java/com/easy/clean/business/ads/AdsMgr.kt
+6
-3
LimitUtils.kt
app/src/main/java/com/easy/clean/business/ads/LimitUtils.kt
+23
-10
AdNativeMgr.kt
...ain/java/com/easy/clean/business/ads/admob/AdNativeMgr.kt
+8
-1
ExitDialog.kt
app/src/main/java/com/easy/clean/ui/dialog/ExitDialog.kt
+4
-1
FunctionBackDialog.kt
.../main/java/com/easy/clean/ui/dialog/FunctionBackDialog.kt
+4
-1
dialog_function_back.xml
app/src/main/res/layout/dialog_function_back.xml
+3
-2
No files found.
app/src/main/java/com/easy/clean/business/ads/AdsMgr.kt
View file @
34708c65
...
...
@@ -244,22 +244,25 @@ object AdsMgr {
fun
showNative
(
nativeView
:
NativeParentView
,
@LayoutRes
layout
:
Int
,
nativeCallBack
:
((
Any
?)
->
Unit
)?
=
null
nativeCallBack
:
((
Any
?)
->
Unit
)?
=
null
,
isShowCallBack
:
((
Boolean
)->
Unit
)?=
null
,
)
{
if
(!
adsConfigBean
.
isAdShow
)
{
if
(!
adsConfigBean
.
isAdShow
||
LimitUtils
.
isNativeAdLimit
(
null
)
)
{
nativeCallBack
?.
invoke
(
null
)
nativeView
.
visibility
=
View
.
GONE
isShowCallBack
?.
invoke
(
false
)
return
}
nativeView
.
visibility
=
View
.
VISIBLE
if
(
configBean
.
isInBlackList
)
{
EventUtils
.
event
(
"isInBlackList"
,
configBean
.
isInBlackList
.
toString
())
isShowCallBack
?.
invoke
(
false
)
return
}
val
showNative
=
{
if
(
adsConfigBean
.
adSwitch
)
{
adNativeMgr
.
show
(
AdmobEvent
(
"nativeAd"
,
"nativeAd"
),
nativeView
,
layout
,
nativeCallBack
)
adNativeMgr
.
show
(
AdmobEvent
(
"nativeAd"
,
"nativeAd"
),
nativeView
,
layout
,
nativeCallBack
,
isShowCallBack
)
}
else
{
maxNativeMgr
.
show
(
AdMaxEvent
(
"nativeAd"
,
"nativeAd"
),
nativeView
,
layout
,
nativeCallBack
)
}
...
...
app/src/main/java/com/easy/clean/business/ads/LimitUtils.kt
View file @
34708c65
...
...
@@ -55,6 +55,7 @@ object LimitUtils {
return
maxCount
>
-
1
&&
AppPreferences
.
getInstance
()
.
getInt
(
NUM_DISPLAY
,
0
)
>=
maxCount
}
/**
* 原生广告展示是否到达限制
*/
...
...
@@ -62,7 +63,7 @@ object LimitUtils {
get
()
{
val
maxCount
=
AdConfigBean
.
adsConfigBean
.
numNativeDisplayLimit
return
maxCount
>
-
1
&&
AppPreferences
.
getInstance
()
.
getInt
(
NUM_
DISPLAY
,
0
)
>=
maxCount
.
getInt
(
NUM_
NATIVE_SHOW
,
0
)
>=
maxCount
}
/**
...
...
@@ -103,13 +104,7 @@ object LimitUtils {
AppPreferences
.
getInstance
().
put
(
NUM_REQUEST
,
0
)
AppPreferences
.
getInstance
().
put
(
NUM_CLICK
,
0
)
}
if
(
isDisplayNativeLimited
){
val
value
=
"current${getAdEventMsg(adsType)} "
+
"show=${AppPreferences.getInstance().getInt(NUM_NATIVE_SHOW, 0)} "
+
"${getAdEventMsg(adsType).lowercase()}_"
+
"max_show=${AdConfigBean.adsConfigBean.numNativeDisplayLimit}"
adEvent
?.
adLimited
(
value
)
}
if
(
isDisplayLimited
)
{
val
value
=
"current${getAdEventMsg(adsType)} "
+
...
...
@@ -120,14 +115,18 @@ object LimitUtils {
}
if
(
isClickLimited
)
{
val
value
=
"current${getAdEventMsg(adsType)}Click=${AppPreferences.getInstance().getInt(NUM_CLICK, 0)} "
"current${getAdEventMsg(adsType)}Click=${
AppPreferences
.
getInstance
().
getInt
(
NUM_CLICK
,
0
)
}
"
"${getAdEventMsg(adsType).lowercase()}_max_click=${AdConfigBean.adsConfigBean.numClickLimit}"
adEvent
?.
adLimited
(
value
)
}
if
(
isRequestLimited
)
{
val
value
=
"current${getAdEventMsg(adsType)}Request=${AppPreferences.getInstance().getInt(NUM_REQUEST, 0)} "
+
val
value
=
"current${getAdEventMsg(adsType)}Request=${
AppPreferences
.
getInstance
().
getInt
(
NUM_REQUEST
,
0
)
}
" +
"${getAdEventMsg(adsType).lowercase()}_max_request=${AdConfigBean.adsConfigBean.numRequestLimit}"
adEvent
?.
adLimited
(
value
)
...
...
@@ -136,6 +135,18 @@ object LimitUtils {
return
!(
isDisplayLimited
||
isClickLimited
||
isRequestLimited
||
isDisplayNativeLimited
)
}
//是否限制原生广告
fun
isNativeAdLimit
(
adEvent
:
AdEvent
?):
Boolean
{
if
(
isDisplayNativeLimited
)
{
val
value
=
"current${getAdEventMsg(AdsType.NATIVE)} "
+
"show=${AppPreferences.getInstance().getInt(NUM_NATIVE_SHOW, 0)} "
+
"${getAdEventMsg(AdsType.NATIVE).lowercase()}_"
+
"max_show=${AdConfigBean.adsConfigBean.numNativeDisplayLimit}"
adEvent
?.
adLimited
(
value
)
}
return
isDisplayNativeLimited
}
private
fun
addNum
(
key
:
String
)
{
val
currentDate
=
System
.
currentTimeMillis
().
toFormatTime4
()
if
(
saveDate
!=
currentDate
)
{
...
...
@@ -159,6 +170,7 @@ object LimitUtils {
fun
addClickNum
()
{
addNum
(
NUM_CLICK
)
}
fun
addNumNative
()
{
addNum
(
NUM_NATIVE_SHOW
)
}
...
...
@@ -167,7 +179,8 @@ object LimitUtils {
* 开屏和插页广告的显示间隔限制
*/
fun
isIntervalLimited
(
adEvent
:
AdEvent
):
Boolean
{
val
flag
=
((
System
.
currentTimeMillis
()
-
openInterLastShowTime
)
/
1000
).
toInt
()
<
(
AdConfigBean
.
adsConfigBean
.
timeInterval
)
val
flag
=
((
System
.
currentTimeMillis
()
-
openInterLastShowTime
)
/
1000
).
toInt
()
<
(
AdConfigBean
.
adsConfigBean
.
timeInterval
)
if
(
flag
)
{
adEvent
.
adShowError
(
"ad in timeInterval"
)
}
...
...
app/src/main/java/com/easy/clean/business/ads/admob/AdNativeMgr.kt
View file @
34708c65
...
...
@@ -88,7 +88,8 @@ class AdNativeMgr {
admobEvent
:
AdmobEvent
,
parent
:
NativeParentView
,
layout
:
Int
,
nativeCallBack
:
((
Any
?)
->
Unit
)?
=
null
nativeCallBack
:
((
Any
?)
->
Unit
)?
=
null
,
isShowCallBack
:
((
Boolean
)->
Unit
)?
=
null
,
)
{
admobEvent
.
adPrepareShow
()
...
...
@@ -96,6 +97,11 @@ class AdNativeMgr {
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
NATIVE
,
admobEvent
))
{
Log
.
e
(
TAG
,
"!isAdShow"
)
cacheItems
.
clear
()
isShowCallBack
?.
invoke
(
false
)
return
}
if
(
LimitUtils
.
isNativeAdLimit
(
admobEvent
)){
isShowCallBack
?.
invoke
(
false
)
return
}
Log
.
e
(
TAG
,
"adNative can show"
)
...
...
@@ -106,6 +112,7 @@ class AdNativeMgr {
cacheItems
.
clear
()
}
isShowCallBack
?.
invoke
(
true
)
val
nativeAd
=
cacheItems
.
peek
()
var
showAction
:
(
ad
:
NativeAd
)
->
Unit
=
{
ad
->
parent
.
isAdShowed
=
true
...
...
app/src/main/java/com/easy/clean/ui/dialog/ExitDialog.kt
View file @
34708c65
...
...
@@ -4,6 +4,7 @@ import android.app.Activity
import
android.view.View
import
android.widget.LinearLayout
import
androidx.appcompat.app.AppCompatDialog
import
androidx.core.view.isVisible
import
com.easy.clean.R
import
com.easy.clean.bean.config.AdConfigBean
import
com.easy.clean.business.ads.AdsMgr
...
...
@@ -44,7 +45,9 @@ class ExitDialog(val activity: Activity) {
fun
show
()
{
dialog
.
show
()
if
(
AdConfigBean
.
adsConfigBean
.
isAdShow
)
{
AdsMgr
.
showNative
(
binding
.
flAd
,
R
.
layout
.
layout_admob_native_custom_r16
)
AdsMgr
.
showNative
(
binding
.
flAd
,
R
.
layout
.
layout_admob_native_custom_r16
,
isShowCallBack
=
{
f
->
binding
.
clAd
.
isVisible
=
f
})
}
else
{
binding
.
clAd
.
visibility
=
View
.
GONE
}
...
...
app/src/main/java/com/easy/clean/ui/dialog/FunctionBackDialog.kt
View file @
34708c65
...
...
@@ -5,6 +5,7 @@ import android.view.LayoutInflater
import
android.view.View
import
android.widget.LinearLayout
import
androidx.appcompat.app.AlertDialog
import
androidx.core.view.isVisible
import
com.easy.clean.R
import
com.easy.clean.bean.config.AdConfigBean
import
com.easy.clean.business.ads.AdsMgr
...
...
@@ -79,7 +80,9 @@ class FunctionBackDialog(
dialog
.
show
()
if
(
AdConfigBean
.
adsConfigBean
.
isAdShow
){
AdsMgr
.
showNative
(
binding
.
flAd
,
R
.
layout
.
layout_admob_native_custom_r16
)
AdsMgr
.
showNative
(
binding
.
flAd
,
R
.
layout
.
layout_admob_native_custom_r16
,
isShowCallBack
=
{
f
->
binding
.
clAd
.
isVisible
=
f
})
}
else
{
binding
.
clAd
.
visibility
=
View
.
GONE
}
...
...
app/src/main/res/layout/dialog_function_back.xml
View file @
34708c65
...
...
@@ -9,8 +9,8 @@
android:id=
"@+id/cl_exit"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/white_background_24"
android:layout_marginHorizontal=
"20dp"
android:background=
"@drawable/white_background_24"
android:paddingBottom=
"30dp"
app:layout_constraintTop_toTopOf=
"parent"
>
...
...
@@ -97,8 +97,8 @@
android:id=
"@+id/cl_ad"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:layout_marginHorizontal=
"20dp"
android:layout_marginTop=
"8dp"
android:background=
"@drawable/bg_ffffff_24"
android:paddingHorizontal=
"11dp"
android:paddingVertical=
"12dp"
...
...
@@ -117,4 +117,5 @@
</com.easy.clean.business.ads.NativeParentView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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