소스 검색

Instant search when leaving search mode

inorichi 9 년 전
부모
커밋
a3236e98d0

+ 6 - 4
app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java

@@ -122,9 +122,7 @@ public class CataloguePresenter extends BasePresenter<CatalogueActivity> {
                 .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<CatalogueActivity> {
     }
 
     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;

+ 1 - 1
app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java

@@ -86,7 +86,7 @@ public class CatalogueActivity extends BaseActivity<CataloguePresenter> {
         sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
             @Override
             public boolean onQueryTextSubmit(String query) {
-                getPresenter().onQueryTextChange(query);
+                getPresenter().queryFromSearch(query);
                 return true;
             }