mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-19 10:45:13 +01:00
Fix headers & footers for search
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
6fa059919f
commit
cc103ebc9c
@ -43,6 +43,7 @@ class ContactsViewFooterSource(private val context: Context, private val element
|
|||||||
override fun getElementType(data: Data<Participant, String>) = elementType
|
override fun getElementType(data: Data<Participant, String>) = elementType
|
||||||
|
|
||||||
override fun computeFooters(page: Page, list: List<Participant>): List<Data<Participant, String>> {
|
override fun computeFooters(page: Page, list: List<Participant>): List<Data<Participant, String>> {
|
||||||
|
lastAnchor = null
|
||||||
val results = arrayListOf<Data<Participant, String>>()
|
val results = arrayListOf<Data<Participant, String>>()
|
||||||
lastAnchor = if (list.isNotEmpty()) {
|
lastAnchor = if (list.isNotEmpty()) {
|
||||||
val participant = list.takeLast(1)[0]
|
val participant = list.takeLast(1)[0]
|
||||||
|
@ -32,12 +32,13 @@ import com.otaliastudios.elements.extensions.HeaderSource
|
|||||||
class ContactsHeaderSource(private val context: Context, private val elementType: Int) : HeaderSource<Participant, String>() {
|
class ContactsHeaderSource(private val context: Context, private val elementType: Int) : HeaderSource<Participant, String>() {
|
||||||
|
|
||||||
// Store the last header that was added, even if it belongs to a previous page.
|
// Store the last header that was added, even if it belongs to a previous page.
|
||||||
private var lastHeader: String = ""
|
private var headersAlreadyAdded = mutableListOf<String>()
|
||||||
|
|
||||||
override fun dependsOn(source: Source<*>) = source is ContactsViewSource
|
override fun dependsOn(source: Source<*>) = source is ContactsViewSource
|
||||||
|
|
||||||
override fun computeHeaders(page: Page, list: List<Participant>): List<Data<Participant, String>> {
|
override fun computeHeaders(page: Page, list: List<Participant>): List<Data<Participant, String>> {
|
||||||
val results = arrayListOf<Data<Participant, String>>()
|
val results = arrayListOf<Data<Participant, String>>()
|
||||||
|
headersAlreadyAdded = mutableListOf()
|
||||||
for (participant in list) {
|
for (participant in list) {
|
||||||
val header = when (participant.source) {
|
val header = when (participant.source) {
|
||||||
"users" -> {
|
"users" -> {
|
||||||
@ -57,9 +58,9 @@ class ContactsHeaderSource(private val context: Context, private val elementType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header != lastHeader) {
|
if (!headersAlreadyAdded.contains(header)) {
|
||||||
results.add(Data(participant, header))
|
results.add(Data(participant, header))
|
||||||
lastHeader = header
|
headersAlreadyAdded.add(header)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user