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,17 +171,18 @@ class NavDrawer(
miniDrawer = MiniDrawerSliderView(context).apply { miniDrawer = MiniDrawerSliderView(context).apply {
drawer = this@NavDrawer.drawer drawer = this@NavDrawer.drawer
includeSecondaryDrawerItems = false includeSecondaryDrawerItems = false
this::class.java.getDeclaredField("onMiniDrawerItemClickListener").let { try {
it.isAccessible = true this::class.java.getDeclaredField("onMiniDrawerItemClickListener").let {
it.set(this, { v: View?, position: Int, item: IDrawerItem<*>, type: Int -> it.isAccessible = true
if (item is MiniProfileDrawerItem) { it.set(this, { v: View?, position: Int, item: IDrawerItem<*>, type: Int ->
profileSelectionOpen() if (item is MiniProfileDrawerItem) {
open() profileSelectionOpen()
true open()
} 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())
} }