Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
Scan QR Code Barcode Reader
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
Scan QR Code Barcode Reader
Commits
e29f36db
Commit
e29f36db
authored
Dec 31, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
be80a446
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
4 deletions
+40
-4
NativeParentView.kt
app/src/main/java/com/base/scanqr/ads/NativeParentView.kt
+27
-2
AdNativeMgr.kt
app/src/main/java/com/base/scanqr/ads/admob/AdNativeMgr.kt
+1
-0
HistoryAdapter.kt
app/src/main/java/com/base/scanqr/ui/main/HistoryAdapter.kt
+1
-0
CollectionEx.kt
app/src/main/java/com/base/scanqr/utils/CollectionEx.kt
+3
-1
item_ad.xml
app/src/main/res/layout/item_ad.xml
+2
-1
attrs.xml
app/src/main/res/values/attrs.xml
+6
-0
No files found.
app/src/main/java/com/base/scanqr/ads/NativeParentView.kt
View file @
e29f36db
...
...
@@ -15,16 +15,38 @@ import com.applovin.mediation.nativeAds.MaxNativeAdLoader
import
com.applovin.mediation.nativeAds.MaxNativeAdView
import
com.applovin.mediation.nativeAds.MaxNativeAdViewBinder
import
com.base.scanqr.R
import
com.base.scanqr.utils.LogEx
import
com.google.android.gms.ads.nativead.NativeAd
import
com.google.android.gms.ads.nativead.NativeAdView
@SuppressLint
(
"ViewConstructor"
)
class
NativeParentView
(
context
:
Context
,
attrs
:
AttributeSet
?
=
null
)
:
FrameLayout
(
context
,
attrs
)
{
private
val
TAG
=
"NativeParentView"
private
var
removeAll
=
true
init
{
// 获取XML属性
val
a
=
context
.
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
NativeParentView
,
0
,
0
)
// 从XML中读取属性值
// 例如,如果你的XML中有自定义属性 `app:customAttribute="value"`
removeAll
=
a
.
getBoolean
(
R
.
styleable
.
NativeParentView_removeAll
,
true
)
// 回收TypedArray
a
.
recycle
()
}
fun
setNativeAd
(
nativeAd
:
NativeAd
,
@LayoutRes
resource
:
Int
?
=
null
@LayoutRes
resource
:
Int
?
=
null
,
)
{
val
layout
=
resource
?:
R
.
layout
.
layout_admob_native_custom
val
adView
=
...
...
@@ -58,7 +80,10 @@ class NativeParentView(context: Context, attrs: AttributeSet? = null) :
}
adView
.
setNativeAd
(
nativeAd
)
setBackgroundResource
(
0
)
removeAllViews
()
LogEx
.
logDebug
(
TAG
,
"removeAll=$removeAll"
)
if
(
removeAll
)
{
removeAllViews
()
}
addView
(
adView
)
}
...
...
app/src/main/java/com/base/scanqr/ads/admob/AdNativeMgr.kt
View file @
e29f36db
package
com.base.scanqr.ads.admob
import
com.base.scanqr.GlobalConfig
import
com.base.scanqr.ads.AdsType
import
com.base.scanqr.ads.LimitUtils
...
...
app/src/main/java/com/base/scanqr/ui/main/HistoryAdapter.kt
View file @
e29f36db
...
...
@@ -47,6 +47,7 @@ class HistoryAdapter : BaseQuickAdapter<ScanBean, CommonViewHolder>() {
if
(
ad
is
NativeAd
)
{
LogEx
.
logDebug
(
TAG
,
"ad is NativeAd"
)
item
.
ad
=
ad
binding
.
shimmerLayout
.
visibility
=
View
.
INVISIBLE
}
})
}
else
{
...
...
app/src/main/java/com/base/scanqr/utils/CollectionEx.kt
View file @
e29f36db
...
...
@@ -7,7 +7,9 @@ object CollectionEx {
val
newList
=
mutableListOf
<
T
>()
chunkedList
.
forEach
{
newList
.
addAll
(
it
)
newList
.
add
(
newElement
())
if
(
it
.
size
==
beanStep
)
{
newList
.
add
(
newElement
())
}
}
return
newList
}
...
...
app/src/main/res/layout/item_ad.xml
View file @
e29f36db
...
...
@@ -8,7 +8,8 @@
android:layout_marginHorizontal=
"16dp"
android:layout_marginVertical=
"8dp"
android:background=
"@drawable/bg_ecf6ff_20"
android:minHeight=
"133dp"
>
android:minHeight=
"133dp"
app:removeAll=
"false"
>
<io.supercharge.shimmerlayout.ShimmerLayout
android:id=
"@+id/shimmerLayout"
...
...
app/src/main/res/values/attrs.xml
0 → 100644
View file @
e29f36db
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable
name=
"NativeParentView"
>
<attr
name=
"removeAll"
format=
"boolean"
/>
</declare-styleable>
</resources>
\ 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