From d6c74049c3c34016ee3d7472503df7966b28362e Mon Sep 17 00:00:00 2001 From: Amine Bou Date: Fri, 30 Mar 2018 22:14:49 +0200 Subject: [PATCH] Fixes #185. --- .../apps/amine/bou/readerforselfoss/HomeActivity.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 9899f30..74c9d0b 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt @@ -87,6 +87,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { private val FAV_SHOWN = 3 private var items: ArrayList = ArrayList() + private var allItems: ArrayList = ArrayList() private var clickBehavior = false private var debugReadingItems = false private var shouldLogEverything = false @@ -159,6 +160,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { shouldLogEverything ) items = ArrayList() + allItems = ArrayList() appColors = AppColors(this@HomeActivity) @@ -770,10 +772,15 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { if (response.body() != null) { if (shouldUpdate) { items = response.body() as ArrayList + + items.forEach { + if (!allItems.contains(it)) allItems.add(it) + } } } else { if (!appendResults) { items = ArrayList() + allItems = ArrayList() } } if (shouldUpdate) { @@ -1043,7 +1050,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { if (elementsShown == UNREAD_SHOWN) { needsConfirmation(R.string.readAll, R.string.markall_dialog_message, { swipeRefreshLayout.isRefreshing = false - val ids = items.map { it.id } + val ids = allItems.map { it.id } fun readAllDebug(e: Throwable) { Crashlytics.setUserIdentifier(userIdentifier) @@ -1098,8 +1105,9 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { } } }) + items = ArrayList() + allItems = ArrayList() } - items = ArrayList() if (items.isEmpty()) { Toast.makeText( this@HomeActivity,