Commit fe885bed authored by Mygod's avatar Mygod

Fix animation when going from connecting to stopping

parent 28f0b4ec
......@@ -123,7 +123,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref
}
private fun changeState(state: BaseService.State, msg: String? = null, animate: Boolean = false) {
fab.changeState(state, animate)
fab.changeState(state, this.state, animate)
stats.changeState(state)
if (msg != null) snackbar(getString(R.string.vpn_error, msg)).show()
this.state = state
......
......@@ -68,11 +68,13 @@ class ServiceButton @JvmOverloads constructor(context: Context, attrs: Attribute
return drawableState
}
fun changeState(state: BaseService.State, animate: Boolean) {
fun changeState(state: BaseService.State, previousState: BaseService.State, animate: Boolean) {
when (state) {
BaseService.State.Connecting -> changeState(iconConnecting, animate)
BaseService.State.Connected -> changeState(iconConnected, animate)
BaseService.State.Stopping -> changeState(iconStopping, animate)
BaseService.State.Stopping -> {
if (previousState == BaseService.State.Connected) changeState(iconStopping, animate)
}
else -> changeState(iconStopped, animate)
}
if (state == BaseService.State.Connected) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment