From 0fe62e256b3332c8de3c98a52fedd4d44794e340 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 24 Dec 2016 02:11:40 +0800 Subject: [PATCH] Prevent crash when removing current profile --- .../scala/com/github/shadowsocks/ProfilesFragment.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala b/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala index 65cdbd5f..0d9f911f 100644 --- a/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala +++ b/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala @@ -195,8 +195,10 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene def refreshId(id: Int) { val index = profiles.indexWhere(_.id == id) - profiles(index) = app.profileManager.getProfile(id).get - notifyItemChanged(index) + if (index >= 0) { + profiles(index) = app.profileManager.getProfile(id).get + notifyItemChanged(index) + } } def removeId(id: Int) { val index = profiles.indexWhere(_.id == id)