Minor code consistency change
This commit is contained in:
parent
9fbf6fa581
commit
89f378b973
|
@ -257,7 +257,7 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
cachedConversations.forEach { cachedConv ->
|
||||
val conv = conversations.find { it.threadId == cachedConv.threadId && !cachedConv.areContentsTheSame(it) }
|
||||
val conv = conversations.find { it.threadId == cachedConv.threadId && !Conversation.areContentsTheSame(cachedConv, it) }
|
||||
if (conv != null) {
|
||||
val conversation = conv.copy(date = maxOf(cachedConv.date, conv.date))
|
||||
conversationsDB.insertOrUpdate(conversation)
|
||||
|
|
|
@ -374,11 +374,11 @@ class ConversationsAdapter(
|
|||
|
||||
private class ConversationDiffCallback : DiffUtil.ItemCallback<Conversation>() {
|
||||
override fun areItemsTheSame(oldItem: Conversation, newItem: Conversation): Boolean {
|
||||
return oldItem.areItemsTheSame(newItem)
|
||||
return Conversation.areItemsTheSame(oldItem, newItem)
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: Conversation, newItem: Conversation): Boolean {
|
||||
return oldItem.areContentsTheSame(newItem)
|
||||
return Conversation.areContentsTheSame(oldItem, newItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,17 +18,19 @@ data class Conversation(
|
|||
@ColumnInfo(name = "is_scheduled") var isScheduled: Boolean = false
|
||||
) {
|
||||
|
||||
fun areItemsTheSame(other: Conversation): Boolean {
|
||||
return threadId == other.threadId
|
||||
companion object {
|
||||
fun areItemsTheSame(old: Conversation, new: Conversation): Boolean {
|
||||
return old.threadId == new.threadId
|
||||
}
|
||||
|
||||
fun areContentsTheSame(other: Conversation): Boolean {
|
||||
return snippet == other.snippet &&
|
||||
date == other.date &&
|
||||
read == other.read &&
|
||||
title == other.title &&
|
||||
photoUri == other.photoUri &&
|
||||
isGroupConversation == other.isGroupConversation &&
|
||||
phoneNumber == other.phoneNumber
|
||||
fun areContentsTheSame(old: Conversation, new: Conversation): Boolean {
|
||||
return old.snippet == new.snippet &&
|
||||
old.date == new.date &&
|
||||
old.read == new.read &&
|
||||
old.title == new.title &&
|
||||
old.photoUri == new.photoUri &&
|
||||
old.isGroupConversation == new.isGroupConversation &&
|
||||
old.phoneNumber == new.phoneNumber
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue