avoid fetching event attendees on the main thread

This commit is contained in:
tibbi 2020-11-03 17:36:30 +01:00
parent 499cf50c4c
commit 711a26dbfc

View file

@ -528,9 +528,7 @@ class EventActivity : SimpleActivity() {
private fun checkAttendees() { private fun checkAttendees() {
ensureBackgroundThread { ensureBackgroundThread {
fillAvailableContacts() fillAvailableContacts()
runOnUiThread { updateAttendees()
updateAttendees()
}
} }
} }
@ -1357,22 +1355,24 @@ class EventActivity : SimpleActivity() {
{ it.status }) { it.status })
mAttendees.reverse() mAttendees.reverse()
mAttendees.forEach { runOnUiThread {
val attendee = it mAttendees.forEach {
val deviceContact = mAvailableContacts.firstOrNull { it.email.isNotEmpty() && it.email == attendee.email && it.photoUri.isNotEmpty() } val attendee = it
if (deviceContact != null) { val deviceContact = mAvailableContacts.firstOrNull { it.email.isNotEmpty() && it.email == attendee.email && it.photoUri.isNotEmpty() }
attendee.photoUri = deviceContact.photoUri if (deviceContact != null) {
attendee.photoUri = deviceContact.photoUri
}
addAttendee(attendee)
} }
addAttendee(attendee) addAttendee()
}
addAttendee()
val imageHeight = event_repetition_image.height val imageHeight = event_repetition_image.height
if (imageHeight > 0) { if (imageHeight > 0) {
event_attendees_image.layoutParams.height = imageHeight event_attendees_image.layoutParams.height = imageHeight
} else { } else {
event_repetition_image.onGlobalLayout { event_repetition_image.onGlobalLayout {
event_attendees_image.layoutParams.height = event_repetition_image.height event_attendees_image.layoutParams.height = event_repetition_image.height
}
} }
} }
} }