Skip to content

Commit 5fe66d9

Browse files
committed
review: unwrap LifecycleOwner once in ServiceButton (avoid double unwrap)
1 parent 2f1f915 commit 5fe66d9

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

app/src/main/java/io/nekohasekai/sagernet/widget/ServiceButton.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ class ServiceButton @JvmOverloads constructor(
6767
private val iconConnecting by lazy {
6868
AnimatedState(R.drawable.ic_service_connecting) {
6969
hideProgress()
70-
delayedAnimation = context.unwrap<LifecycleOwner>().lifecycleScope.launch {
70+
val owner = context.unwrap<LifecycleOwner>()
71+
delayedAnimation = owner.lifecycleScope.launch {
7172
delay(context.resources.getInteger(android.R.integer.config_mediumAnimTime) + 1000L)
7273
// Gate the UI mutation on STARTED so a delayed progress reveal doesn't run
7374
// while the activity is stopped (the old launchWhenStarted suspended here).
74-
context.unwrap<LifecycleOwner>().withStarted {
75+
owner.withStarted {
7576
isIndeterminate = true
7677
show()
7778
}

0 commit comments

Comments
 (0)