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
|
binding.swipeRefreshLayout.isRefreshing = true
|
||||||
repository.displayedItems = itemType
|
repository.displayedItems = itemType
|
||||||
items = if (appendResults) {
|
items = if (appendResults) {
|
||||||
repository.getNewerItems()
|
|
||||||
} else {
|
|
||||||
repository.getOlderItems()
|
repository.getOlderItems()
|
||||||
|
} else {
|
||||||
|
repository.getNewerItems()
|
||||||
}
|
}
|
||||||
binding.swipeRefreshLayout.isRefreshing = false
|
binding.swipeRefreshLayout.isRefreshing = false
|
||||||
handleListResult()
|
handleListResult()
|
||||||
|
@ -83,8 +83,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
private fun appendItems(fetchedItems: List<SelfossModel.Item>) {
|
private fun appendItems(fetchedItems: List<SelfossModel.Item>) {
|
||||||
// TODO: Store in DB if enabled by user
|
// TODO: Store in DB if enabled by user
|
||||||
val fetchedIDS = fetchedItems.map { it.id }
|
val fetchedIDS = fetchedItems.map { it.id }
|
||||||
val tmpItems = items
|
val tmpItems = ArrayList(items.filterNot { it.id in fetchedIDS })
|
||||||
tmpItems.removeAll{ it.id in fetchedIDS }
|
|
||||||
tmpItems.addAll(fetchedItems)
|
tmpItems.addAll(fetchedItems)
|
||||||
sortItems(tmpItems)
|
sortItems(tmpItems)
|
||||||
items = tmpItems
|
items = tmpItems
|
||||||
|
Loading…
Reference in New Issue
Block a user