mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-12 12:08:56 +01:00
Minor cleanup
This commit is contained in:
@@ -56,7 +56,7 @@ class AndroidSourceManager(
|
||||
extensions.forEach { extension ->
|
||||
extension.sources.forEach {
|
||||
mutableMap[it.id] = it
|
||||
registerStubSource(it.toStubSource())
|
||||
registerStubSource(StubSource.from(it))
|
||||
}
|
||||
}
|
||||
sourcesMapFlow.value = mutableMap
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
package eu.kanade.tachiyomi.source
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import tachiyomi.domain.source.model.StubSource
|
||||
import tachiyomi.source.local.isLocal
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
fun Source.icon(): Drawable? = Injekt.get<ExtensionManager>().getAppIconForSource(this.id)
|
||||
|
||||
fun Source.toStubSource(): StubSource = StubSource(id = id, lang = lang, name = name)
|
||||
|
||||
fun Source.getNameForMangaInfo(): String {
|
||||
val preferences = Injekt.get<SourcePreferences>()
|
||||
val enabledLanguages = preferences.enabledLanguages().get()
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package eu.kanade.tachiyomi.source.model
|
||||
|
||||
import tachiyomi.data.Chapters
|
||||
|
||||
fun SChapter.copyFrom(other: Chapters) {
|
||||
name = other.name
|
||||
url = other.url
|
||||
date_upload = other.date_upload
|
||||
chapter_number = other.chapter_number.toFloat()
|
||||
scanlator = other.scanlator
|
||||
}
|
||||
@@ -3,58 +3,14 @@ package eu.kanade.tachiyomi.source.model
|
||||
import tachiyomi.data.Mangas
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
|
||||
fun SManga.copyFrom(other: Mangas) {
|
||||
if (other.author != null) {
|
||||
author = other.author
|
||||
}
|
||||
|
||||
if (other.artist != null) {
|
||||
artist = other.artist
|
||||
}
|
||||
|
||||
if (other.description != null) {
|
||||
description = other.description
|
||||
}
|
||||
|
||||
if (other.genre != null) {
|
||||
genre = other.genre!!.joinToString(separator = ", ")
|
||||
}
|
||||
|
||||
if (other.thumbnail_url != null) {
|
||||
thumbnail_url = other.thumbnail_url
|
||||
}
|
||||
|
||||
status = other.status.toInt()
|
||||
|
||||
if (!initialized) {
|
||||
initialized = other.initialized
|
||||
}
|
||||
}
|
||||
|
||||
fun Manga.copyFrom(other: Mangas): Manga {
|
||||
var manga = this
|
||||
if (other.author != null) {
|
||||
manga = manga.copy(author = other.author)
|
||||
}
|
||||
|
||||
if (other.artist != null) {
|
||||
manga = manga.copy(artist = other.artist)
|
||||
}
|
||||
|
||||
if (other.description != null) {
|
||||
manga = manga.copy(description = other.description)
|
||||
}
|
||||
|
||||
if (other.genre != null) {
|
||||
manga = manga.copy(genre = other.genre)
|
||||
}
|
||||
|
||||
if (other.thumbnail_url != null) {
|
||||
manga = manga.copy(thumbnailUrl = other.thumbnail_url)
|
||||
}
|
||||
|
||||
other.author?.let { manga = manga.copy(author = it) }
|
||||
other.artist?.let { manga = manga.copy(artist = it) }
|
||||
other.description?.let { manga = manga.copy(description = it) }
|
||||
other.genre?.let { manga = manga.copy(genre = it) }
|
||||
other.thumbnail_url?.let { manga = manga.copy(thumbnailUrl = it) }
|
||||
manga = manga.copy(status = other.status)
|
||||
|
||||
if (!initialized) {
|
||||
manga = manga.copy(initialized = other.initialized)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user