mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 02:34:39 +00:00
chore: More domain module Manga prep
This commit is contained in:
parent
f94e69cdf8
commit
de48b52ec3
6 changed files with 39 additions and 7 deletions
|
@ -145,6 +145,7 @@ android {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(projects.core)
|
implementation(projects.core)
|
||||||
implementation(projects.data)
|
implementation(projects.data)
|
||||||
|
implementation(projects.domain)
|
||||||
implementation(projects.i18n)
|
implementation(projects.i18n)
|
||||||
implementation(projects.presentation.core)
|
implementation(projects.presentation.core)
|
||||||
implementation(projects.sourceApi)
|
implementation(projects.sourceApi)
|
||||||
|
|
|
@ -146,11 +146,6 @@ interface Manga : SManga {
|
||||||
).lowercase(Locale.getDefault())
|
).lowercase(Locale.getDefault())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getGenres(): List<String>? {
|
|
||||||
return genre?.split(",")
|
|
||||||
?.mapNotNull { tag -> tag.trim().takeUnless { it.isBlank() } }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getOriginalGenres(): List<String>? {
|
fun getOriginalGenres(): List<String>? {
|
||||||
return (originalGenre ?: genre)?.split(",")
|
return (originalGenre ?: genre)?.split(",")
|
||||||
?.mapNotNull { tag -> tag.trim().takeUnless { it.isBlank() } }
|
?.mapNotNull { tag -> tag.trim().takeUnless { it.isBlank() } }
|
||||||
|
|
31
app/src/main/java/yokai/data/manga/models/MangaExtensions.kt
Normal file
31
app/src/main/java/yokai/data/manga/models/MangaExtensions.kt
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package yokai.data.manga.models
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
|
import yokai.domain.manga.models.Manga
|
||||||
|
|
||||||
|
fun Manga.toSManga() = SManga.create().also {
|
||||||
|
it.url = url
|
||||||
|
it.title = title
|
||||||
|
it.artist = artist
|
||||||
|
it.author = author
|
||||||
|
it.description = description
|
||||||
|
it.genre = genres.orEmpty().joinToString()
|
||||||
|
it.status = status
|
||||||
|
it.thumbnail_url = thumbnailUrl
|
||||||
|
it.initialized = initialized
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Manga.copyFrom(other: SManga): Manga {
|
||||||
|
val author = other.author ?: author
|
||||||
|
val artist = other.artist ?: artist
|
||||||
|
val description = other.description ?: description
|
||||||
|
val genres = if (other.genre != null) other.getGenres() else genres
|
||||||
|
val thumbnailUrl = other.thumbnail_url ?: thumbnailUrl
|
||||||
|
return this.copy(
|
||||||
|
author = author,
|
||||||
|
artist = artist,
|
||||||
|
description = description,
|
||||||
|
genres = genres,
|
||||||
|
thumbnailUrl = thumbnailUrl,
|
||||||
|
)
|
||||||
|
}
|
|
@ -9,11 +9,11 @@ kotlin {
|
||||||
sourceSets {
|
sourceSets {
|
||||||
val commonMain by getting {
|
val commonMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation(projects.sourceApi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val androidMain by getting {
|
val androidMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(projects.sourceApi)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ data class Manga(
|
||||||
val artist: String?,
|
val artist: String?,
|
||||||
val author: String?,
|
val author: String?,
|
||||||
val description: String?,
|
val description: String?,
|
||||||
val genre: String?,
|
val genres: List<String>?,
|
||||||
val status: Int,
|
val status: Int,
|
||||||
val thumbnailUrl: String?,
|
val thumbnailUrl: String?,
|
||||||
val updateStrategy: UpdateStrategy,
|
val updateStrategy: UpdateStrategy,
|
|
@ -24,6 +24,11 @@ interface SManga : Serializable {
|
||||||
|
|
||||||
var initialized: Boolean
|
var initialized: Boolean
|
||||||
|
|
||||||
|
fun getGenres(): List<String>? {
|
||||||
|
if (genre.isNullOrBlank()) return null
|
||||||
|
return genre?.split(", ")?.map { it.trim() }?.filterNot { it.isBlank() }?.distinct()
|
||||||
|
}
|
||||||
|
|
||||||
fun copy() = create().also {
|
fun copy() = create().also {
|
||||||
it.url = url
|
it.url = url
|
||||||
it.title = title
|
it.title = title
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue