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
bf1961aa
Commit
bf1961aa
authored
Aug 26, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Request bandwidth update on switching tab
parent
7d5197e2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
31 deletions
+27
-31
core/src/main/java/com/github/shadowsocks/aidl/ShadowsocksConnection.kt
...java/com/github/shadowsocks/aidl/ShadowsocksConnection.kt
+3
-4
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+18
-21
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
+5
-2
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
.../src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/ToolbarFragment.kt
...e/src/main/java/com/github/shadowsocks/ToolbarFragment.kt
+0
-3
No files found.
core/src/main/java/com/github/shadowsocks/aidl/ShadowsocksConnection.kt
View file @
bf1961aa
...
...
@@ -84,10 +84,9 @@ class ShadowsocksConnection(private val handler: Handler = Handler(),
var
bandwidthTimeout
=
0L
set
(
value
)
{
val
service
=
service
if
(
bandwidthTimeout
!=
value
&&
service
!=
null
)
try
{
if
(
value
>
0
)
service
.
startListeningForBandwidth
(
serviceCallback
,
value
)
else
service
.
stopListeningForBandwidth
(
serviceCallback
)
try
{
if
(
value
>
0
)
service
?.
startListeningForBandwidth
(
serviceCallback
,
value
)
else
service
?.
stopListeningForBandwidth
(
serviceCallback
)
}
catch
(
_
:
RemoteException
)
{
}
field
=
value
}
...
...
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
bf1961aa
...
...
@@ -149,9 +149,7 @@ object BaseService {
override
fun
startListeningForBandwidth
(
cb
:
IShadowsocksServiceCallback
,
timeout
:
Long
)
{
launch
{
val
wasEmpty
=
bandwidthListeners
.
isEmpty
()
if
(
bandwidthListeners
.
put
(
cb
.
asBinder
(),
timeout
)
==
null
)
{
if
(
wasEmpty
)
{
if
(
bandwidthListeners
.
isEmpty
()
and
(
bandwidthListeners
.
put
(
cb
.
asBinder
(),
timeout
)
==
null
))
{
check
(
looper
==
null
)
looper
=
launch
{
loop
()
}
}
...
...
@@ -176,7 +174,6 @@ object BaseService {
cb
.
trafficUpdated
(
0
,
sum
)
}
}
}
override
fun
stopListeningForBandwidth
(
cb
:
IShadowsocksServiceCallback
)
{
launch
{
...
...
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
View file @
bf1961aa
...
...
@@ -101,7 +101,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref
if
(
profileId
==
0L
)
this
@MainActivity
.
stats
.
updateTraffic
(
stats
.
txRate
,
stats
.
rxRate
,
stats
.
txTotal
,
stats
.
rxTotal
)
if
(
state
!=
BaseService
.
State
.
Stopping
)
{
(
supportFragmentManager
.
findFragmentById
(
R
.
id
.
fragment_holder
)
as
?
Toolbar
Fragment
)
(
supportFragmentManager
.
findFragmentById
(
R
.
id
.
fragment_holder
)
as
?
Profiles
Fragment
)
?.
onTrafficUpdated
(
profileId
,
stats
)
}
}
...
...
@@ -201,7 +201,10 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref
override
fun
onNavigationItemSelected
(
item
:
MenuItem
):
Boolean
{
if
(
item
.
isChecked
)
drawer
.
closeDrawers
()
else
{
when
(
item
.
itemId
)
{
R
.
id
.
profiles
->
displayFragment
(
ProfilesFragment
())
R
.
id
.
profiles
->
{
displayFragment
(
ProfilesFragment
())
connection
.
bandwidthTimeout
=
connection
.
bandwidthTimeout
// request stats update
}
R
.
id
.
globalSettings
->
displayFragment
(
GlobalSettingsFragment
())
R
.
id
.
about
->
{
Core
.
analytics
.
logEvent
(
"about"
,
Bundle
())
...
...
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
View file @
bf1961aa
...
...
@@ -461,7 +461,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
}
}
override
fun
onTrafficUpdated
(
profileId
:
Long
,
stats
:
TrafficStats
)
{
fun
onTrafficUpdated
(
profileId
:
Long
,
stats
:
TrafficStats
)
{
if
(
profileId
!=
0L
)
{
// ignore aggregate stats
statsCache
.
put
(
profileId
,
stats
)
profilesAdapter
.
refreshId
(
profileId
)
...
...
mobile/src/main/java/com/github/shadowsocks/ToolbarFragment.kt
View file @
bf1961aa
...
...
@@ -25,7 +25,6 @@ import android.view.View
import
androidx.appcompat.widget.Toolbar
import
androidx.core.view.GravityCompat
import
androidx.fragment.app.Fragment
import
com.github.shadowsocks.aidl.TrafficStats
/**
* @author Mygod
...
...
@@ -40,7 +39,5 @@ open class ToolbarFragment : Fragment() {
toolbar
.
setNavigationOnClickListener
{
(
activity
as
MainActivity
).
drawer
.
openDrawer
(
GravityCompat
.
START
)
}
}
open
fun
onTrafficUpdated
(
profileId
:
Long
,
stats
:
TrafficStats
)
{
}
open
fun
onBackPressed
():
Boolean
=
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