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
dfe469e1
Commit
dfe469e1
authored
Dec 28, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent bandwidth and border flashing in ProfilesFragment
parent
f96f58f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
27 deletions
+27
-27
src/main/scala/com/github/shadowsocks/BaseService.scala
src/main/scala/com/github/shadowsocks/BaseService.scala
+5
-5
src/main/scala/com/github/shadowsocks/MainActivity.scala
src/main/scala/com/github/shadowsocks/MainActivity.scala
+1
-1
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
+21
-21
No files found.
src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
dfe469e1
...
...
@@ -93,7 +93,7 @@ trait BaseService extends Service {
if
(
timer
==
null
)
{
timer
=
new
Timer
(
true
)
timer
.
schedule
(
new
TimerTask
{
def
run
()
:
Unit
=
if
(
TrafficMonitor
.
updateRate
())
updateTrafficRate
()
def
run
()
:
Unit
=
if
(
state
==
State
.
CONNECTED
&&
TrafficMonitor
.
updateRate
())
updateTrafficRate
()
},
1000
,
1000
)
}
TrafficMonitor
.
updateRate
()
...
...
@@ -288,8 +288,8 @@ trait BaseService extends Service {
protected
def
changeState
(
s
:
Int
,
msg
:
String
=
null
)
{
val
handler
=
new
Handler
(
getMainLooper
)
handler
.
post
(()
=>
if
(
state
!=
s
||
msg
!=
null
)
{
if
(
callbacks
.
getRegisteredCallbackCount
>
0
)
{
if
(
state
!=
s
||
msg
!=
null
)
{
if
(
callbacks
.
getRegisteredCallbackCount
>
0
)
handler
.
post
(()
=>
{
val
n
=
callbacks
.
beginBroadcast
()
for
(
i
<-
0
until
n
)
{
try
{
...
...
@@ -299,9 +299,9 @@ trait BaseService extends Service {
}
}
callbacks
.
finishBroadcast
()
}
}
)
state
=
s
}
)
}
}
def
getBlackList
:
String
=
{
...
...
src/main/scala/com/github/shadowsocks/MainActivity.scala
View file @
dfe469e1
...
...
@@ -143,7 +143,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
txRateText
.
setText
(
TrafficMonitor
.
formatTraffic
(
txRate
)
+
"/s"
)
rxRateText
.
setText
(
TrafficMonitor
.
formatTraffic
(
rxRate
)
+
"/s"
)
val
child
=
getFragmentManager
.
findFragmentById
(
R
.
id
.
content
).
asInstanceOf
[
ToolbarFragment
]
if
(
child
!=
null
)
child
.
onTrafficUpdated
(
txRate
,
rxRate
,
txTotal
,
rxTotal
)
if
(
state
!=
State
.
STOPPING
&&
child
!=
null
)
child
.
onTrafficUpdated
(
txRate
,
rxRate
,
txTotal
,
rxTotal
)
}
override
def
onServiceConnected
()
{
...
...
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
View file @
dfe469e1
...
...
@@ -23,7 +23,7 @@ package com.github.shadowsocks
import
java.util.GregorianCalendar
import
android.content._
import
android.os.
{
Bundle
,
Handler
}
import
android.os.
Bundle
import
android.support.v7.widget.RecyclerView.ViewHolder
import
android.support.v7.widget._
import
android.support.v7.widget.helper.ItemTouchHelper
...
...
@@ -93,27 +93,21 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
share
.
setOnLongClickListener
(
cardButtonLongClickListener
)
}
def
updateText
(
txTotal
:
Long
=
0
,
rxTotal
:
Long
=
0
)
{
val
tx
=
item
.
tx
+
txTotal
val
rx
=
item
.
rx
+
rxTotal
val
title
=
item
.
getName
val
address
=
if
(
item
.
nameIsEmpty
)
""
else
item
.
formattedAddress
val
traffic
=
getString
(
R
.
string
.
stat_profiles
,
TrafficMonitor
.
formatTraffic
(
tx
),
TrafficMonitor
.
formatTraffic
(
rx
))
handler
.
post
(()
=>
{
this
.
title
.
setText
(
title
)
this
.
address
.
setText
(
address
)
this
.
traffic
.
setText
(
traffic
)
})
}
def
bind
(
item
:
Profile
)
{
this
.
item
=
item
val
editable
=
isProfileEditable
(
item
.
id
)
edit
.
setEnabled
(
editable
)
edit
.
setAlpha
(
if
(
editable
)
1
else
0.5F
)
updateText
()
var
tx
=
item
.
tx
var
rx
=
item
.
rx
if
(
item
.
id
==
app
.
profileId
)
{
tx
+=
txTotal
rx
+=
rxTotal
}
title
.
setText
(
item
.
getName
)
address
.
setText
(
if
(
item
.
nameIsEmpty
)
""
else
item
.
formattedAddress
)
traffic
.
setText
(
getString
(
R
.
string
.
stat_profiles
,
TrafficMonitor
.
formatTraffic
(
tx
),
TrafficMonitor
.
formatTraffic
(
rx
)))
if
(
item
.
id
==
app
.
profileId
)
{
indicator
.
setBackgroundResource
(
R
.
drawable
.
background_selected
)
...
...
@@ -239,10 +233,11 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
}
private
var
selectedItem
:
ProfileViewHolder
=
_
private
val
handler
=
new
Handler
lazy
val
profilesAdapter
=
new
ProfilesAdapter
private
var
undoManager
:
UndoSnackbarManager
[
Profile
]
=
_
private
var
txTotal
:
Long
=
_
private
var
rxTotal
:
Long
=
_
private
lazy
val
clipboard
=
getActivity
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
).
asInstanceOf
[
ClipboardManager
]
...
...
@@ -262,7 +257,9 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
val
profilesList
=
view
.
findViewById
(
R
.
id
.
profilesList
).
asInstanceOf
[
RecyclerView
]
val
layoutManager
=
new
LinearLayoutManager
(
getActivity
)
profilesList
.
setLayoutManager
(
layoutManager
)
profilesList
.
setItemAnimator
(
new
DefaultItemAnimator
())
val
animator
=
new
DefaultItemAnimator
()
animator
.
setSupportsChangeAnimations
(
false
)
// prevent fading-in/out when rebinding
profilesList
.
setItemAnimator
(
animator
)
profilesList
.
setAdapter
(
profilesAdapter
)
instance
=
this
layoutManager
.
scrollToPosition
(
profilesAdapter
.
profiles
.
zipWithIndex
.
collectFirst
{
...
...
@@ -289,8 +286,11 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
}).
attachToRecyclerView
(
profilesList
)
}
override
def
onTrafficUpdated
(
txRate
:
Long
,
rxRate
:
Long
,
txTotal
:
Long
,
rxTotal
:
Long
)
:
Unit
=
if
(
selectedItem
!=
null
)
selectedItem
.
updateText
(
txTotal
,
rxTotal
)
override
def
onTrafficUpdated
(
txRate
:
Long
,
rxRate
:
Long
,
txTotal
:
Long
,
rxTotal
:
Long
)
:
Unit
=
{
this
.
txTotal
=
txTotal
this
.
rxTotal
=
rxTotal
profilesAdapter
.
refreshId
(
app
.
profileId
)
}
override
def
onDetach
()
{
undoManager
.
flush
()
...
...
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