From 2fb2be2dd556f078b2227d63524d3919bf1868e4 Mon Sep 17 00:00:00 2001 From: Rayyan <52076121+rlam20@users.noreply.github.com> Date: Tue, 2 Jul 2024 10:21:41 -0400 Subject: [PATCH] update chatHistory --- .../myplanet/ui/chat/ChatHistoryListAdapter.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/chat/ChatHistoryListAdapter.kt b/app/src/main/java/org/ole/planet/myplanet/ui/chat/ChatHistoryListAdapter.kt index bc249ab60b..8026674585 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/chat/ChatHistoryListAdapter.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/chat/ChatHistoryListAdapter.kt @@ -77,9 +77,23 @@ class ChatHistoryListAdapter(var context: Context, private var chatHistory: List } fun updateChatHistory(newChatHistory: List) { + val oldListSize = chatHistory.size + val newListSize = newChatHistory.size chatHistory = newChatHistory filteredChatHistory = newChatHistory - notifyDataSetChanged() + if(oldListSizenewListSize){ + notifyItemRangeRemoved(newListSize,oldListSize-newListSize) + } + else{ + for(i in 0 until newListSize){ + if(chatHistory[i] != newChatHistory[i]){ + notifyItemChanged(i) + } + } + } } override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {