Nat Strangerweather
08/04/2023, 10:21 AMResultsChips
for each headline? I understand why I am getting this result (because of the loops), but I have no idea how to resolve it. 🧵Nat Strangerweather
08/04/2023, 10:22 AMval dateTimeFormatter: DateTimeFormatter =
DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss O yyyy")
items(newsFeeds?.sortedByDescending {item->
LocalDateTime.parse(item.feedItem.pubDate, dateTimeFormatter)
}?.filter { it.feedTitle == title } ?: emptyList()) { item ->
ResultsChip(item.id, item.feedItem.title, navController)
}
Joffrey
08/04/2023, 10:28 AMitems()
look like (once sorted and filtered)?
Also, what's the difference between item.feedTitle
and item.feedItem.title
? If they are the same, what would you expect to look different in the ResultsChip
?Joffrey
08/04/2023, 10:30 AMNat Strangerweather
08/04/2023, 10:31 AMitem->
twice. Yes, it's a Compose list.Nat Strangerweather
08/04/2023, 10:31 AMNat Strangerweather
08/04/2023, 10:32 AMJoffrey
08/04/2023, 10:32 AMNat Strangerweather
08/04/2023, 10:33 AMNat Strangerweather
08/04/2023, 10:33 AMNat Strangerweather
08/04/2023, 10:34 AMitems(newsFeeds?.filter { it.feedTitle == title } ?: emptyList()) { item ->
ResultsChip(item.id, item.feedItem.title, navController)
}
Nat Strangerweather
08/04/2023, 10:34 AMJoffrey
08/04/2023, 10:37 AMitems()
parameter. It will be a bit clearer and will also allow to print the list for debugging, or put a breakpoint more easily. What does the list look like before and after sorting? What about after filtering?Joffrey
08/04/2023, 10:38 AMNat Strangerweather
08/04/2023, 10:39 AMNat Strangerweather
08/04/2023, 10:40 AMJoffrey
08/04/2023, 10:41 AMResultsChip
you're describing? (what titles, what dates, what's the size of the list, before filtering, after filtering, this kind of things). Did you look at this when debugging?Joffrey
08/04/2023, 10:44 AMUntil I add the sorting code, all works fineDoes it work fine again when you remove the sorting code and go back to just filtering? Are you sure the dupicates are not just farther apart, and you just don't notice them?
Nat Strangerweather
08/04/2023, 10:45 AMNat Strangerweather
08/04/2023, 10:46 AMNat Strangerweather
08/04/2023, 10:46 AMJoffrey
08/04/2023, 10:46 AMThis is what my room database looks likeThat is just a tiny extract, though. Or does the whole table only contain items 55-64?
Nat Strangerweather
08/04/2023, 10:46 AMNat Strangerweather
08/04/2023, 10:47 AMNat Strangerweather
08/04/2023, 10:48 AMJoffrey
08/04/2023, 10:50 AMsortingByDescending
cannot add elements to the list, so if you see duplicates eventually, they must have been there originally. Sorting does bring duplicates next to each other, making the duplication more obvious in long lists. So I believe if you see duplicate chips, and you want to be sure there are no duplicates in DB, you should run a query with the duplicate title from the chips and see how many results you find in DBNat Strangerweather
08/04/2023, 10:51 AMJoffrey
08/04/2023, 10:52 AMNat Strangerweather
08/04/2023, 10:52 AMNat Strangerweather
08/04/2023, 10:53 AMNat Strangerweather
08/04/2023, 10:53 AMJoffrey
08/04/2023, 10:53 AMNat Strangerweather
08/04/2023, 11:01 AMJoffrey
08/04/2023, 11:01 AMJoffrey
08/04/2023, 11:03 AMNat Strangerweather
08/04/2023, 11:04 AMxoangon
08/04/2023, 7:00 PMremember
blocks for performance reasons
• If you’re using DB models in Compose, those may all be unstable and lead to a whole lot of recompositions on scrolling
If you want more information on this, we can continue this topic by DMNat Strangerweather
08/04/2023, 7:42 PM