mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-01-31 17:44:46 +01:00
tweak the way adapters are updated
This commit is contained in:
parent
9c0ef0fbe9
commit
b02b54b055
@ -209,10 +209,11 @@ class ConversationsAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateConversations(newConversations: ArrayList<Conversation>) {
|
fun updateConversations(newConversations: ArrayList<Conversation>) {
|
||||||
|
val latestConversations = newConversations.clone() as ArrayList<Conversation>
|
||||||
val oldHashCode = conversations.hashCode()
|
val oldHashCode = conversations.hashCode()
|
||||||
val newHashCode = newConversations.hashCode()
|
val newHashCode = latestConversations.hashCode()
|
||||||
if (newHashCode != oldHashCode) {
|
if (newHashCode != oldHashCode) {
|
||||||
conversations = newConversations
|
conversations = latestConversations
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,10 +201,11 @@ class ThreadAdapter(
|
|||||||
private fun isThreadDateTime(position: Int) = messages.getOrNull(position) is ThreadDateTime
|
private fun isThreadDateTime(position: Int) = messages.getOrNull(position) is ThreadDateTime
|
||||||
|
|
||||||
fun updateMessages(newMessages: ArrayList<ThreadItem>) {
|
fun updateMessages(newMessages: ArrayList<ThreadItem>) {
|
||||||
|
val latestMessages = newMessages.clone() as ArrayList<ThreadItem>
|
||||||
val oldHashCode = messages.hashCode()
|
val oldHashCode = messages.hashCode()
|
||||||
val newHashCode = newMessages.hashCode()
|
val newHashCode = latestMessages.hashCode()
|
||||||
if (newHashCode != oldHashCode) {
|
if (newHashCode != oldHashCode) {
|
||||||
messages = newMessages
|
messages = latestMessages
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
recyclerView.scrollToPosition(messages.size - 1)
|
recyclerView.scrollToPosition(messages.size - 1)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user