mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
refactor: Allow nullable [skip ci]
This commit is contained in:
parent
73b395000f
commit
1d7fab08cf
2 changed files with 4 additions and 2 deletions
|
@ -181,7 +181,7 @@ class DownloadManager(val context: Context) {
|
|||
fun buildPageList(source: Source, manga: Manga, chapter: Chapter): List<Page> {
|
||||
val chapterDir = provider.findChapterDir(chapter, manga, source)
|
||||
val files = chapterDir?.listFiles().orEmpty()
|
||||
.filter { it.isFile && ImageUtil.isImage(it.name.orEmpty()) { it.openInputStream() } }
|
||||
.filter { it.isFile && ImageUtil.isImage(it.name) { it.openInputStream() } }
|
||||
|
||||
if (files.isEmpty()) {
|
||||
throw Exception(context.getString(MR.strings.no_pages_found))
|
||||
|
|
|
@ -44,7 +44,9 @@ import kotlin.math.roundToInt
|
|||
|
||||
object ImageUtil {
|
||||
|
||||
fun isImage(name: String, openStream: (() -> InputStream)? = null): Boolean {
|
||||
fun isImage(name: String?, openStream: (() -> InputStream)? = null): Boolean {
|
||||
if (name == null) return false
|
||||
|
||||
val extension = name.substringAfterLast('.')
|
||||
return ImageType.entries.any { it.extension == extension } || openStream?.let { findImageType(it) } != null
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue