Skip to content
Snippets Groups Projects
Commit fb9f243c authored by Pierre Nicolas's avatar Pierre Nicolas :joy: Committed by Adrien Béraud
Browse files

conversation: hide "scroll to end" when unnecessary

GitLab: #1251
Change-Id: I2a4d01560218daefb742af79565eb9b0da6c19a1
parent 0dbb6687
No related branches found
No related tags found
No related merge requests found
......@@ -347,24 +347,29 @@ class ConversationFragment : BaseSupportFragment<ConversationPresenter, Conversa
val visibleLatestThreshold = 8
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {}
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
val layoutManager = recyclerView.layoutManager as LinearLayoutManager?
if (!loading && layoutManager!!.findFirstVisibleItemPosition() < visibleLoadThreshold) {
val layoutManager = recyclerView.layoutManager as LinearLayoutManager? ?: return
if (!loading
&& layoutManager.findFirstVisibleItemPosition() < visibleLoadThreshold
) {
loading = true
presenter.loadMore()
}
if (layoutManager!!.itemCount - layoutManager.findLastVisibleItemPosition() > visibleLatestThreshold) {
// Recyclerview is composed of items which are sometimes invisible (to preserve
// the model and interaction relationship).
// Because of bug #1251, we use findLastCompletelyVisibleItemPosition because
// findLastVisibleItemPosition ignores invisible items (don't understand why).
val lastVisibleItemPosition =
layoutManager.findLastCompletelyVisibleItemPosition()
if (layoutManager.itemCount - lastVisibleItemPosition > visibleLatestThreshold)
binding.fabLatest.show()
} else {
binding.fabLatest.hide()
}
else binding.fabLatest.hide()
}
})
val animator = binding.histList.itemAnimator as DefaultItemAnimator?
animator?.supportsChangeAnimations = false
binding.histList.adapter = mAdapter
// val toolbarLayout: AppBarLayout? = activity?.findViewById(R.id.toolbar_layout)
// toolbarLayout?.isLifted = true
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment