Fix an issue of attach/deattach service when switching NAT mode

This commit is contained in:
Max Lv
2015-12-05 17:32:56 +08:00
parent b0f3d91d5d
commit d2a1027229
2 changed files with 18 additions and 7 deletions
@@ -73,10 +73,13 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
}
def onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) = key match {
case Key.isNAT => if (ShadowsocksApplication.isRoot) activity.handler.post(() => {
activity.deattachService()
activity.attachService()
})
case Key.isNAT => if (ShadowsocksApplication.isRoot && activity != null) {
activity.handler.post(() => {
val intent = activity.getIntent
activity.finish()
startActivity(intent)
})
}
case _ =>
}
}