Simplify scroll listeners

This commit is contained in:
Bnyro 2023-01-23 18:02:10 +01:00
parent 22dce72e95
commit f6a42cc8a0
3 changed files with 3 additions and 9 deletions

View File

@ -91,9 +91,7 @@ class ChannelFragment : BaseFragment() {
binding.channelScrollView.viewTreeObserver
.addOnScrollChangedListener {
if (binding.channelScrollView.getChildAt(0).bottom
== (binding.channelScrollView.height + binding.channelScrollView.scrollY)
) {
if (!binding.channelScrollView.canScrollVertically(1)) {
try {
onScrollEnd.invoke()
} catch (e: Exception) {

View File

@ -212,9 +212,7 @@ class PlaylistFragment : BaseFragment() {
binding.playlistRecView.adapter = playlistAdapter
binding.playlistScrollview.viewTreeObserver
.addOnScrollChangedListener {
if (binding.playlistScrollview.getChildAt(0).bottom
== (binding.playlistScrollview.height + binding.playlistScrollview.scrollY)
) {
if (!binding.playlistScrollview.canScrollVertically(1)) {
if (isLoading) return@addOnScrollChangedListener
// append more playlists to the recycler view

View File

@ -137,9 +137,7 @@ class SubscriptionsFragment : BaseFragment() {
binding.scrollviewSub.viewTreeObserver
.addOnScrollChangedListener {
if (binding.scrollviewSub.getChildAt(0).bottom
== (binding.scrollviewSub.height + binding.scrollviewSub.scrollY)
) {
if (!binding.scrollviewSub.canScrollVertically(1)) {
// scroll view is at bottom
if (viewModel.videoFeed.value == null) return@addOnScrollChangedListener
binding.subRefresh.isRefreshing = true