Closed tmtron closed 7 years ago
As far as I understand the following code from DebounceSearchEmitterFragment.java#L76:
_disposable = RxJavaInterop.toV2Observable(RxTextView.textChangeEvents(_inputSearchText)) .debounce(400, TimeUnit.MILLISECONDS)// default Scheduler is Computation .filter(changes -> isNotNullOrEmpty(_inputSearchText.getText().toString())) .observeOn(AndroidSchedulers.mainThread()) .subscribeWith(_getSearchObserver());
filter() accesses the GUI element _inputSearchText, which it must not do: see StackOverflow: Is it okay to read data from UI elements in another thread?
filter()
_inputSearchText
Instead the text should be read from the change-event like this: .filter(changes -> isNotNullOrEmpty(changes.text().toString()))
.filter(changes -> isNotNullOrEmpty(changes.text().toString()))
great catch! do you feel like submitting a mini-PR instead :) ? i'm happy to make the change, but would like to attribute the credit to you.
As far as I understand the following code from DebounceSearchEmitterFragment.java#L76:
filter()
accesses the GUI element_inputSearchText
, which it must not do: see StackOverflow: Is it okay to read data from UI elements in another thread?Instead the text should be read from the change-event like this:
.filter(changes -> isNotNullOrEmpty(changes.text().toString()))