Created
October 15, 2017 17:51
-
-
Save amitshekhariitbhu/b50148fbdd73b1d822fe06270130175e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RxSearchObservable { | |
public static Observable<String> fromView(SearchView searchView) { | |
final PublishSubject<String> subject = PublishSubject.create(); | |
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { | |
@Override | |
public boolean onQueryTextSubmit(String s) { | |
subject.onComplete(); | |
return true; | |
} | |
@Override | |
public boolean onQueryTextChange(String text) { | |
subject.onNext(text); | |
return true; | |
} | |
}); | |
return subject; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment