From d7d46f4447746d5719cbc30532522e9ccdf405ca Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 18 Sep 2021 16:13:14 -0400 Subject: [PATCH] Minor cleanup --- .../eu/kanade/tachiyomi/source/LocalSource.kt | 19 +++++++------------ .../ui/manga/info/MangaInfoHeaderAdapter.kt | 3 ++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index b28b79213..c4b68fd9a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt @@ -271,18 +271,13 @@ class LocalSource(private val context: Context) : CatalogueSource { throw Exception(context.getString(R.string.chapter_not_found)) } - private fun getFormat(file: File): Format { - return file.run { - when { - isDirectory -> Format.Directory(file) - extension.equals("zip", true) -> Format.Zip(file) - extension.equals("cbz", true) -> Format.Zip(file) - extension.equals("rar", true) -> Format.Rar(file) - extension.equals("cbr", true) -> Format.Rar(file) - extension.equals("epub", true) -> Format.Epub(file) - - else -> throw Exception("Invalid chapter format") - } + private fun getFormat(file: File) = with(file) { + when { + isDirectory -> Format.Directory(this) + extension.equals("zip", true) || extension.equals("cbz", true) -> Format.Zip(this) + extension.equals("rar", true) || extension.equals("cbr", true) -> Format.Rar(this) + extension.equals("epub", true) -> Format.Epub(this) + else -> throw Exception(context.getString(R.string.local_invalid_format)) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt index 67d046862..5dff9c637 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt @@ -368,7 +368,8 @@ class MangaInfoHeaderAdapter( private fun updateDescription(description: String?, isCurrentlyExpanded: Boolean): CharSequence { return when { description.isNullOrBlank() -> view.context.getString(R.string.unknown) - isCurrentlyExpanded -> description + isCurrentlyExpanded -> + description .replace(Regex(" +\$", setOf(RegexOption.MULTILINE)), "") .replace(Regex("[\\r\\n]{2,}", setOf(RegexOption.MULTILINE)), "\n") else -> description