From 5d396bfb7c5ec31d24876e885144c168a14c963a Mon Sep 17 00:00:00 2001 From: len Date: Wed, 27 Apr 2016 00:56:37 +0200 Subject: [PATCH] Make query non nullable, it fixes some bugs in the catalogue --- .../tachiyomi/ui/catalogue/CataloguePresenter.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 a3dbe9b5d..cbf67fa51 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 @@ -52,7 +52,7 @@ class CataloguePresenter : BasePresenter() { /** * Query from the view. */ - var query: String? = null + var query = "" private set /** @@ -104,7 +104,7 @@ class CataloguePresenter : BasePresenter() { source = getLastUsedSource() if (savedState != null) { - query = savedState.getString(QUERY_KEY) + query = savedState.getString(QUERY_KEY, "") } startableLatestCache(GET_MANGA_DETAILS, @@ -160,7 +160,7 @@ class CataloguePresenter : BasePresenter() { fun setActiveSource(source: Source) { prefs.lastUsedCatalogueSource().set(source.id) this.source = source - restartPager(null) + restartPager() } /** @@ -168,7 +168,7 @@ class CataloguePresenter : BasePresenter() { * * @param query the query, or null if searching popular manga. */ - fun restartPager(query: String?) { + fun restartPager(query: String = "") { this.query = query stop(REQUEST_PAGE) lastMangasPage = null @@ -215,10 +215,10 @@ class CataloguePresenter : BasePresenter() { nextMangasPage.url = lastMangasPage!!.nextPageUrl } - val observable = if (query.isNullOrEmpty()) + val observable = if (query.isEmpty()) source.pullPopularMangasFromNetwork(nextMangasPage) else - source.searchMangasFromNetwork(nextMangasPage, query!!) + source.searchMangasFromNetwork(nextMangasPage, query) return observable.subscribeOn(Schedulers.io()) .doOnNext { lastMangasPage = it }