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
d0c4384c
Commit
d0c4384c
authored
Dec 17, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid attach/detach service in the fragment
parent
02513418
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
8 deletions
+17
-8
build.sbt
build.sbt
+3
-0
src/main/scala/com/github/shadowsocks/MainActivity.scala
src/main/scala/com/github/shadowsocks/MainActivity.scala
+10
-1
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
+4
-7
No files found.
build.sbt
View file @
d0c4384c
...
@@ -43,6 +43,9 @@ libraryDependencies ++=
...
@@ -43,6 +43,9 @@ libraryDependencies ++=
"com.google.android.gms"
%
"play-services-gcm"
%
"10.0.1"
::
"com.google.android.gms"
%
"play-services-gcm"
%
"10.0.1"
::
"com.j256.ormlite"
%
"ormlite-android"
%
"5.0"
::
"com.j256.ormlite"
%
"ormlite-android"
%
"5.0"
::
"com.mikepenz"
%
"materialdrawer"
%
"5.8.1"
::
"com.mikepenz"
%
"materialdrawer"
%
"5.8.1"
::
"com.mikepenz"
%
"materialize"
%
"1.0.0"
::
"com.mikepenz"
%
"iconics-core"
%
"2.8.0"
::
"com.mikepenz"
%
"fastadapter"
%
"2.1.0"
::
"com.twofortyfouram"
%
"android-plugin-api-for-locale"
%
"1.0.2"
::
"com.twofortyfouram"
%
"android-plugin-api-for-locale"
%
"1.0.2"
::
"dnsjava"
%
"dnsjava"
%
"2.1.7"
::
"dnsjava"
%
"dnsjava"
%
"2.1.7"
::
"eu.chainfire"
%
"libsuperuser"
%
"1.0.0.201608240809"
::
"eu.chainfire"
%
"libsuperuser"
%
"1.0.0.201608240809"
::
...
...
src/main/scala/com/github/shadowsocks/MainActivity.scala
View file @
d0c4384c
...
@@ -51,8 +51,12 @@ import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
...
@@ -51,8 +51,12 @@ import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
import
com.mikepenz.materialdrawer.model.
{
PrimaryDrawerItem
,
SecondaryDrawerItem
}
import
com.mikepenz.materialdrawer.model.
{
PrimaryDrawerItem
,
SecondaryDrawerItem
}
import
com.mikepenz.materialdrawer.
{
Drawer
,
DrawerBuilder
}
import
com.mikepenz.materialdrawer.
{
Drawer
,
DrawerBuilder
}
trait
TrafficCallback
{
def
update
(
txRate
:
Long
,
rxRate
:
Long
,
txTotal
:
Long
,
rxTotal
:
Long
)
}
object
MainActivity
{
object
MainActivity
{
private
final
val
TAG
=
"MainActivity"
private
final
val
TAG
=
"
Shadowsocks
MainActivity"
private
final
val
REQUEST_CONNECT
=
1
private
final
val
REQUEST_CONNECT
=
1
private
final
val
DRAWER_PROFILES
=
0L
private
final
val
DRAWER_PROFILES
=
0L
...
@@ -72,6 +76,9 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -72,6 +76,9 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
var
state
=
State
.
STOPPED
var
state
=
State
.
STOPPED
var
currentProfile
=
new
Profile
var
currentProfile
=
new
Profile
var
drawer
:
Drawer
=
_
var
drawer
:
Drawer
=
_
@volatile
var
trafficCallback
:
TrafficCallback
=
_
private
lazy
val
profilesFragment
=
new
ProfilesFragment
()
private
lazy
val
profilesFragment
=
new
ProfilesFragment
()
private
lazy
val
globalSettingsFragment
=
new
GlobalSettingsFragment
()
private
lazy
val
globalSettingsFragment
=
new
GlobalSettingsFragment
()
...
@@ -133,6 +140,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -133,6 +140,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
rxText
.
setText
(
TrafficMonitor
.
formatTraffic
(
rxTotal
))
rxText
.
setText
(
TrafficMonitor
.
formatTraffic
(
rxTotal
))
txRateText
.
setText
(
TrafficMonitor
.
formatTraffic
(
txRate
)
+
"/s"
)
txRateText
.
setText
(
TrafficMonitor
.
formatTraffic
(
txRate
)
+
"/s"
)
rxRateText
.
setText
(
TrafficMonitor
.
formatTraffic
(
rxRate
)
+
"/s"
)
rxRateText
.
setText
(
TrafficMonitor
.
formatTraffic
(
rxRate
)
+
"/s"
)
if
(
trafficCallback
!=
null
)
trafficCallback
.
update
(
txRate
,
rxRate
,
txTotal
,
rxTotal
)
}
}
def
attachServiceCallback
()
:
Unit
=
attachService
(
callback
)
def
attachServiceCallback
()
:
Unit
=
attachService
(
callback
)
...
@@ -372,6 +380,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -372,6 +380,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
private
def
updateState
()
{
private
def
updateState
()
{
if
(
bgService
!=
null
)
{
if
(
bgService
!=
null
)
{
Log
.
d
(
TAG
,
"bgService "
+
bgService
.
getState
)
bgService
.
getState
match
{
bgService
.
getState
match
{
case
State
.
CONNECTING
=>
case
State
.
CONNECTING
=>
fab
.
setBackgroundTintList
(
greyTint
)
fab
.
setBackgroundTintList
(
greyTint
)
...
...
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
View file @
d0c4384c
...
@@ -216,25 +216,22 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
...
@@ -216,25 +216,22 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
override
def
onAttach
(
activity
:
Activity
)
{
override
def
onAttach
(
activity
:
Activity
)
{
super
.
onAttach
(
activity
)
super
.
onAttach
(
activity
)
activity
.
asInstanceOf
[
ServiceBoundContext
].
attachService
(
new
IShadowsocksServiceCallback
.
Stub
{
activity
.
asInstanceOf
[
MainActivity
].
trafficCallback
=
new
TrafficCallback
{
def
stateChanged
(
state
:
Int
,
profileName
:
String
,
msg
:
String
)
:
Unit
=
()
// ignore
def
update
(
txRate
:
Long
,
rxRate
:
Long
,
txTotal
:
Long
,
rxTotal
:
Long
)
:
Unit
=
def
trafficUpdated
(
txRate
:
Long
,
rxRate
:
Long
,
txTotal
:
Long
,
rxTotal
:
Long
)
:
Unit
=
if
(
selectedItem
!=
null
)
selectedItem
.
updateText
(
txTotal
,
rxTotal
)
if
(
selectedItem
!=
null
)
selectedItem
.
updateText
(
txTotal
,
rxTotal
)
}
)
}
}
}
override
def
onStart
()
{
override
def
onStart
()
{
super
.
onStart
()
super
.
onStart
()
getActivity
.
asInstanceOf
[
ServiceBoundContext
].
registerCallback
()
}
}
override
def
onStop
()
{
override
def
onStop
()
{
super
.
onStop
()
super
.
onStop
()
getActivity
.
asInstanceOf
[
ServiceBoundContext
].
unregisterCallback
()
}
}
override
def
onDetach
()
{
override
def
onDetach
()
{
getActivity
.
asInstanceOf
[
ServiceBoundContext
].
detachService
()
getActivity
.
asInstanceOf
[
MainActivity
].
trafficCallback
=
null
undoManager
.
flush
()
undoManager
.
flush
()
super
.
onDetach
()
super
.
onDetach
()
}
}
...
...
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