Skip to content

Commit eb827a4

Browse files
committed
Only show progress for connecting
1 parent 262fa7e commit eb827a4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

mobile/src/main/java/com/github/shadowsocks/widget/ServiceButton.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ class ServiceButton @JvmOverloads constructor(context: Context, attrs: Attribute
5959
}
6060

6161
private inner class AnimatedState(@DrawableRes resId: Int,
62-
private val onStart: BaseProgressIndicator<*>.() -> Unit = {
63-
hide()
64-
isIndeterminate = true
65-
show()
66-
}) {
62+
private val onStart: BaseProgressIndicator<*>.() -> Unit = { hide() }) {
6763
val icon: AnimatedVectorDrawableCompat = AnimatedVectorDrawableCompat.create(context, resId)!!.apply {
6864
registerAnimationCallback(this@ServiceButton.callback)
6965
}
@@ -75,8 +71,14 @@ class ServiceButton @JvmOverloads constructor(context: Context, attrs: Attribute
7571
fun stop() = icon.stop()
7672
}
7773

78-
private val iconStopped by lazy { AnimatedState(R.drawable.ic_service_stopped) { hide() } }
79-
private val iconConnecting by lazy { AnimatedState(R.drawable.ic_service_connecting) }
74+
private val iconStopped by lazy { AnimatedState(R.drawable.ic_service_stopped) }
75+
private val iconConnecting by lazy {
76+
AnimatedState(R.drawable.ic_service_connecting) {
77+
hide()
78+
isIndeterminate = true
79+
show()
80+
}
81+
}
8082
private val iconConnected by lazy { AnimatedState(R.drawable.ic_service_connected) { setProgressCompat(1, true) } }
8183
private val iconStopping by lazy { AnimatedState(R.drawable.ic_service_stopping) }
8284
private val animationQueue = ArrayDeque<AnimatedState>()

0 commit comments

Comments
 (0)