Improved a bit chat room diff callback
This commit is contained in:
parent
cbacb97f9d
commit
5fac97b55d
2 changed files with 8 additions and 2 deletions
|
@ -33,6 +33,7 @@ import org.linphone.activities.main.viewmodels.ListTopBarViewModel
|
|||
import org.linphone.core.ChatRoom
|
||||
import org.linphone.databinding.ChatRoomListCellBinding
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class ChatRoomsListAdapter(
|
||||
selectionVM: ListTopBarViewModel,
|
||||
|
@ -108,13 +109,13 @@ private class ChatRoomDiffCallback : DiffUtil.ItemCallback<ChatRoomViewModel>()
|
|||
oldItem: ChatRoomViewModel,
|
||||
newItem: ChatRoomViewModel
|
||||
): Boolean {
|
||||
return oldItem.chatRoom == newItem.chatRoom
|
||||
return LinphoneUtils.areChatRoomsTheSame(oldItem.chatRoom, newItem.chatRoom)
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(
|
||||
oldItem: ChatRoomViewModel,
|
||||
newItem: ChatRoomViewModel
|
||||
): Boolean {
|
||||
return false // To force redraw when contacts are updated
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,6 +210,11 @@ class LinphoneUtils {
|
|||
)
|
||||
}
|
||||
|
||||
fun areChatRoomsTheSame(chatRoom1: ChatRoom, chatRoom2: ChatRoom): Boolean {
|
||||
return chatRoom1.localAddress.weakEqual(chatRoom2.localAddress) &&
|
||||
chatRoom1.peerAddress.weakEqual(chatRoom2.peerAddress)
|
||||
}
|
||||
|
||||
fun getChatRoomId(localAddress: Address, remoteAddress: Address): String {
|
||||
val localSipUri = localAddress.clone()
|
||||
localSipUri.clean()
|
||||
|
|
Loading…
Reference in a new issue