From 40ea07de2e9e167f7e6962f010c95b712268a844 Mon Sep 17 00:00:00 2001 From: Amine Bou Date: Tue, 28 Nov 2017 20:10:32 +0100 Subject: [PATCH] Last fix for the endless scroll. --- .../java/apps/amine/bou/readerforselfoss/HomeActivity.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 41a3d25..5302373 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt @@ -17,6 +17,7 @@ import android.support.v7.widget.RecyclerView import android.support.v7.widget.SearchView import android.support.v7.widget.StaggeredGridLayoutManager import android.support.v7.widget.helper.ItemTouchHelper +import android.util.Log import android.view.Menu import android.view.MenuItem import android.view.View @@ -101,6 +102,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { private var userIdentifier: String = "" private var displayAccountHeader: Boolean = false private var infiniteScroll: Boolean = false + private var lastFetchDone: Boolean = false private lateinit var tabNewBadge: TextBadgeItem private lateinit var tabArchiveBadge: TextBadgeItem @@ -227,8 +229,11 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { if (lastVisibleItem === items.size && items.size <= maxItemNumber() && - maxItemNumber() >= itemsNumber + (maxItemNumber() >= itemsNumber || !lastFetchDone) ) { + if (maxItemNumber() < itemsNumber) { + lastFetchDone = true + } getElementsAccordingToTab( appendResults = true, offsetOverride = lastVisibleItem @@ -656,6 +661,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { override fun onTabSelected(position: Int) { offset = 0 + lastFetchDone = false when (position) { 0 -> getUnRead() 1 -> getRead()