Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RxView not emitting focusChanges for SearchViews #382

Open
neteinstein opened this issue May 17, 2017 · 1 comment
Open

RxView not emitting focusChanges for SearchViews #382

neteinstein opened this issue May 17, 2017 · 1 comment

Comments

@neteinstein
Copy link

Observable<Boolean> mSearchFocusObs = RxView
                .focusChanges(mViewBuilder.getSearchView())
                .share();

DisposableObserver<Boolean> mSearchStateDisposable = mSearchFocusObs
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(getSearchFocusObserver());


private DisposableObserver<Boolean> getSearchFocusObserver() {
        return new DisposableObserver<Boolean>() {
            @Override
            public void onNext(Boolean isFocused) {
                Log.d("Test", "getSearchFocusObserver", "Focus? " + isFocused);

            }

            @Override
            public void onError(Throwable e) {
                Log.e("Test", "getSearchFocusObserver", "Error doing search");
            }

            @Override
            public void onComplete() {
                Log.d("Test", "getSearchFocusObserver", "Focus!!!");
            }
        };
    }

This is being called only once, when the Activity is opened:

D/TestApplication: TestActivity getSearchFocusObserver Focus? false

After it's never called.

For what I digged, it's due to SearchView not reacting correctly to mySearchView.setOnFocusChangeListener()

but only to

mySearchView.setOnQueryTextFocusChangeListener()

So my suggestion would be to either validate the type of View and then use the different method.. or have RxSearchView binding with focus option.

@tallnato
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants