@@ -31,6 +31,7 @@ import org.thoughtcrime.securesms.database.CursorRecyclerViewAdapter
31
31
import org.thoughtcrime.securesms.database.model.MessageId
32
32
import org.thoughtcrime.securesms.database.model.MessageRecord
33
33
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
34
+ import java.util.concurrent.ConcurrentHashMap
34
35
import kotlin.math.max
35
36
36
37
class ConversationAdapter (
@@ -56,8 +57,8 @@ class ConversationAdapter(
56
57
var visibleMessageViewDelegate: VisibleMessageViewDelegate ? = null
57
58
58
59
private val updateQueue = Channel <String >(1024 , onBufferOverflow = BufferOverflow .DROP_OLDEST )
59
- private val contactCache = SparseArray < Contact >(100 )
60
- private val contactLoadedCache = SparseBooleanArray (100 )
60
+ private val contactCache = ConcurrentHashMap < String , Contact >(100 )
61
+ private val contactLoadedCache = ConcurrentHashMap < String , Boolean > (100 )
61
62
private val lastSeen = AtomicLong (originalLastSeen)
62
63
63
64
var lastSentMessageId: MessageId ? = null
@@ -79,8 +80,8 @@ class ConversationAdapter(
79
80
while (isActive) {
80
81
val item = updateQueue.receive()
81
82
val contact = getSenderInfo(item) ? : continue
82
- contactCache[item.hashCode() ] = contact
83
- contactLoadedCache[item.hashCode() ] = true
83
+ contactCache[item] = contact
84
+ contactLoadedCache[item] = true
84
85
}
85
86
}
86
87
}
@@ -131,18 +132,17 @@ class ConversationAdapter(
131
132
visibleMessageView.snIsSelected = isSelected
132
133
visibleMessageView.indexInAdapter = position
133
134
val senderId = message.individualRecipient.address.toString()
134
- val senderIdHash = senderId.hashCode()
135
135
updateQueue.trySend(senderId)
136
- if (contactCache[senderIdHash ] == null && ! contactLoadedCache.getOrDefault(
137
- senderIdHash ,
136
+ if (contactCache[senderId ] == null && ! contactLoadedCache.getOrDefault(
137
+ senderId ,
138
138
false
139
139
)
140
140
) {
141
141
getSenderInfo(senderId)?.let { contact ->
142
- contactCache[senderIdHash ] = contact
142
+ contactCache[senderId ] = contact
143
143
}
144
144
}
145
- val contact = contactCache[senderIdHash ]
145
+ val contact = contactCache[senderId ]
146
146
val isExpanded = expandedMessageIds.contains(message.messageId)
147
147
148
148
visibleMessageView.bind(
0 commit comments