Merge pull request #470 from Isira-Seneviratne/Data_classes
This commit is contained in:
@@ -5,14 +5,13 @@ import org.koitharu.kotatsu.list.ui.ListModelDiffCallback
|
||||
import org.koitharu.kotatsu.list.ui.model.ListModel
|
||||
import java.io.File
|
||||
|
||||
class DirectoryModel(
|
||||
data class DirectoryModel(
|
||||
val title: String?,
|
||||
@StringRes val titleRes: Int,
|
||||
val file: File?,
|
||||
val isChecked: Boolean,
|
||||
val isAvailable: Boolean,
|
||||
) : ListModel {
|
||||
|
||||
override fun areItemsTheSame(other: ListModel): Boolean {
|
||||
return other is DirectoryModel && other.file == file && other.title == title && other.titleRes == titleRes
|
||||
}
|
||||
@@ -24,26 +23,4 @@ class DirectoryModel(
|
||||
super.getChangePayload(previousState)
|
||||
}
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as DirectoryModel
|
||||
|
||||
if (title != other.title) return false
|
||||
if (titleRes != other.titleRes) return false
|
||||
if (file != other.file) return false
|
||||
if (isChecked != other.isChecked) return false
|
||||
return isAvailable == other.isAvailable
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = title?.hashCode() ?: 0
|
||||
result = 31 * result + titleRes
|
||||
result = 31 * result + (file?.hashCode() ?: 0)
|
||||
result = 31 * result + isChecked.hashCode()
|
||||
result = 31 * result + isAvailable.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,13 @@
|
||||
package org.koitharu.kotatsu.settings.userdata
|
||||
|
||||
class StorageUsage(
|
||||
data class StorageUsage(
|
||||
val savedManga: Item,
|
||||
val pagesCache: Item,
|
||||
val otherCache: Item,
|
||||
val available: Item,
|
||||
) {
|
||||
|
||||
class Item(
|
||||
data class Item(
|
||||
val bytes: Long,
|
||||
val percent: Float,
|
||||
) {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Item
|
||||
|
||||
if (bytes != other.bytes) return false
|
||||
return percent == other.percent
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = bytes.hashCode()
|
||||
result = 31 * result + percent.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as StorageUsage
|
||||
|
||||
if (savedManga != other.savedManga) return false
|
||||
if (pagesCache != other.pagesCache) return false
|
||||
if (otherCache != other.otherCache) return false
|
||||
return available == other.available
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = savedManga.hashCode()
|
||||
result = 31 * result + pagesCache.hashCode()
|
||||
result = 31 * result + otherCache.hashCode()
|
||||
result = 31 * result + available.hashCode()
|
||||
return result
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user