refine UI

This commit is contained in:
Max Lv
2013-09-29 16:26:19 +08:00
parent a2848ce538
commit 58dc3e5061
4 changed files with 61 additions and 22 deletions
@@ -70,8 +70,8 @@ class MenuAdapter(context: Context, var items: List[Any]) extends BaseAdapter {
this.listener = listener
}
def setActivePosition(activePosition: Int) {
this.activePosition = activePosition
def setActiveId(activeId: Int) {
this.activeId = activeId
}
@Override def getCount: Int = {
@@ -139,28 +139,26 @@ class MenuAdapter(context: Context, var items: List[Any]) extends BaseAdapter {
v.setTag(R.id.mdItem, value)
if (value.id == activeId) {
if (listener != null) listener.onActiveViewChanged(v, position)
}
case _ =>
}
v.setTag(R.id.mdActiveViewPosition, position)
if (position == activePosition) {
if (listener != null) listener.onActiveViewChanged(v, position)
}
v
}
def updateList(list: List[Any], activeId: Int) {
items = list
activePosition = items.indexWhere{
case item: Item => item.id == activeId
case _ => false
}
this.activeId = activeId
notifyDataSetChanged()
}
private var listener: MenuAdapter.MenuListener = null
private var activePosition: Int = -1
private var activeId: Int = -1
}
@@ -91,11 +91,12 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
}
}
def load(id: Int): Profile = {
Log.d(Shadowsocks.TAG, id + " ")
def reload(id: Int): Profile = {
save()
load(id)
}
def load(id: Int): Profile = {
val profile = getProfile(id) getOrElse {
val p = new Profile()
@@ -103,8 +104,6 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
p
}
Log.d(Shadowsocks.TAG, "load " + profile.id + " " + profile.name)
val edit = settings.edit()
edit.putBoolean(Key.isGlobalProxy, profile.global)
edit.putBoolean(Key.isGFWList, profile.chnroute)