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

@@ -1,6 +1,7 @@
package org.koitharu.kotatsu.settings.storage
import androidx.annotation.StringRes
import org.koitharu.kotatsu.list.ui.ListModelDiffCallback
import org.koitharu.kotatsu.list.ui.model.ListModel
import java.io.File
@@ -12,6 +13,18 @@ class DirectoryModel(
val isAvailable: Boolean,
) : ListModel {
override fun areItemsTheSame(other: ListModel): Boolean {
return other is DirectoryModel && other.file == file && other.title == title && other.titleRes == titleRes
}
override fun getChangePayload(previousState: ListModel): Any? {
return if (previousState is DirectoryModel && previousState.isChecked != isChecked) {
ListModelDiffCallback.PAYLOAD_CHECKED_CHANGED
} else {
super.getChangePayload(previousState)
}
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false