Commit 5052b748 authored by Max Lv's avatar Max Lv

fix a race condition

parent cefe9b17
......@@ -322,7 +322,7 @@ class Shadowsocks
case ignored: RemoteException => // Nothing
}
// Update the UI
switchButton.setEnabled(true)
if (switchButton != null) switchButton.setEnabled(true)
if (State.isAvailable(bgService.getState)) {
Crouton.cancelAllCroutons()
setPreferenceEnabled(enabled = true)
......@@ -334,9 +334,9 @@ class Shadowsocks
}
override def onServiceDisconnected(name: ComponentName) {
switchButton.setEnabled(false)
if (switchButton != null) switchButton.setEnabled(false)
try {
bgService.unregisterCallback(callback)
if (bgService != null) bgService.unregisterCallback(callback)
} catch {
case ignored: RemoteException => // Nothing
}
......
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