Search Result | scroll jumps after pagination (#2238)

This commit is contained in:
Benoit Marty 2020-10-30 09:02:29 +01:00
parent 5f99eb8c97
commit 225a5d4e59
3 changed files with 4 additions and 11 deletions

View File

@ -17,6 +17,7 @@ Improvements 🙌:
Bugfix 🐛: Bugfix 🐛:
- Messages encrypted with no way to decrypt after SDK update from 0.18 to 1.0.0 (#2252) - Messages encrypted with no way to decrypt after SDK update from 0.18 to 1.0.0 (#2252)
- Search Result | scroll jumps after pagination (#2238)
Translations 🗣: Translations 🗣:
- -

View File

@ -52,8 +52,6 @@ class SearchFragment @Inject constructor(
private val fragmentArgs: SearchArgs by args() private val fragmentArgs: SearchArgs by args()
private val searchViewModel: SearchViewModel by fragmentViewModel() private val searchViewModel: SearchViewModel by fragmentViewModel()
private var pendingScrollToPosition: Int? = null
override fun getLayoutResId() = R.layout.fragment_search override fun getLayoutResId() = R.layout.fragment_search
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -70,12 +68,6 @@ class SearchFragment @Inject constructor(
searchResultRecycler.configureWith(controller, showDivider = false) searchResultRecycler.configureWith(controller, showDivider = false)
(searchResultRecycler.layoutManager as? LinearLayoutManager)?.stackFromEnd = true (searchResultRecycler.layoutManager as? LinearLayoutManager)?.stackFromEnd = true
controller.listener = this controller.listener = this
controller.addModelBuildListener {
pendingScrollToPosition?.let {
searchResultRecycler.smoothScrollToPosition(it)
}
}
} }
override fun onDestroy() { override fun onDestroy() {
@ -100,8 +92,6 @@ class SearchFragment @Inject constructor(
} }
} }
} else { } else {
pendingScrollToPosition = (state.lastBatchSize - 1).coerceAtLeast(0)
stateView.state = StateView.State.Content stateView.state = StateView.State.Content
controller.setData(state) controller.setData(state)
} }

View File

@ -8,8 +8,10 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/searchResultRecycler" android:id="@+id/searchResultRecycler"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:overScrollMode="always" android:overScrollMode="always"
tools:itemCount="2"
tools:listitem="@layout/item_search_result" /> tools:listitem="@layout/item_search_result" />
</im.vector.app.core.platform.StateView> </im.vector.app.core.platform.StateView>