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
e9dc275f
Commit
e9dc275f
authored
Jan 19, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure code only run when created
parent
3d079f29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt
...main/java/com/github/shadowsocks/ProfileConfigFragment.kt
+2
-1
mobile/src/main/java/com/github/shadowsocks/widget/StatsBar.kt
...e/src/main/java/com/github/shadowsocks/widget/StatsBar.kt
+4
-2
No files found.
mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt
View file @
e9dc275f
...
...
@@ -32,6 +32,7 @@ import android.view.MenuItem
import
android.view.View
import
androidx.appcompat.app.AlertDialog
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.whenCreated
import
androidx.preference.*
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.database.ProfileManager
...
...
@@ -171,7 +172,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
super
.
onAttach
(
context
)
receiver
=
context
.
listenForPackageChanges
(
false
)
{
lifecycleScope
.
launch
(
Dispatchers
.
Main
)
{
// wait until changes were flushed
lifecycleScope
.
launchW
henCreated
{
initPlugins
()
}
w
henCreated
{
initPlugins
()
}
}
}
}
...
...
mobile/src/main/java/com/github/shadowsocks/widget/StatsBar.kt
View file @
e9dc275f
...
...
@@ -30,12 +30,14 @@ import androidx.appcompat.widget.TooltipCompat
import
androidx.coordinatorlayout.widget.CoordinatorLayout
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.observe
import
androidx.lifecycle.whenStarted
import
com.github.shadowsocks.MainActivity
import
com.github.shadowsocks.R
import
com.github.shadowsocks.bg.BaseService
import
com.github.shadowsocks.net.HttpsTest
import
com.google.android.material.bottomappbar.BottomAppBar
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
class
StatsBar
@JvmOverloads
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?
=
null
,
...
...
@@ -76,8 +78,8 @@ class StatsBar @JvmOverloads constructor(context: Context, attrs: AttributeSet?
fun
changeState
(
state
:
BaseService
.
State
)
{
val
activity
=
context
as
MainActivity
fun
postWhenStarted
(
what
:
()
->
Unit
)
=
activity
.
lifecycleScope
.
launch
WhenStarted
{
withContext
(
Dispatchers
.
Main
)
{
what
()
}
fun
postWhenStarted
(
what
:
()
->
Unit
)
=
activity
.
lifecycleScope
.
launch
{
withContext
(
Dispatchers
.
Main
)
{
activity
.
whenStarted
{
what
()
}
}
}
if
((
state
==
BaseService
.
State
.
Connected
).
also
{
hideOnScroll
=
it
})
{
postWhenStarted
{
performShow
()
}
...
...
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