mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-01-30 17:14:55 +01:00
Enable stable ids again
now we have stable ids, sorta
This commit is contained in:
parent
4295e5cf55
commit
6cc8277694
@ -67,6 +67,7 @@ class ThreadAdapter(
|
||||
|
||||
init {
|
||||
setupDragListener(true)
|
||||
setHasStableIds(true)
|
||||
}
|
||||
|
||||
override fun getActionMenuId() = R.menu.cab_thread
|
||||
@ -142,6 +143,13 @@ class ThreadAdapter(
|
||||
bindViewHolder(holder)
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return when (val item = getItem(position)) {
|
||||
is Message -> Message.getStableId(item)
|
||||
else -> item.hashCode().toLong()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return when (val item = getItem(position)) {
|
||||
is ThreadLoading -> THREAD_LOADING
|
||||
|
@ -29,6 +29,20 @@ data class Message(
|
||||
fun millis() = date * 1000L
|
||||
|
||||
companion object {
|
||||
|
||||
fun getStableId(message: Message): Long {
|
||||
var result = message.id.hashCode()
|
||||
result = 31 * result + message.body.hashCode()
|
||||
result = 32 * result + message.date.hashCode()
|
||||
result = 31 * result + message.threadId.hashCode()
|
||||
result = 31 * result + message.isMMS.hashCode()
|
||||
result = 31 * result + (message.attachment?.hashCode() ?: 0)
|
||||
result = 31 * result + message.senderName.hashCode()
|
||||
result = 31 * result + message.senderPhotoUri.hashCode()
|
||||
result = 31 * result + message.isScheduled.hashCode()
|
||||
return result.toLong()
|
||||
}
|
||||
|
||||
fun areItemsTheSame(old: Message, new: Message): Boolean {
|
||||
return old.id == new.id
|
||||
}
|
||||
@ -36,6 +50,7 @@ data class Message(
|
||||
fun areContentsTheSame(old: Message, new: Message): Boolean {
|
||||
return old.body == new.body &&
|
||||
old.threadId == new.threadId &&
|
||||
old.date == new.date &&
|
||||
old.isMMS == new.isMMS &&
|
||||
old.attachment == new.attachment &&
|
||||
old.senderName == new.senderName &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user