Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
86c21de6
Commit
86c21de6
authored
Jun 25, 2019
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the AdView when scrolling
parent
3765b97c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
24 deletions
+35
-24
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
.../src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+35
-24
No files found.
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
View file @
86c21de6
...
@@ -116,6 +116,39 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
...
@@ -116,6 +116,39 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
TooltipCompat
.
setTooltipText
(
share
,
share
.
contentDescription
)
TooltipCompat
.
setTooltipText
(
share
,
share
.
contentDescription
)
}
}
fun
attach
()
{
if
(!
isAdLoaded
&&
item
.
host
==
"198.199.101.152"
)
{
if
(
this
.
adView
==
null
)
{
val
params
=
LinearLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
AdSize
.
SMART_BANNER
.
getHeightInPixels
(
context
))
params
.
gravity
=
Gravity
.
CENTER_HORIZONTAL
var
adView
=
AdView
(
context
)
adView
.
layoutParams
=
params
adView
.
adUnitId
=
"ca-app-pub-9097031975646651/7760346322"
adView
.
adSize
=
AdSize
.
SMART_BANNER
itemView
.
findViewById
<
LinearLayout
>(
R
.
id
.
content
).
addView
(
adView
)
// Load Ad
val
adBuilder
=
AdRequest
.
Builder
()
adBuilder
.
addTestDevice
(
"B08FC1764A7B250E91EA9D0D5EBEB208"
)
adBuilder
.
addTestDevice
(
"7509D18EB8AF82F915874FEF53877A64"
)
adView
.
loadAd
(
adBuilder
.
build
())
this
.
adView
=
adView
}
else
this
.
adView
?.
visibility
=
View
.
VISIBLE
isAdLoaded
=
true
}
else
this
.
adView
?.
visibility
=
View
.
GONE
}
fun
detach
()
{
if
(
this
.
adView
?.
visibility
==
View
.
VISIBLE
)
{
isAdLoaded
=
false
this
.
adView
?.
visibility
==
View
.
GONE
}
}
fun
bind
(
item
:
Profile
)
{
fun
bind
(
item
:
Profile
)
{
this
.
item
=
item
this
.
item
=
item
val
editable
=
isProfileEditable
(
item
.
id
)
val
editable
=
isProfileEditable
(
item
.
id
)
...
@@ -144,30 +177,6 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
...
@@ -144,30 +177,6 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
itemView
.
isSelected
=
false
itemView
.
isSelected
=
false
if
(
selectedItem
===
this
)
selectedItem
=
null
if
(
selectedItem
===
this
)
selectedItem
=
null
}
}
if
(!
isAdLoaded
&&
item
.
host
==
"198.199.101.152"
)
{
if
(
this
.
adView
==
null
)
{
val
params
=
LinearLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
AdSize
.
SMART_BANNER
.
getHeightInPixels
(
context
))
params
.
gravity
=
Gravity
.
CENTER_HORIZONTAL
var
adView
=
AdView
(
context
)
adView
.
layoutParams
=
params
adView
.
adUnitId
=
"ca-app-pub-9097031975646651/7760346322"
adView
.
adSize
=
AdSize
.
SMART_BANNER
itemView
.
findViewById
<
LinearLayout
>(
R
.
id
.
content
).
addView
(
adView
)
// Load Ad
val
adBuilder
=
AdRequest
.
Builder
()
adBuilder
.
addTestDevice
(
"B08FC1764A7B250E91EA9D0D5EBEB208"
)
adBuilder
.
addTestDevice
(
"7509D18EB8AF82F915874FEF53877A64"
)
adView
.
loadAd
(
adBuilder
.
build
())
this
.
adView
=
adView
}
else
this
.
adView
?.
visibility
=
View
.
VISIBLE
isAdLoaded
=
true
}
else
this
.
adView
?.
visibility
=
View
.
GONE
}
}
override
fun
onClick
(
v
:
View
?)
{
override
fun
onClick
(
v
:
View
?)
{
...
@@ -203,6 +212,8 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
...
@@ -203,6 +212,8 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
setHasStableIds
(
true
)
// see: http://stackoverflow.com/a/32488059/2245107
setHasStableIds
(
true
)
// see: http://stackoverflow.com/a/32488059/2245107
}
}
override
fun
onViewAttachedToWindow
(
holder
:
ProfileViewHolder
)
=
holder
.
attach
()
override
fun
onViewDetachedFromWindow
(
holder
:
ProfileViewHolder
)
=
holder
.
detach
()
override
fun
onBindViewHolder
(
holder
:
ProfileViewHolder
,
position
:
Int
)
=
holder
.
bind
(
profiles
[
position
])
override
fun
onBindViewHolder
(
holder
:
ProfileViewHolder
,
position
:
Int
)
=
holder
.
bind
(
profiles
[
position
])
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ProfileViewHolder
=
ProfileViewHolder
(
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ProfileViewHolder
=
ProfileViewHolder
(
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
layout_profile
,
parent
,
false
))
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
layout_profile
,
parent
,
false
))
...
...
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