LibraryItem: Fix equality check (#7999)

Proper equality check is needed by compose for state changes.

(cherry picked from commit 7270c48f26bf61780aca5f588c742839fd3e9c2f)
This commit is contained in:
Ivan Iskandar 2022-09-12 23:29:28 +07:00 committed by Jobobby04
parent 3e6a7b666b
commit 2f7a8d0505

View File

@ -71,13 +71,30 @@ class LibraryItem(
}
override fun equals(other: Any?): Boolean {
if (other is LibraryItem) {
return manga.id == other.manga.id
}
return false
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as LibraryItem
if (manga != other.manga) return false
if (sourceManager != other.sourceManager) return false
if (displayMode != other.displayMode) return false
if (downloadCount != other.downloadCount) return false
if (unreadCount != other.unreadCount) return false
if (isLocal != other.isLocal) return false
if (sourceLanguage != other.sourceLanguage) return false
return true
}
override fun hashCode(): Int {
return manga.id!!.hashCode()
var result = manga.hashCode()
result = 31 * result + sourceManager.hashCode()
result = 31 * result + displayMode.hashCode()
result = 31 * result + downloadCount
result = 31 * result + unreadCount
result = 31 * result + isLocal.hashCode()
result = 31 * result + sourceLanguage.hashCode()
return result
}
}