From dbbc191704d1244e97cb8a86deea92f58d48dc2b Mon Sep 17 00:00:00 2001 From: davide Date: Sun, 24 Jul 2022 03:38:46 +0200 Subject: [PATCH] Remove unused items variables --- .../amine/apps/readerforselfossv2/android/HomeActivity.kt | 8 -------- .../apps/readerforselfossv2/repository/Repository.kt | 1 - .../apps/readerforselfossv2/repository/RepositoryImpl.kt | 6 +----- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt index 218a67d..af91908 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt @@ -103,7 +103,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar private val FAV_SHOWN = 3 private var items: ArrayList = ArrayList() - private var allItems: ArrayList = ArrayList() private var internalBrowser = false private var articleViewer = false @@ -206,8 +205,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar searchService = SearchService(DateUtils(repository.apiMajorVersion)) dbService = AndroidDeviceDatabaseService(dataBase, searchService) service = SelfossService(api, dbService, searchService) - items = ArrayList() - allItems = ArrayList() handleBottomBar() handleDrawer() @@ -229,7 +226,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar ) binding.swipeRefreshLayout.setOnRefreshListener { offlineShortcut = false - allItems = ArrayList() lastFetchDone = false handleDrawerItems() CoroutineScope(Dispatchers.Main).launch { @@ -549,7 +545,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar textColor = ColorHolder.fromColor(Color.WHITE) color = ColorHolder.fromColor(appColors.colorAccent) } onDrawerItemClickListener = { _,_,_ -> - allItems = ArrayList() searchService.tagFilter = it.tag searchService.sourceFilter = null searchService.sourceIDFilter = null @@ -602,7 +597,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar textColor = ColorHolder.fromColor(Color.WHITE) color = ColorHolder.fromColor(appColors.colorAccent) } onDrawerItemClickListener = { _,_,_ -> - allItems = ArrayList() searchService.tagFilter = it.tag searchService.sourceFilter = null searchService.sourceIDFilter = null @@ -638,7 +632,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar identifier = source.id.toLong() iconUrl = source.getIcon(apiDetailsService.getBaseUrl()) onDrawerItemClickListener = { _,_,_ -> - allItems = ArrayList() searchService.sourceIDFilter = source.id.toLong() searchService.sourceFilter = source.title searchService.tagFilter = null @@ -661,7 +654,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar identifier = DRAWER_ID_FILTERS badgeRes = R.string.drawer_action_clear onDrawerItemClickListener = { _,_,_ -> - allItems = ArrayList() searchService.sourceFilter = null searchService.sourceIDFilter = null searchService.tagFilter = null diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt index 3bc6c95..a1cb199 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt @@ -6,7 +6,6 @@ interface Repository { // TODO: remove the items variables in favor of storing everything in the database var items: ArrayList - var selectedItems: ArrayList var baseUrl: String var selectedType: String diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index f4db7f8..ed7bbbd 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -17,10 +17,6 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet get() { return ArrayList(field) } set(value) { field = ArrayList(value) } - override var selectedItems = ArrayList() - get() { return ArrayList(field) } - set(value) { field = ArrayList(value) } - override var baseUrl = apiDetails.getBaseUrl() // TODO: Validate the string in the setter @@ -55,7 +51,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet override suspend fun getOlderItems(): ArrayList { // TODO: Check connectivity - val offset = selectedItems.size + val offset = filterSelectedItems(items).size val fetchedItems = api.getItems(selectedType, settings.getString("prefer_api_items_number", "200").toInt(), offset,