Add exception catching in reflection. Fix deselecting mini drawer.

This commit is contained in:
kubasz 2020-03-26 18:18:19 +01:00
parent 43f5ecdef5
commit 28cdab3414

View File

@ -171,6 +171,7 @@ class NavDrawer(
miniDrawer = MiniDrawerSliderView(context).apply { miniDrawer = MiniDrawerSliderView(context).apply {
drawer = this@NavDrawer.drawer drawer = this@NavDrawer.drawer
includeSecondaryDrawerItems = false includeSecondaryDrawerItems = false
try {
this::class.java.getDeclaredField("onMiniDrawerItemClickListener").let { this::class.java.getDeclaredField("onMiniDrawerItemClickListener").let {
it.isAccessible = true it.isAccessible = true
it.set(this, { v: View?, position: Int, item: IDrawerItem<*>, type: Int -> it.set(this, { v: View?, position: Int, item: IDrawerItem<*>, type: Int ->
@ -178,10 +179,10 @@ class NavDrawer(
profileSelectionOpen() profileSelectionOpen()
open() open()
true true
} } else false
else false
}) })
} }
} catch (_: Exception) { }
} }
updateMiniDrawer() updateMiniDrawer()
@ -478,7 +479,7 @@ class NavDrawer(
if (drawer.selectedItemIdentifier != id.toLong() || !fireOnClick) if (drawer.selectedItemIdentifier != id.toLong() || !fireOnClick)
drawer.setSelection(id.toLong(), fireOnClick) drawer.setSelection(id.toLong(), fireOnClick)
//miniDrawer.setSelection(-1L) miniDrawer.setSelection(-1L)
if (drawerMode == DRAWER_MODE_MINI) if (drawerMode == DRAWER_MODE_MINI)
miniDrawer.setSelection(id.toLong()) miniDrawer.setSelection(id.toLong())
} }