From 902bb35ba7f56f06660985dda0f7f8abf41ee669 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Fri, 15 Jul 2022 03:17:31 +0600 Subject: [PATCH] Little cleanup for stub source (#7519) * Little cleanup for stub source Fixes instances where name shows up blank for stub sources * Review Changes Co-authored-by: Andreas Co-authored-by: Andreas --- .../java/eu/kanade/domain/source/model/SourceData.kt | 5 ++++- .../java/eu/kanade/tachiyomi/source/SourceManager.kt | 11 ++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/source/model/SourceData.kt b/app/src/main/java/eu/kanade/domain/source/model/SourceData.kt index f9fcbf37f7..44fe16d020 100644 --- a/app/src/main/java/eu/kanade/domain/source/model/SourceData.kt +++ b/app/src/main/java/eu/kanade/domain/source/model/SourceData.kt @@ -4,4 +4,7 @@ data class SourceData( val id: Long, val lang: String, val name: String, -) +) { + + val isMissingInfo: Boolean = name.isBlank() || lang.isBlank() +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt b/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt index 2f3dbbe3cf..18e7fbeb13 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt @@ -108,12 +108,12 @@ class SourceManager(private val context: Context) { @Suppress("OverridingDeprecatedMember") open inner class StubSource(val sourceData: SourceData) : Source { - override val name: String = sourceData.name + override val id: Long = sourceData.id + + override val name: String = sourceData.name.ifBlank { id.toString() } override val lang: String = sourceData.lang - override val id: Long = sourceData.id - override suspend fun getMangaDetails(manga: MangaInfo): MangaInfo { throw getSourceNotInstalledException() } @@ -139,10 +139,7 @@ class SourceManager(private val context: Context) { } override fun toString(): String { - if (name.isNotBlank() && lang.isNotBlank()) { - return "$name (${lang.uppercase()})" - } - return id.toString() + return if (sourceData.isMissingInfo.not()) "$name (${lang.uppercase()})" else id.toString() } fun getSourceNotInstalledException(): SourceNotInstalledException {