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
aa1e052b
Commit
aa1e052b
authored
Dec 21, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add native adview
parent
7564ba51
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
0 deletions
+50
-0
src/main/res/layout/layout_profiles_item.xml
src/main/res/layout/layout_profiles_item.xml
+13
-0
src/main/scala/com/github/shadowsocks/GlobalSettingsFragment.scala
...scala/com/github/shadowsocks/GlobalSettingsFragment.scala
+1
-0
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
+36
-0
No files found.
src/main/res/layout/layout_profiles_item.xml
View file @
aa1e052b
...
...
@@ -2,6 +2,7 @@
<!-- Based on: https://github.com/android/platform_frameworks_base/blob/505e3ab/core/res/res/layout/simple_list_item_2.xml -->
<android.support.v7.widget.CardView
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:ads=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/background_selectable"
...
...
@@ -15,6 +16,7 @@
android:padding=
"8dp"
android:focusable=
"true"
android:nextFocusRight=
"@+id/edit"
android:id=
"@+id/content"
android:background=
"?android:attr/selectableItemBackground"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
@@ -67,5 +69,16 @@
android:textAppearance=
"?android:attr/textAppearanceSmall"
android:textColor=
"?android:attr/textColorSecondary"
/>
</LinearLayout>
<com.google.android.gms.ads.NativeExpressAdView
android:id=
"@+id/adView"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"8dp"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:layout_centerHorizontal=
"true"
android:layout_alignParentBottom=
"true"
android:visibility=
"gone"
ads:adSize=
"320x132"
ads:adUnitId=
"ca-app-pub-9097031975646651/5224027521"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
src/main/scala/com/github/shadowsocks/GlobalSettingsFragment.scala
View file @
aa1e052b
...
...
@@ -4,6 +4,7 @@ import android.os.Bundle
import
android.view.
{
LayoutInflater
,
View
,
ViewGroup
}
class
GlobalSettingsFragment
extends
ToolbarFragment
{
override
def
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
,
savedInstanceState
:
Bundle
)
:
View
=
inflater
.
inflate
(
R
.
layout
.
layout_global_settings
,
container
,
false
)
...
...
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
View file @
aa1e052b
...
...
@@ -31,11 +31,16 @@ import android.support.v7.widget.helper.ItemTouchHelper
import
android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback
import
android.view._
import
android.widget.
{
TextView
,
Toast
}
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.utils._
import
com.github.shadowsocks.widget.UndoSnackbarManager
import
com.google.android.gms.ads.
{
AdRequest
,
AdSize
,
NativeExpressAdView
}
import
java.util.GregorianCalendar
import
scala.util.Random
import
scala.collection.mutable.ArrayBuffer
final
class
ProfilesFragment
extends
ToolbarFragment
with
OnMenuItemClickListener
{
...
...
@@ -43,12 +48,16 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
with
View
.
OnClickListener
{
var
item
:
Profile
=
_
private
val
text1
=
itemView
.
findViewById
(
R
.
id
.
title
).
asInstanceOf
[
TextView
]
private
val
text2
=
itemView
.
findViewById
(
R
.
id
.
address
).
asInstanceOf
[
TextView
]
private
val
text3
=
itemView
.
findViewById
(
R
.
id
.
traffic
).
asInstanceOf
[
TextView
]
private
val
indicator
=
itemView
.
findViewById
(
R
.
id
.
indicator
).
asInstanceOf
[
ViewGroup
]
itemView
.
setOnClickListener
(
this
)
private
var
adView
:
NativeExpressAdView
=
_
{
val
edit
=
itemView
.
findViewById
(
R
.
id
.
edit
)
edit
.
setOnClickListener
(
_
=>
startActivity
(
new
Intent
(
getActivity
,
classOf
[
ProfileConfigActivity
])
...
...
@@ -79,6 +88,7 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
def
bind
(
item
:
Profile
)
{
this
.
item
=
item
updateText
()
if
(
item
.
id
==
app
.
profileId
)
{
// text1.setTypeface(null, Typeface.BOLD)
indicator
.
setBackgroundResource
(
R
.
drawable
.
background_selected
)
...
...
@@ -88,6 +98,31 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
indicator
.
setBackgroundResource
(
R
.
drawable
.
background_selectable
)
if
(
selectedItem
eq
this
)
selectedItem
=
null
}
if
(
item
.
host
==
"198.199.101.152"
)
{
if
(
adView
==
null
)
{
adView
=
itemView
.
findViewById
(
R
.
id
.
adView
).
asInstanceOf
[
NativeExpressAdView
]
// Demographics
val
random
=
new
Random
()
val
adBuilder
=
new
AdRequest
.
Builder
()
adBuilder
.
setGender
(
AdRequest
.
GENDER_MALE
)
val
year
=
1975
+
random
.
nextInt
(
40
)
val
month
=
1
+
random
.
nextInt
(
12
)
val
day
=
random
.
nextInt
(
28
)
adBuilder
.
setBirthday
(
new
GregorianCalendar
(
year
,
month
,
day
).
getTime
)
adView
.
setVisibility
(
View
.
VISIBLE
)
// Load Ad
adView
.
loadAd
(
adBuilder
.
build
())
}
else
{
adView
.
setVisibility
(
View
.
VISIBLE
)
}
}
else
if
(
adView
!=
null
)
{
adView
.
setVisibility
(
View
.
GONE
)
}
}
def
onClick
(
v
:
View
)
{
...
...
@@ -216,6 +251,7 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
val
filter
=
new
IntentFilter
(
Action
.
PROFILE_CHANGED
)
filter
.
addAction
(
Action
.
PROFILE_REMOVED
)
LocalBroadcastManager
.
getInstance
(
getActivity
).
registerReceiver
(
profilesListener
,
filter
)
}
override
def
onTrafficUpdated
(
txRate
:
Long
,
rxRate
:
Long
,
txTotal
:
Long
,
rxTotal
:
Long
)
:
Unit
=
...
...
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