Refactor ListModel

This commit is contained in:
Koitharu
2023-07-03 13:57:51 +03:00
parent 80db817ff2
commit 942d4fe5ab
67 changed files with 671 additions and 715 deletions

View File

@@ -10,6 +10,10 @@ class ScrobblerManga(
val url: String,
) : ListModel {
override fun areItemsTheSame(other: ListModel): Boolean {
return other is ScrobblerManga && other.id == id
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

View File

@@ -16,6 +16,10 @@ class ScrobblingInfo(
val externalUrl: String,
) : ListModel {
override fun areItemsTheSame(other: ListModel): Boolean {
return other is ScrobblingInfo && other.scrobbler == scrobbler
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

View File

@@ -4,10 +4,9 @@ import org.koitharu.kotatsu.list.ui.model.ListModel
enum class ScrobblingStatus : ListModel {
PLANNED,
READING,
RE_READING,
COMPLETED,
ON_HOLD,
DROPPED,
PLANNED, READING, RE_READING, COMPLETED, ON_HOLD, DROPPED;
override fun areItemsTheSame(other: ListModel): Boolean {
return other is ScrobblingStatus && other.ordinal == ordinal
}
}

View File

@@ -12,6 +12,10 @@ class ScrobblerHint(
@StringRes val actionStringRes: Int,
) : ListModel {
override fun areItemsTheSame(other: ListModel): Boolean {
return other is ScrobblerHint && other.textPrimary == textPrimary
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
@@ -22,9 +26,7 @@ class ScrobblerHint(
if (textPrimary != other.textPrimary) return false
if (textSecondary != other.textSecondary) return false
if (error != other.error) return false
if (actionStringRes != other.actionStringRes) return false
return true
return actionStringRes == other.actionStringRes
}
override fun hashCode(): Int {