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
0fac785f
Commit
0fac785f
authored
Apr 05, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix context gone when callback is called
parent
fbb82c8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
tv/src/main/java/com/github/shadowsocks/tv/MainPreferenceFragment.kt
.../java/com/github/shadowsocks/tv/MainPreferenceFragment.kt
+4
-3
No files found.
tv/src/main/java/com/github/shadowsocks/tv/MainPreferenceFragment.kt
View file @
0fac785f
...
@@ -92,7 +92,7 @@ class MainPreferenceFragment : LeanbackPreferenceFragmentCompat(), ShadowsocksCo
...
@@ -92,7 +92,7 @@ class MainPreferenceFragment : LeanbackPreferenceFragmentCompat(), ShadowsocksCo
private
set
private
set
override
fun
stateChanged
(
state
:
BaseService
.
State
,
profileName
:
String
?,
msg
:
String
?)
=
changeState
(
state
,
msg
)
override
fun
stateChanged
(
state
:
BaseService
.
State
,
profileName
:
String
?,
msg
:
String
?)
=
changeState
(
state
,
msg
)
override
fun
trafficUpdated
(
profileId
:
Long
,
stats
:
TrafficStats
)
{
override
fun
trafficUpdated
(
profileId
:
Long
,
stats
:
TrafficStats
)
{
if
(
profileId
==
0L
)
requireContext
()
.
let
{
context
->
if
(
profileId
==
0L
)
context
?
.
let
{
context
->
this
.
stats
.
summary
=
getString
(
R
.
string
.
stat_summary
,
this
.
stats
.
summary
=
getString
(
R
.
string
.
stat_summary
,
getString
(
R
.
string
.
speed
,
Formatter
.
formatFileSize
(
context
,
stats
.
txRate
)),
getString
(
R
.
string
.
speed
,
Formatter
.
formatFileSize
(
context
,
stats
.
txRate
)),
getString
(
R
.
string
.
speed
,
Formatter
.
formatFileSize
(
context
,
stats
.
rxRate
)),
getString
(
R
.
string
.
speed
,
Formatter
.
formatFileSize
(
context
,
stats
.
rxRate
)),
...
@@ -102,6 +102,7 @@ class MainPreferenceFragment : LeanbackPreferenceFragmentCompat(), ShadowsocksCo
...
@@ -102,6 +102,7 @@ class MainPreferenceFragment : LeanbackPreferenceFragmentCompat(), ShadowsocksCo
}
}
private
fun
changeState
(
state
:
BaseService
.
State
,
msg
:
String
?
=
null
)
{
private
fun
changeState
(
state
:
BaseService
.
State
,
msg
:
String
?
=
null
)
{
val
context
=
context
?:
return
fab
.
isEnabled
=
state
.
canStop
||
state
==
BaseService
.
State
.
Stopped
fab
.
isEnabled
=
state
.
canStop
||
state
==
BaseService
.
State
.
Stopped
fab
.
setTitle
(
when
(
state
)
{
fab
.
setTitle
(
when
(
state
)
{
BaseService
.
State
.
Connecting
->
R
.
string
.
connecting
BaseService
.
State
.
Connecting
->
R
.
string
.
connecting
...
@@ -116,9 +117,9 @@ class MainPreferenceFragment : LeanbackPreferenceFragmentCompat(), ShadowsocksCo
...
@@ -116,9 +117,9 @@ class MainPreferenceFragment : LeanbackPreferenceFragmentCompat(), ShadowsocksCo
tester
.
status
.
removeObservers
(
this
)
tester
.
status
.
removeObservers
(
this
)
if
(
state
!=
BaseService
.
State
.
Idle
)
tester
.
invalidate
()
if
(
state
!=
BaseService
.
State
.
Idle
)
tester
.
invalidate
()
}
else
tester
.
status
.
observe
(
this
,
Observer
{
}
else
tester
.
status
.
observe
(
this
,
Observer
{
it
.
retrieve
(
stats
::
setTitle
)
{
Toast
.
makeText
(
requireContext
()
,
it
,
Toast
.
LENGTH_LONG
).
show
()
}
it
.
retrieve
(
stats
::
setTitle
)
{
Toast
.
makeText
(
context
,
it
,
Toast
.
LENGTH_LONG
).
show
()
}
})
})
if
(
msg
!=
null
)
Toast
.
makeText
(
requireContext
()
,
getString
(
R
.
string
.
vpn_error
,
msg
),
Toast
.
LENGTH_SHORT
).
show
()
if
(
msg
!=
null
)
Toast
.
makeText
(
context
,
getString
(
R
.
string
.
vpn_error
,
msg
),
Toast
.
LENGTH_SHORT
).
show
()
this
.
state
=
state
this
.
state
=
state
if
(
state
==
BaseService
.
State
.
Stopped
)
{
if
(
state
==
BaseService
.
State
.
Stopped
)
{
controlImport
.
isEnabled
=
true
controlImport
.
isEnabled
=
true
...
...
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