Simplify items appending operation
This commit is contained in:
parent
edc705ec8e
commit
7fb7e45093
@ -893,9 +893,9 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
||||
binding.swipeRefreshLayout.isRefreshing = true
|
||||
repository.displayedItems = itemType
|
||||
items = if (appendResults) {
|
||||
repository.getNewerItems()
|
||||
} else {
|
||||
repository.getOlderItems()
|
||||
} else {
|
||||
repository.getNewerItems()
|
||||
}
|
||||
binding.swipeRefreshLayout.isRefreshing = false
|
||||
handleListResult()
|
||||
|
@ -83,8 +83,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
||||
private fun appendItems(fetchedItems: List<SelfossModel.Item>) {
|
||||
// TODO: Store in DB if enabled by user
|
||||
val fetchedIDS = fetchedItems.map { it.id }
|
||||
val tmpItems = items
|
||||
tmpItems.removeAll{ it.id in fetchedIDS }
|
||||
val tmpItems = ArrayList(items.filterNot { it.id in fetchedIDS })
|
||||
tmpItems.addAll(fetchedItems)
|
||||
sortItems(tmpItems)
|
||||
items = tmpItems
|
||||
|
Loading…
Reference in New Issue
Block a user