This commit is contained in:
Amine Bou 2018-03-30 22:14:49 +02:00
parent 18946464a2
commit d6c74049c3

View File

@ -87,6 +87,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
private val FAV_SHOWN = 3 private val FAV_SHOWN = 3
private var items: ArrayList<Item> = ArrayList() private var items: ArrayList<Item> = ArrayList()
private var allItems: ArrayList<Item> = ArrayList()
private var clickBehavior = false private var clickBehavior = false
private var debugReadingItems = false private var debugReadingItems = false
private var shouldLogEverything = false private var shouldLogEverything = false
@ -159,6 +160,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
shouldLogEverything shouldLogEverything
) )
items = ArrayList() items = ArrayList()
allItems = ArrayList()
appColors = AppColors(this@HomeActivity) appColors = AppColors(this@HomeActivity)
@ -770,10 +772,15 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
if (response.body() != null) { if (response.body() != null) {
if (shouldUpdate) { if (shouldUpdate) {
items = response.body() as ArrayList<Item> items = response.body() as ArrayList<Item>
items.forEach {
if (!allItems.contains(it)) allItems.add(it)
}
} }
} else { } else {
if (!appendResults) { if (!appendResults) {
items = ArrayList() items = ArrayList()
allItems = ArrayList()
} }
} }
if (shouldUpdate) { if (shouldUpdate) {
@ -1043,7 +1050,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
if (elementsShown == UNREAD_SHOWN) { if (elementsShown == UNREAD_SHOWN) {
needsConfirmation(R.string.readAll, R.string.markall_dialog_message, { needsConfirmation(R.string.readAll, R.string.markall_dialog_message, {
swipeRefreshLayout.isRefreshing = false swipeRefreshLayout.isRefreshing = false
val ids = items.map { it.id } val ids = allItems.map { it.id }
fun readAllDebug(e: Throwable) { fun readAllDebug(e: Throwable) {
Crashlytics.setUserIdentifier(userIdentifier) Crashlytics.setUserIdentifier(userIdentifier)
@ -1098,8 +1105,9 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
} }
} }
}) })
items = ArrayList()
allItems = ArrayList()
} }
items = ArrayList()
if (items.isEmpty()) { if (items.isEmpty()) {
Toast.makeText( Toast.makeText(
this@HomeActivity, this@HomeActivity,