Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
B
Browser White
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
Browser White
Commits
a8dabff6
Commit
a8dabff6
authored
Sep 04, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
5eba597d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
24 deletions
+26
-24
AdmobNativeUtils.kt
.../java/com/base/browserwhite/ads/admob/AdmobNativeUtils.kt
+17
-23
NewsBean.kt
app/src/main/java/com/base/browserwhite/bean/NewsBean.kt
+8
-0
NewsAdapter.kt
...ava/com/base/browserwhite/ui/activity/news/NewsAdapter.kt
+1
-1
No files found.
app/src/main/java/com/base/browserwhite/ads/admob/AdmobNativeUtils.kt
View file @
a8dabff6
...
@@ -138,7 +138,7 @@ object AdmobNativeUtils {
...
@@ -138,7 +138,7 @@ object AdmobNativeUtils {
}
}
}
}
var
readyNative
=
arrayListOf
<
NativeAd
>()
private
var
readyNative
=
arrayListOf
<
NewsBean
>()
fun
loadNativeList
(
count
:
Int
)
{
fun
loadNativeList
(
count
:
Int
)
{
readyNative
.
clear
()
readyNative
.
clear
()
repeat
(
count
)
{
repeat
(
count
)
{
...
@@ -146,7 +146,12 @@ object AdmobNativeUtils {
...
@@ -146,7 +146,12 @@ object AdmobNativeUtils {
MyApplication
.
context
,
MyApplication
.
context
,
if
(
BuildConfig
.
DEBUG
)
ConfigHelper
.
nativeAdmobIdTest
else
ConfigHelper
.
nativeAdmobId
if
(
BuildConfig
.
DEBUG
)
ConfigHelper
.
nativeAdmobIdTest
else
ConfigHelper
.
nativeAdmobId
).
forNativeAd
{
).
forNativeAd
{
readyNative
.
add
(
it
)
val
newsBean
=
NewsBean
().
apply
{
uiType
=
1
nativeAd
=
it
nativeAdLoadTime
=
System
.
currentTimeMillis
()
}
readyNative
.
add
(
newsBean
)
}.
withAdListener
(
object
:
AdListener
()
{
}.
withAdListener
(
object
:
AdListener
()
{
override
fun
onAdLoaded
()
{
override
fun
onAdLoaded
()
{
super
.
onAdLoaded
()
super
.
onAdLoaded
()
...
@@ -154,6 +159,7 @@ object AdmobNativeUtils {
...
@@ -154,6 +159,7 @@ object AdmobNativeUtils {
}
}
override
fun
onAdClicked
()
{
override
fun
onAdClicked
()
{
LogEx
.
logDebug
(
TAG
,
"loadNativeList onAdClicked"
)
}
}
override
fun
onAdFailedToLoad
(
p0
:
LoadAdError
)
{
override
fun
onAdFailedToLoad
(
p0
:
LoadAdError
)
{
...
@@ -170,42 +176,30 @@ object AdmobNativeUtils {
...
@@ -170,42 +176,30 @@ object AdmobNativeUtils {
list
.
add
(
newsBean
)
list
.
add
(
newsBean
)
if
(
index
==
0
)
{
if
(
index
==
0
)
{
runCatching
{
runCatching
{
val
ad
=
AdmobNativeUtils
.
readyNative
[
0
]
val
ad
=
readyNative
[
0
]
list
.
add
(
NewsBean
().
apply
{
list
.
add
(
ad
)
uiType
=
1
nativeAd
=
ad
})
}
}
}
}
if
(
index
==
4
)
{
if
(
index
==
4
)
{
runCatching
{
runCatching
{
val
ad
=
AdmobNativeUtils
.
readyNative
[
1
]
val
ad
=
readyNative
[
1
]
list
.
add
(
NewsBean
().
apply
{
list
.
add
(
ad
)
uiType
=
1
nativeAd
=
ad
})
}
}
}
}
if
(
index
==
8
)
{
if
(
index
==
8
)
{
runCatching
{
runCatching
{
val
ad
=
AdmobNativeUtils
.
readyNative
[
2
]
val
ad
=
readyNative
[
2
]
list
.
add
(
NewsBean
().
apply
{
list
.
add
(
ad
)
uiType
=
1
nativeAd
=
ad
})
}
}
}
}
if
(
index
==
12
)
{
if
(
index
==
12
)
{
runCatching
{
runCatching
{
val
ad
=
AdmobNativeUtils
.
readyNative
[
3
]
val
ad
=
readyNative
[
3
]
list
.
add
(
NewsBean
().
apply
{
list
.
add
(
ad
)
uiType
=
1
nativeAd
=
ad
})
}
}
}
}
}
}
AdmobNativeUtils
.
loadNativeList
(
4
)
loadNativeList
(
4
)
return
list
return
list
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/browserwhite/bean/NewsBean.kt
View file @
a8dabff6
package
com.base.browserwhite.bean
package
com.base.browserwhite.bean
import
com.base.browserwhite.utils.LogEx
import
com.google.android.gms.ads.nativead.NativeAd
import
com.google.android.gms.ads.nativead.NativeAd
import
java.util.concurrent.TimeUnit
class
NewsBean
(
class
NewsBean
(
val
newsId
:
Long
=
0
,
val
newsId
:
Long
=
0
,
...
@@ -15,7 +17,13 @@ class NewsBean(
...
@@ -15,7 +17,13 @@ class NewsBean(
)
{
)
{
var
uiType
:
Int
=
0
//0新闻 1广告
var
uiType
:
Int
=
0
//0新闻 1广告
var
nativeAd
:
NativeAd
?
=
null
var
nativeAd
:
NativeAd
?
=
null
var
nativeAdLoadTime
:
Long
=
0
fun
isNativeAdTimeout
():
Boolean
{
val
outTime
=
System
.
currentTimeMillis
()
-
nativeAdLoadTime
LogEx
.
logDebug
(
"NewsBean"
,
"outTime=$outTime"
)
return
outTime
>
30
*
60
*
1000L
}
}
}
// 栏目类别 0:最新 , 101 :政治, 301:体育 ,娱乐:501 ,
// 栏目类别 0:最新 , 101 :政治, 301:体育 ,娱乐:501 ,
...
...
app/src/main/java/com/base/browserwhite/ui/activity/news/NewsAdapter.kt
View file @
a8dabff6
...
@@ -95,7 +95,7 @@ class NewsAdapter(
...
@@ -95,7 +95,7 @@ class NewsAdapter(
1
->
{
1
->
{
val
binding
=
ItemNewsAdBinding
.
bind
(
holder
.
itemView
)
val
binding
=
ItemNewsAdBinding
.
bind
(
holder
.
itemView
)
if
(
item
.
nativeAd
!=
null
)
{
if
(
item
.
nativeAd
!=
null
&&
!
item
.
isNativeAdTimeout
()
)
{
AdmobNativeUtils
.
showReadyNativeAd
(
null
,
item
.
nativeAd
,
binding
.
flAd
,
R
.
layout
.
layout_admob_native_news
)
AdmobNativeUtils
.
showReadyNativeAd
(
null
,
item
.
nativeAd
,
binding
.
flAd
,
R
.
layout
.
layout_admob_native_news
)
}
}
}
}
...
...
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