From f7bb356abdc17c43be47fd69d2f95cd7882f6711 Mon Sep 17 00:00:00 2001 From: len Date: Sat, 16 Jul 2016 17:25:22 +0200 Subject: [PATCH] Fix exception thrown when Batoto search is empty --- .../kanade/tachiyomi/data/source/online/english/Batoto.kt | 2 +- .../eu/kanade/tachiyomi/ui/catalogue/CatalogueAdapter.kt | 8 +++++--- .../kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt | 1 - 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/source/online/english/Batoto.kt b/app/src/main/java/eu/kanade/tachiyomi/data/source/online/english/Batoto.kt index 7f114bfdb..0fe674241 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/source/online/english/Batoto.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/source/online/english/Batoto.kt @@ -73,7 +73,7 @@ class Batoto(context: Context, override val id: Int) : ParsedOnlineSource(contex } } - override fun popularMangaSelector() = "tr:not([id]):not([class])" + override fun popularMangaSelector() = "tr:has(a)" override fun popularMangaFromElement(element: Element, manga: Manga) { element.select("a[href^=http://bato.to]").first().let { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueAdapter.kt index 7ece6c950..4674ddcf7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueAdapter.kt @@ -36,9 +36,11 @@ class CatalogueAdapter(val fragment: CatalogueFragment) : FlexibleAdapter) { - val sizeBeforeAdding = mItems.size - mItems.addAll(list) - notifyItemRangeInserted(sizeBeforeAdding, list.size) + if (list.isNotEmpty()) { + val sizeBeforeAdding = mItems.size + mItems.addAll(list) + notifyItemRangeInserted(sizeBeforeAdding, list.size) + } } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt index 359c1c04c..6d1b9426a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.kt @@ -229,7 +229,6 @@ class CataloguePresenter : BasePresenter() { source.fetchSearchManga(nextMangasPage, query) return observable.subscribeOn(Schedulers.io()) - .doOnNext { if (it.mangas.isEmpty()) throw Exception("Empty page") } .doOnNext { lastMangasPage = it } .flatMap { Observable.from(it.mangas) } .map { networkToLocalManga(it) }