Update bad calculation of content size for stories collection.
This commit is contained in:
parent
457c3c0526
commit
2a82db2b02
2 changed files with 4 additions and 1 deletions
|
@ -16,7 +16,7 @@ open class ContactSearchCollection<ContactRecord>(
|
||||||
private val activeContactCount: Int
|
private val activeContactCount: Int
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val contentSize: Int = if (recordPredicate != null) {
|
protected open val contentSize: Int = if (recordPredicate != null) {
|
||||||
records.asSequence().filter(recordPredicate).count()
|
records.asSequence().filter(recordPredicate).count()
|
||||||
} else {
|
} else {
|
||||||
records.getCount()
|
records.getCount()
|
||||||
|
|
|
@ -14,6 +14,7 @@ class StoriesSearchCollection<ContactRecord>(
|
||||||
activeContactCount: Int,
|
activeContactCount: Int,
|
||||||
private val storyComparator: Comparator<ContactSearchData.Story>
|
private val storyComparator: Comparator<ContactSearchData.Story>
|
||||||
) : ContactSearchCollection<ContactRecord>(section, records, null, recordMapper, activeContactCount) {
|
) : ContactSearchCollection<ContactRecord>(section, records, null, recordMapper, activeContactCount) {
|
||||||
|
|
||||||
private val aggregateStoryData: List<ContactSearchData.Story> by lazy {
|
private val aggregateStoryData: List<ContactSearchData.Story> by lazy {
|
||||||
if (section !is ContactSearchConfiguration.Section.Stories) {
|
if (section !is ContactSearchConfiguration.Section.Stories) {
|
||||||
error("Aggregate data creation is only necessary for stories.")
|
error("Aggregate data creation is only necessary for stories.")
|
||||||
|
@ -24,6 +25,8 @@ class StoriesSearchCollection<ContactRecord>(
|
||||||
(cursorContacts + extraData).filterIsInstance(ContactSearchData.Story::class.java).sortedWith(storyComparator)
|
(cursorContacts + extraData).filterIsInstance(ContactSearchData.Story::class.java).sortedWith(storyComparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val contentSize: Int = records.getCount() + extraData.size
|
||||||
|
|
||||||
override fun getItemAtCorrectedIndex(correctedIndex: Int): ContactSearchData {
|
override fun getItemAtCorrectedIndex(correctedIndex: Int): ContactSearchData {
|
||||||
return aggregateStoryData[correctedIndex]
|
return aggregateStoryData[correctedIndex]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue