From a3236e98d0b79803c1b6ff0d34357afac4933bec Mon Sep 17 00:00:00 2001 From: inorichi Date: Mon, 19 Oct 2015 04:23:31 +0200 Subject: [PATCH] Instant search when leaving search mode --- .../kanade/mangafeed/presenter/CataloguePresenter.java | 10 ++++++---- .../mangafeed/ui/activity/CatalogueActivity.java | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java b/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java index 1adeb03671..34161a6aac 100644 --- a/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java +++ b/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java @@ -122,9 +122,7 @@ public class CataloguePresenter extends BasePresenter { .debounce(SEARCH_TIMEOUT, TimeUnit.MILLISECONDS) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe( - this::queryFromSearch, - error -> Timber.e(error.getCause(), error.getMessage())); + .subscribe(this::queryFromSearch); add(mSearchViewSubscription); } @@ -176,11 +174,15 @@ public class CataloguePresenter extends BasePresenter { } public void onQueryTextChange(String query) { + if (query.equals("")) { + queryFromSearch(query); + return; + } if (mSearchViewPublishSubject != null) mSearchViewPublishSubject.onNext(Observable.just(query)); } - private void queryFromSearch(String query) { + public void queryFromSearch(String query) { // If text didn't change if (mSearchName.equals(query)) { return; diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java index a46899e0b2..85744def11 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java @@ -86,7 +86,7 @@ public class CatalogueActivity extends BaseActivity { sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { - getPresenter().onQueryTextChange(query); + getPresenter().queryFromSearch(query); return true; }