Scroll breadcrumbs to top when opened

This commit is contained in:
Benoit Marty 2019-12-13 16:42:48 +01:00
parent 853518fbb2
commit 1108ad5705
3 changed files with 15 additions and 1 deletions

View file

@ -11,7 +11,7 @@ Other changes:
-
Bugfix 🐛:
-
- Scroll breadcrumbs to top when opened
Translations 🗣:
-

View file

@ -65,4 +65,8 @@ class BreadcrumbsFragment @Inject constructor(
override fun onBreadcrumbClicked(roomId: String) {
sharedActionViewModel.post(RoomDetailSharedAction.SwitchToRoom(roomId))
}
fun scrollToTop() {
breadcrumbsRecyclerView.scrollToPosition(0)
}
}

View file

@ -86,9 +86,19 @@ class RoomDetailActivity : VectorBaseActivity(), ToolbarConfigurable {
private val drawerListener = object : DrawerLayout.SimpleDrawerListener() {
override fun onDrawerStateChanged(newState: Int) {
hideKeyboard()
if (!drawerLayout.isDrawerOpen(GravityCompat.START) && newState == DrawerLayout.STATE_DRAGGING) {
// User is starting to open the drawer, scroll the list to op
scrollBreadcrumbsToTop()
}
}
}
private fun scrollBreadcrumbsToTop() {
supportFragmentManager.fragments.filterIsInstance<BreadcrumbsFragment>()
.forEach { it.scrollToTop() }
}
override fun onBackPressed() {
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START)