Instant search when leaving search mode
This commit is contained in:
parent
85d34ab9e5
commit
a3236e98d0
@ -122,9 +122,7 @@ public class CataloguePresenter extends BasePresenter<CatalogueActivity> {
|
|||||||
.debounce(SEARCH_TIMEOUT, TimeUnit.MILLISECONDS)
|
.debounce(SEARCH_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(
|
.subscribe(this::queryFromSearch);
|
||||||
this::queryFromSearch,
|
|
||||||
error -> Timber.e(error.getCause(), error.getMessage()));
|
|
||||||
|
|
||||||
add(mSearchViewSubscription);
|
add(mSearchViewSubscription);
|
||||||
}
|
}
|
||||||
@ -176,11 +174,15 @@ public class CataloguePresenter extends BasePresenter<CatalogueActivity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onQueryTextChange(String query) {
|
public void onQueryTextChange(String query) {
|
||||||
|
if (query.equals("")) {
|
||||||
|
queryFromSearch(query);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mSearchViewPublishSubject != null)
|
if (mSearchViewPublishSubject != null)
|
||||||
mSearchViewPublishSubject.onNext(Observable.just(query));
|
mSearchViewPublishSubject.onNext(Observable.just(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void queryFromSearch(String query) {
|
public void queryFromSearch(String query) {
|
||||||
// If text didn't change
|
// If text didn't change
|
||||||
if (mSearchName.equals(query)) {
|
if (mSearchName.equals(query)) {
|
||||||
return;
|
return;
|
||||||
|
@ -86,7 +86,7 @@ public class CatalogueActivity extends BaseActivity<CataloguePresenter> {
|
|||||||
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextSubmit(String query) {
|
public boolean onQueryTextSubmit(String query) {
|
||||||
getPresenter().onQueryTextChange(query);
|
getPresenter().queryFromSearch(query);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user