diff --git a/.travis.yml b/.travis.yml index 70da574e8e..aa62653c59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ android: - tools # The BuildTools version used by your project - - build-tools-25.0.0 + - build-tools-25.0.1 - android-25 - extra-android-m2repository - extra-google-m2repository diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index 1f1f53a313..4338b7d573 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -96,16 +96,17 @@ class DownloadManager(context: Context) { */ private fun buildPageList(chapterDir: UniFile?): Observable> { return Observable.fromCallable { - val pages = mutableListOf() - chapterDir?.listFiles() - ?.filter { it.type?.startsWith("image") ?: false } - ?.sortedBy { it.name } - ?.forEach { file -> - val page = Page(pages.size, uri = file.uri) - pages.add(page) - page.status = Page.READY + val files = chapterDir?.listFiles().orEmpty() + .filter { "image" in it.type.orEmpty() } + + if (files.isEmpty()) { + throw Exception("Page list is empty") + } + + files.sortedBy { it.name } + .mapIndexed { i, file -> + Page(i, uri = file.uri).apply { status = Page.READY } } - pages } }