Reader chapter sheet now needs two swipes from recycler view to collapse

similar to other bottom sheets, if you're not at the top of the list and reach the top while dragging, it will not drag the sheet down. only when at the top it will drag down
This commit is contained in:
Jays2Kings 2021-08-10 16:58:00 -04:00
parent c9fbe8f847
commit 18d385d5ac

View File

@ -174,6 +174,19 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
else fullPrimary
)
binding.chapterRecycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
if (newState == RecyclerView.SCROLL_STATE_IDLE ||
newState == RecyclerView.SCROLL_STATE_SETTLING
) {
sheetBehavior?.isDraggable = true
} else {
sheetBehavior?.isDraggable = !recyclerView.canScrollVertically(-1)
}
}
})
binding.chapterRecycler.layoutManager = LinearLayoutManager(context)
refreshList()
}