Last fix for the endless scroll.

This commit is contained in:
Amine Bou 2017-11-28 20:10:32 +01:00
parent 7905e4aa12
commit 40ea07de2e

View File

@ -17,6 +17,7 @@ import android.support.v7.widget.RecyclerView
import android.support.v7.widget.SearchView import android.support.v7.widget.SearchView
import android.support.v7.widget.StaggeredGridLayoutManager import android.support.v7.widget.StaggeredGridLayoutManager
import android.support.v7.widget.helper.ItemTouchHelper import android.support.v7.widget.helper.ItemTouchHelper
import android.util.Log
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
@ -101,6 +102,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
private var userIdentifier: String = "" private var userIdentifier: String = ""
private var displayAccountHeader: Boolean = false private var displayAccountHeader: Boolean = false
private var infiniteScroll: Boolean = false private var infiniteScroll: Boolean = false
private var lastFetchDone: Boolean = false
private lateinit var tabNewBadge: TextBadgeItem private lateinit var tabNewBadge: TextBadgeItem
private lateinit var tabArchiveBadge: TextBadgeItem private lateinit var tabArchiveBadge: TextBadgeItem
@ -227,8 +229,11 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
if (lastVisibleItem === items.size && if (lastVisibleItem === items.size &&
items.size <= maxItemNumber() && items.size <= maxItemNumber() &&
maxItemNumber() >= itemsNumber (maxItemNumber() >= itemsNumber || !lastFetchDone)
) { ) {
if (maxItemNumber() < itemsNumber) {
lastFetchDone = true
}
getElementsAccordingToTab( getElementsAccordingToTab(
appendResults = true, appendResults = true,
offsetOverride = lastVisibleItem offsetOverride = lastVisibleItem
@ -656,6 +661,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
override fun onTabSelected(position: Int) { override fun onTabSelected(position: Int) {
offset = 0 offset = 0
lastFetchDone = false
when (position) { when (position) {
0 -> getUnRead() 0 -> getUnRead()
1 -> getRead() 1 -> getRead()