Commit 3ffca249 authored by Mygod's avatar Mygod

Handle error msg for no profile

parent c38e37c0
...@@ -107,9 +107,9 @@ trait BaseService extends Service { ...@@ -107,9 +107,9 @@ trait BaseService extends Service {
} }
} }
override def use(profileId: Int): Unit = synchronized(if (profileId < 0) stopRunner(stopService = true) else { override def use(profileId: Int): Unit = synchronized {
val profile = app.profileManager.getProfile(profileId).orNull val profile = app.profileManager.getProfile(profileId).orNull
if (profile == null) stopRunner(stopService = true) else state match { if (profile == null) stopRunner(stopService = true, "Please select a profile.") else state match { // TODO: localize
case State.STOPPED => if (checkProfile(profile)) startRunner(profile) case State.STOPPED => if (checkProfile(profile)) startRunner(profile)
case State.CONNECTED => if (profileId != BaseService.this.profile.id && checkProfile(profile)) { case State.CONNECTED => if (profileId != BaseService.this.profile.id && checkProfile(profile)) {
stopRunner(stopService = false) stopRunner(stopService = false)
...@@ -117,7 +117,7 @@ trait BaseService extends Service { ...@@ -117,7 +117,7 @@ trait BaseService extends Service {
} }
case _ => Log.w(BaseService.this.getClass.getSimpleName, "Illegal state when invoking use: " + state) case _ => Log.w(BaseService.this.getClass.getSimpleName, "Illegal state when invoking use: " + state)
} }
}) }
override def useSync(profileId: Int): Unit = use(profileId) override def useSync(profileId: Int): Unit = use(profileId)
} }
......
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