From d350088153d639090a355d49d956bfbd21123e53 Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 17 Jun 2016 13:01:09 +0800 Subject: [PATCH] Refine updateCurrentProfile --- src/main/scala/com/github/shadowsocks/Shadowsocks.scala | 6 +++--- .../com/github/shadowsocks/database/ProfileManager.scala | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala index 2c691aaf..f8a18ed8 100644 --- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala +++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala @@ -491,10 +491,10 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext { currentProfile = app.currentProfile match { case Some(profile) => profile // updated case None => // removed - app.profileManager.getFirstProfile match { - case Some(first) => app.switchProfile(first.id) + app.switchProfile((app.profileManager.getFirstProfile match { + case Some(first) => first case None => app.profileManager.createDefault() - } + }).id) } updatePreferenceScreen() diff --git a/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala b/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala index a56d0664..9e178e5c 100644 --- a/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala +++ b/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala @@ -208,6 +208,5 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) { password = "u1rRWTssNv0p" } createProfile(profile) - profile } }