From b02b54b0551ab5a37b6cd55976df5f2b7154650a Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 23 May 2021 17:53:18 +0200 Subject: [PATCH] tweak the way adapters are updated --- .../smsmessenger/adapters/ConversationsAdapter.kt | 5 +++-- .../simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ConversationsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ConversationsAdapter.kt index 07f8b70b..c895ea85 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ConversationsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ConversationsAdapter.kt @@ -209,10 +209,11 @@ class ConversationsAdapter( } fun updateConversations(newConversations: ArrayList) { + val latestConversations = newConversations.clone() as ArrayList val oldHashCode = conversations.hashCode() - val newHashCode = newConversations.hashCode() + val newHashCode = latestConversations.hashCode() if (newHashCode != oldHashCode) { - conversations = newConversations + conversations = latestConversations notifyDataSetChanged() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt index 18f513e2..1aead4e9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt @@ -201,10 +201,11 @@ class ThreadAdapter( private fun isThreadDateTime(position: Int) = messages.getOrNull(position) is ThreadDateTime fun updateMessages(newMessages: ArrayList) { + val latestMessages = newMessages.clone() as ArrayList val oldHashCode = messages.hashCode() - val newHashCode = newMessages.hashCode() + val newHashCode = latestMessages.hashCode() if (newHashCode != oldHashCode) { - messages = newMessages + messages = latestMessages notifyDataSetChanged() recyclerView.scrollToPosition(messages.size - 1) }