Minor cleanup

This commit is contained in:
arkon 2023-04-22 22:29:17 -04:00
parent d62d94f587
commit 67b4e53a58
9 changed files with 14 additions and 14 deletions

View file

@ -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,

View file

@ -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")}",
)

View file

@ -173,7 +173,7 @@ data class ExtensionDetailsState(
) {
val sources: List<ExtensionSourceItem>
get() = _sources ?: emptyList()
get() = _sources.orEmpty()
val isLoading: Boolean
get() = extension == null || _sources == null

View file

@ -64,7 +64,7 @@ data class MigrateMangaState(
) {
val titles: List<Manga>
get() = titleList ?: emptyList()
get() = titleList.orEmpty()
val isLoading: Boolean
get() = source == null || titleList == null

View file

@ -311,7 +311,7 @@ class BrowseSourceScreenModel(
return getCategories.subscribe()
.firstOrNull()
?.filterNot { it.isSystemCategory }
?: emptyList()
.orEmpty()
}
suspend fun getDuplicateLibraryManga(manga: Manga): Manga? {

View file

@ -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<LibraryItem> {
return library.values.toTypedArray().getOrNull(page) ?: emptyList()
return library.values.toTypedArray().getOrNull(page).orEmpty()
}
fun getMangaCountForCategory(category: Category): Int? {

View file

@ -25,7 +25,8 @@ class DirectoryPageLoader(val file: File) : PageLoader() {
stream = streamFn
status = Page.State.READY
}
} ?: emptyList()
}
.orEmpty()
}
/**

View file

@ -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()
}

View file

@ -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) {