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 🐛: Bugfix 🐛:
- - Scroll breadcrumbs to top when opened
Translations 🗣: Translations 🗣:
- -

View File

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

View File

@ -86,8 +86,18 @@ class RoomDetailActivity : VectorBaseActivity(), ToolbarConfigurable {
private val drawerListener = object : DrawerLayout.SimpleDrawerListener() { private val drawerListener = object : DrawerLayout.SimpleDrawerListener() {
override fun onDrawerStateChanged(newState: Int) { override fun onDrawerStateChanged(newState: Int) {
hideKeyboard() 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() { override fun onBackPressed() {
if (drawerLayout.isDrawerOpen(GravityCompat.START)) { if (drawerLayout.isDrawerOpen(GravityCompat.START)) {