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
3c7d045c
Commit
3c7d045c
authored
Apr 20, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix deprecation
parent
0a1536a7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
9 deletions
+43
-9
mobile/src/main/java/com/github/shadowsocks/AdsManager.kt
mobile/src/main/java/com/github/shadowsocks/AdsManager.kt
+41
-0
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
.../src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+2
-9
No files found.
mobile/src/main/java/com/github/shadowsocks/AdsManager.kt
0 → 100644
View file @
3c7d045c
/*******************************************************************************
* *
* Copyright (C) 2020 by Max Lv <max.c.lv@gmail.com> *
* Copyright (C) 2020 by Mygod Studio <contact-shadowsocks-android@mygod.be> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
package
com.github.shadowsocks
import
android.content.Context
import
com.google.android.gms.ads.AdLoader
import
com.google.android.gms.ads.AdRequest
import
com.google.android.gms.ads.MobileAds
import
com.google.android.gms.ads.RequestConfiguration
internal
object
AdsManager
{
init
{
MobileAds
.
setRequestConfiguration
(
RequestConfiguration
.
Builder
().
apply
{
setTestDeviceIds
(
listOf
(
"B08FC1764A7B250E91EA9D0D5EBEB208"
,
"7509D18EB8AF82F915874FEF53877A64"
,
"F58907F28184A828DD0DB6F8E38189C6"
,
"FE983F496D7C5C1878AA163D9420CA97"
))
}.
build
())
}
fun
load
(
context
:
Context
?,
setup
:
AdLoader
.
Builder
.()
->
Unit
)
=
AdLoader
.
Builder
(
context
,
"ca-app-pub-3283768469187309/8632513739"
).
apply
(
setup
).
build
()
.
loadAd
(
AdRequest
.
Builder
().
build
())
}
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
View file @
3c7d045c
...
@@ -59,8 +59,6 @@ import com.github.shadowsocks.utils.readableMessage
...
@@ -59,8 +59,6 @@ import com.github.shadowsocks.utils.readableMessage
import
com.github.shadowsocks.widget.ListHolderListener
import
com.github.shadowsocks.widget.ListHolderListener
import
com.github.shadowsocks.widget.MainListListener
import
com.github.shadowsocks.widget.MainListListener
import
com.github.shadowsocks.widget.UndoSnackbarManager
import
com.github.shadowsocks.widget.UndoSnackbarManager
import
com.google.android.gms.ads.AdLoader
import
com.google.android.gms.ads.AdRequest
import
com.google.android.gms.ads.VideoOptions
import
com.google.android.gms.ads.VideoOptions
import
com.google.android.gms.ads.formats.NativeAdOptions
import
com.google.android.gms.ads.formats.NativeAdOptions
import
com.google.android.gms.ads.formats.UnifiedNativeAd
import
com.google.android.gms.ads.formats.UnifiedNativeAd
...
@@ -249,7 +247,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
...
@@ -249,7 +247,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
if
(
adHost
!=
null
||
!
item
.
isSponsored
)
return
if
(
adHost
!=
null
||
!
item
.
isSponsored
)
return
if
(
nativeAdView
==
null
)
{
if
(
nativeAdView
==
null
)
{
nativeAdView
=
layoutInflater
.
inflate
(
R
.
layout
.
ad_unified
,
adContainer
,
false
)
as
UnifiedNativeAdView
nativeAdView
=
layoutInflater
.
inflate
(
R
.
layout
.
ad_unified
,
adContainer
,
false
)
as
UnifiedNativeAdView
Ad
Loader
.
Builder
(
context
,
"ca-app-pub-3283768469187309/8632513739"
).
apply
{
Ad
sManager
.
load
(
context
)
{
forUnifiedNativeAd
{
unifiedNativeAd
->
forUnifiedNativeAd
{
unifiedNativeAd
->
// You must call destroy on old ads when you are done with them,
// You must call destroy on old ads when you are done with them,
// otherwise you will have a memory leak.
// otherwise you will have a memory leak.
...
@@ -262,12 +260,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
...
@@ -262,12 +260,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
setStartMuted
(
true
)
setStartMuted
(
true
)
}.
build
())
}.
build
())
}.
build
())
}.
build
())
}.
build
().
loadAd
(
AdRequest
.
Builder
().
apply
{
}
addTestDevice
(
"B08FC1764A7B250E91EA9D0D5EBEB208"
)
addTestDevice
(
"7509D18EB8AF82F915874FEF53877A64"
)
addTestDevice
(
"F58907F28184A828DD0DB6F8E38189C6"
)
addTestDevice
(
"FE983F496D7C5C1878AA163D9420CA97"
)
}.
build
())
}
else
if
(
nativeAd
!=
null
)
populateUnifiedNativeAdView
(
nativeAd
!!
,
nativeAdView
!!
)
}
else
if
(
nativeAd
!=
null
)
populateUnifiedNativeAdView
(
nativeAd
!!
,
nativeAdView
!!
)
}
}
...
...
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