Commit 9fd86fe8 authored by Mygod's avatar Mygod

Fix #1487

parent 6608355e
...@@ -93,7 +93,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, Drawe ...@@ -93,7 +93,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, Drawe
private lateinit var fabProgressCircle: FABProgressCircle private lateinit var fabProgressCircle: FABProgressCircle
internal var crossfader: Crossfader<CrossFadeSlidingPaneLayout>? = null internal var crossfader: Crossfader<CrossFadeSlidingPaneLayout>? = null
internal lateinit var drawer: Drawer internal lateinit var drawer: Drawer
private var previousPosition: Int = 0 // it's actually lateinit private var previousSelectedDrawer: Long = 0 // it's actually lateinit
private var testCount = 0 private var testCount = 0
private lateinit var statusText: TextView private lateinit var statusText: TextView
...@@ -303,7 +303,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, Drawe ...@@ -303,7 +303,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, Drawe
} else drawer = drawerBuilder.build() } else drawer = drawerBuilder.build()
if (savedInstanceState == null) displayFragment(ProfilesFragment()) if (savedInstanceState == null) displayFragment(ProfilesFragment())
previousPosition = drawer.currentSelectedPosition previousSelectedDrawer = drawer.currentSelection
statusText = findViewById(R.id.status) statusText = findViewById(R.id.status)
txText = findViewById(R.id.tx) txText = findViewById(R.id.tx)
txRateText = findViewById(R.id.txRate) txRateText = findViewById(R.id.txRate)
...@@ -387,9 +387,10 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, Drawe ...@@ -387,9 +387,10 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, Drawe
} }
override fun onItemClick(view: View?, position: Int, drawerItem: IDrawerItem<*, *>): Boolean { override fun onItemClick(view: View?, position: Int, drawerItem: IDrawerItem<*, *>): Boolean {
if (position == previousPosition) drawer.closeDrawer() else { val id = drawerItem.identifier
previousPosition = position if (id == previousSelectedDrawer) drawer.closeDrawer() else {
when (drawerItem.identifier) { previousSelectedDrawer = id
when (id) {
DRAWER_PROFILES -> displayFragment(ProfilesFragment()) DRAWER_PROFILES -> displayFragment(ProfilesFragment())
DRAWER_GLOBAL_SETTINGS -> displayFragment(GlobalSettingsFragment()) DRAWER_GLOBAL_SETTINGS -> displayFragment(GlobalSettingsFragment())
DRAWER_ABOUT -> { DRAWER_ABOUT -> {
......
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