From 67b4e53a58209a42d03fcc00e3b7191f955bf257 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 22 Apr 2023 22:29:17 -0400 Subject: [PATCH] Minor cleanup --- .../eu/kanade/tachiyomi/data/backup/models/BackupManga.kt | 2 +- .../kanade/tachiyomi/extension/api/ExtensionGithubApi.kt | 2 +- .../extension/details/ExtensionDetailsScreenModel.kt | 2 +- .../ui/browse/migration/manga/MigrationMangaScreenModel.kt | 2 +- .../ui/browse/source/browse/BrowseSourceScreenModel.kt | 2 +- .../eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt | 4 ++-- .../tachiyomi/ui/reader/loader/DirectoryPageLoader.kt | 3 ++- .../java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt | 7 +++---- .../kotlin/tachiyomi/source/local/LocalSource.kt | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt index cef57a31bc..a38d45197f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt @@ -79,7 +79,7 @@ data class BackupManga( artist = manga.artist, author = manga.author, description = manga.description, - genre = manga.genre ?: emptyList(), + genre = manga.genre.orEmpty(), status = manga.status.toInt(), thumbnailUrl = manga.thumbnailUrl, favorite = manga.favorite, diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt index 5ccd503b2b..c9e381dd14 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt @@ -124,7 +124,7 @@ internal class ExtensionGithubApi { isNsfw = it.nsfw == 1, hasReadme = it.hasReadme == 1, hasChangelog = it.hasChangelog == 1, - sources = it.sources?.toExtensionSources() ?: emptyList(), + sources = it.sources?.toExtensionSources().orEmpty(), apkName = it.apk, iconUrl = "${getUrlPrefix()}icon/${it.apk.replace(".apk", ".png")}", ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt index ceace82ce6..9a35a72710 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt @@ -173,7 +173,7 @@ data class ExtensionDetailsState( ) { val sources: List - get() = _sources ?: emptyList() + get() = _sources.orEmpty() val isLoading: Boolean get() = extension == null || _sources == null diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaScreenModel.kt index 958976f015..f0cfad2ef7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaScreenModel.kt @@ -64,7 +64,7 @@ data class MigrateMangaState( ) { val titles: List - get() = titleList ?: emptyList() + get() = titleList.orEmpty() val isLoading: Boolean get() = source == null || titleList == null diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt index bd98f1a1e2..bc44ae9dbd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt @@ -311,7 +311,7 @@ class BrowseSourceScreenModel( return getCategories.subscribe() .firstOrNull() ?.filterNot { it.isSystemCategory } - ?: emptyList() + .orEmpty() } suspend fun getDuplicateLibraryManga(manga: Manga): Manga? { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt index 99c94d8029..e5411fd842 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt @@ -355,7 +355,7 @@ class LibraryScreenModel( categories } - displayCategories.associateWith { libraryManga[it.id] ?: emptyList() } + displayCategories.associateWith { libraryManga[it.id].orEmpty() } } } @@ -700,7 +700,7 @@ class LibraryScreenModel( } fun getLibraryItemsByPage(page: Int): List { - return library.values.toTypedArray().getOrNull(page) ?: emptyList() + return library.values.toTypedArray().getOrNull(page).orEmpty() } fun getMangaCountForCategory(category: Category): Int? { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DirectoryPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DirectoryPageLoader.kt index 1b25c273e9..c55ebddb68 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DirectoryPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DirectoryPageLoader.kt @@ -25,7 +25,8 @@ class DirectoryPageLoader(val file: File) : PageLoader() { stream = streamFn status = Page.State.READY } - } ?: emptyList() + } + .orEmpty() } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt index 38cdc0f19e..b57abbba5b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt @@ -57,10 +57,9 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att val title = getString(R.styleable.MaterialSpinnerView_title).orEmpty() binding.title.text = title - val viewEntries = ( - getTextArray(R.styleable.MaterialSpinnerView_android_entries) - ?: emptyArray() - ).map { it.toString() } + val viewEntries = getTextArray(R.styleable.MaterialSpinnerView_android_entries) + .orEmpty() + .map { it.toString() } entries = viewEntries binding.details.text = viewEntries.firstOrNull().orEmpty() } diff --git a/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt b/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt index 7683bf3b7b..76633cbda9 100644 --- a/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt +++ b/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt @@ -290,8 +290,8 @@ actual class LocalSource( fun getFormat(chapter: SChapter): Format { try { return fileSystem.getBaseDirectories() - .map { directory -> File(directory, chapter.url) } - .find { chapterFile -> chapterFile.exists() } + .map { dir -> File(dir, chapter.url) } + .find { it.exists() } ?.let(Format.Companion::valueOf) ?: throw Exception(context.getString(R.string.chapter_not_found)) } catch (e: Format.UnknownFormatException) {