From 57177cc910172a04f101d4250ada5bbdca11abb6 Mon Sep 17 00:00:00 2001 From: Amine Date: Wed, 1 Nov 2017 19:46:13 +0100 Subject: [PATCH] Loading more on swipe. --- .../apps/amine/bou/readerforselfoss/HomeActivity.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt index 766aeec..bc5443b 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt @@ -207,6 +207,18 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { else tabNewBadge.hide() + + val manager = recyclerView.layoutManager + val lastVisibleItem: Int = when (manager) { + is StaggeredGridLayoutManager -> manager.findLastCompletelyVisibleItemPositions(null).last() + is GridLayoutManager -> manager.findLastCompletelyVisibleItemPosition() + else -> 0 + } + + if (lastVisibleItem == (items.size - 1)) { + getElementsAccordingToTab(appendResults = true) + } + } catch (e: IndexOutOfBoundsException) {} }