lots of background work for manga extensions
This commit is contained in:
parent
dbe573131e
commit
57a584a820
123 changed files with 2676 additions and 553 deletions
|
@ -0,0 +1,18 @@
|
|||
package tachiyomi.domain.category.model
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
data class Category(
|
||||
val id: Long,
|
||||
val name: String,
|
||||
val order: Long,
|
||||
val flags: Long,
|
||||
val hidden: Boolean,
|
||||
) : Serializable {
|
||||
|
||||
val isSystemCategory: Boolean = id == UNCATEGORIZED_ID
|
||||
|
||||
companion object {
|
||||
const val UNCATEGORIZED_ID = 0L
|
||||
}
|
||||
}
|
35
app/src/main/java/tachiyomi/domain/library/model/Flag.kt
Normal file
35
app/src/main/java/tachiyomi/domain/library/model/Flag.kt
Normal file
|
@ -0,0 +1,35 @@
|
|||
package tachiyomi.domain.library.model
|
||||
|
||||
interface Flag {
|
||||
val flag: Long
|
||||
}
|
||||
|
||||
interface Mask {
|
||||
val mask: Long
|
||||
}
|
||||
|
||||
interface FlagWithMask : Flag, Mask
|
||||
|
||||
operator fun Long.contains(other: Flag): Boolean {
|
||||
return if (other is Mask) {
|
||||
other.flag == this and other.mask
|
||||
} else {
|
||||
other.flag == this
|
||||
}
|
||||
}
|
||||
|
||||
operator fun Long.plus(other: Flag): Long {
|
||||
return if (other is Mask) {
|
||||
this and other.mask.inv() or (other.flag and other.mask)
|
||||
} else {
|
||||
this or other.flag
|
||||
}
|
||||
}
|
||||
|
||||
operator fun Flag.plus(other: Flag): Long {
|
||||
return if (other is Mask) {
|
||||
this.flag and other.mask.inv() or (other.flag and other.mask)
|
||||
} else {
|
||||
this.flag or other.flag
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package tachiyomi.domain.library.model
|
||||
|
||||
import tachiyomi.domain.category.model.Category
|
||||
|
||||
sealed class LibraryDisplayMode(
|
||||
override val flag: Long,
|
||||
) : FlagWithMask {
|
||||
|
||||
override val mask: Long = 0b00000011L
|
||||
|
||||
object CompactGrid : LibraryDisplayMode(0b00000000)
|
||||
object ComfortableGrid : LibraryDisplayMode(0b00000001)
|
||||
object List : LibraryDisplayMode(0b00000010)
|
||||
object CoverOnlyGrid : LibraryDisplayMode(0b00000011)
|
||||
|
||||
object Serializer {
|
||||
fun deserialize(serialized: String): LibraryDisplayMode {
|
||||
return Companion.deserialize(serialized)
|
||||
}
|
||||
|
||||
fun serialize(value: LibraryDisplayMode): String {
|
||||
return value.serialize()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val values by lazy { setOf(CompactGrid, ComfortableGrid, List, CoverOnlyGrid) }
|
||||
val default = CompactGrid
|
||||
|
||||
fun valueOf(flag: Long?): LibraryDisplayMode {
|
||||
if (flag == null) return default
|
||||
return values
|
||||
.find { mode -> mode.flag == flag and mode.mask }
|
||||
?: default
|
||||
}
|
||||
|
||||
fun deserialize(serialized: String): LibraryDisplayMode {
|
||||
return when (serialized) {
|
||||
"COMFORTABLE_GRID" -> ComfortableGrid
|
||||
"COMPACT_GRID" -> CompactGrid
|
||||
"COVER_ONLY_GRID" -> CoverOnlyGrid
|
||||
"LIST" -> List
|
||||
else -> default
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun serialize(): String {
|
||||
return when (this) {
|
||||
ComfortableGrid -> "COMFORTABLE_GRID"
|
||||
CompactGrid -> "COMPACT_GRID"
|
||||
CoverOnlyGrid -> "COVER_ONLY_GRID"
|
||||
List -> "LIST"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val Category?.display: LibraryDisplayMode
|
||||
get() = LibraryDisplayMode.valueOf(this?.flags)
|
|
@ -0,0 +1,10 @@
|
|||
package tachiyomi.domain.source.anime.model
|
||||
|
||||
data class AnimeSourceData(
|
||||
val id: Long,
|
||||
val lang: String,
|
||||
val name: String,
|
||||
) {
|
||||
|
||||
val isMissingInfo: Boolean = name.isBlank() || lang.isBlank()
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package tachiyomi.domain.source.manga.model
|
||||
|
||||
data class MangaSourceData(
|
||||
val id: Long,
|
||||
val lang: String,
|
||||
val name: String,
|
||||
) {
|
||||
|
||||
val isMissingInfo: Boolean = name.isBlank() || lang.isBlank()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue